Skip to content

Commit

Permalink
adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
SandyXSD committed Mar 25, 2023
1 parent da6d9c7 commit 369585c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
19 changes: 7 additions & 12 deletions cmd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func clone(ctx *cli.Context) error {
if srcMp != dstMp {
return fmt.Errorf("the clone DST path should be at the same mount point as the SRC path")
}

if strings.HasPrefix(dstAbsPath, srcAbsPath) {
return fmt.Errorf("the clone DST path should not be under the SRC path")
}
Expand Down Expand Up @@ -143,20 +142,16 @@ func clone(ctx *cli.Context) error {
}
return nil
}
func findMountpoint(dir string) (string, error) {
odir := dir
for dir != "" {
inode, err := utils.GetFileInode(dir)

func findMountpoint(fpath string) (string, error) {
for p := fpath; p != "/"; p = filepath.Dir(p) {
inode, err := utils.GetFileInode(p)
if err != nil {
return "", fmt.Errorf("get inode of %s: %s", dir, err)
return "", fmt.Errorf("get inode of %s: %s", p, err)
}
if inode == uint64(meta.RootInode) {
return dir, nil
}
dir = filepath.Dir(dir)
if dir == "/" {
return "", fmt.Errorf("%s is not inside JuiceFS", odir)
return p, nil
}
}
return "", fmt.Errorf("%s is not inside JuiceFS", odir)
return "", fmt.Errorf("%s is not inside JuiceFS", fpath)
}
4 changes: 2 additions & 2 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func info(ctx *cli.Context) error {
}
f, err := openController(d)
if err != nil {
logger.Errorf("open control file for: %s", err)
logger.Errorf("Open control file for %s: %s", d, err)
continue
}

Expand Down Expand Up @@ -246,7 +246,7 @@ func ltypeToString(t uint32) string {
func legacyInfo(d, path string, inode uint64, recursive, raw uint8) {
f, err := openController(d)
if err != nil {
logger.Errorf("open control file for: %s", err)
logger.Errorf("Open control file for %s: %s", d, err)
return
}
defer f.Close()
Expand Down
2 changes: 1 addition & 1 deletion cmd/rmr.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func rmr(ctx *cli.Context) error {
}
f, err := openController(d)
if err != nil {
logger.Errorf("open control file for: %s", err)
logger.Errorf("Open control file for %s: %s", d, err)
continue
}
wb := utils.NewBuffer(8 + 8 + 1 + uint32(len(name)))
Expand Down
2 changes: 1 addition & 1 deletion cmd/warmup.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func warmup(ctx *cli.Context) error {
}
controller, err := openController(mp)
if err != nil {
return fmt.Errorf("open control file for: %s", first)
return fmt.Errorf("open control file for %s: %s", first, err)
}
defer controller.Close()

Expand Down

0 comments on commit 369585c

Please sign in to comment.