diff --git a/cmn/objlist_utils.go b/cmn/objlist_utils.go index 44aec9867db..80dcb2256e5 100644 --- a/cmn/objlist_utils.go +++ b/cmn/objlist_utils.go @@ -225,12 +225,14 @@ func TokenGreaterEQ(token, objName string) bool { return token >= objName } // an alternative name for this function could be smth. like SameBranch() // see also: cos.TrimPrefix func DirHasOrIsPrefix(dirPath, prefix string) bool { - return prefix == "" || (strings.HasPrefix(prefix, dirPath) || strings.HasPrefix(dirPath, prefix)) + debug.Assert(prefix != "") + return strings.HasPrefix(prefix, dirPath) || strings.HasPrefix(dirPath, prefix) } // see also: cos.TrimPrefix func ObjHasPrefix(objName, prefix string) bool { - return prefix == "" || strings.HasPrefix(objName, prefix) + debug.Assert(prefix != "") + return strings.HasPrefix(objName, prefix) } // no recursion (LsNoRecursion) helper function: diff --git a/reb/globrun.go b/reb/globrun.go index c262a12b0a8..9de6ec8eb5c 100644 --- a/reb/globrun.go +++ b/reb/globrun.go @@ -10,6 +10,7 @@ import ( "io" "net/http" "path/filepath" + "strings" "sync" ratomic "sync/atomic" "time" @@ -834,8 +835,14 @@ func (rj *rebJogger) _lwalk(lom *core.LOM, fqn string) error { if rj.rargs.prefix != "" { debug.Assert(rj.rargs.bck != nil) if !cmn.ObjHasPrefix(lom.ObjName, rj.rargs.prefix) { - if len(lom.ObjName) > len(rj.rargs.prefix)+1 { - nlog.Warningln(rj.rargs.logHdr, "skip-dir", lom.ObjName) + // + // TODO: unify via (fs.WalkBck => validateCb => cmn.DirHasOrIsPrefix) + // + i := strings.IndexByte(lom.ObjName, filepath.Separator) + if i > 0 && !cmn.DirHasOrIsPrefix(lom.ObjName[:i], rj.rargs.prefix) { + if cmn.Rom.FastV(4, cos.SmoduleReb) { + nlog.Warningln(rj.rargs.logHdr, "skip-dir", lom.ObjName, "prefix", rj.rargs.prefix) + } return filepath.SkipDir } return cmn.ErrSkip diff --git a/xact/xs/wi_lso.go b/xact/xs/wi_lso.go index decaebbaba6..50031c3d2d4 100644 --- a/xact/xs/wi_lso.go +++ b/xact/xs/wi_lso.go @@ -66,7 +66,7 @@ func (wi *walkInfo) processDir(fqn string) error { return nil } - if !cmn.DirHasOrIsPrefix(ct.ObjectName(), wi.msg.Prefix) { + if wi.msg.Prefix != "" && !cmn.DirHasOrIsPrefix(ct.ObjectName(), wi.msg.Prefix) { return filepath.SkipDir } @@ -81,7 +81,7 @@ func (wi *walkInfo) processDir(fqn string) error { } func (wi *walkInfo) match(objName string) bool { - if !cmn.ObjHasPrefix(objName, wi.msg.Prefix) { + if wi.msg.Prefix != "" && !cmn.ObjHasPrefix(objName, wi.msg.Prefix) { return false } return wi.msg.ContinuationToken == "" || !cmn.TokenGreaterEQ(wi.msg.ContinuationToken, objName)