diff --git a/vfs/vfscache/cache.go b/vfs/vfscache/cache.go index dc1b73f14..979652891 100644 --- a/vfs/vfscache/cache.go +++ b/vfs/vfscache/cache.go @@ -376,7 +376,7 @@ func rename(osOldPath, osNewPath string) error { if !os.IsNotExist(err) { return fmt.Errorf("Failed to stat destination: %s: %w", osNewPath, err) } - parent := vfscommon.OsFindParent(osNewPath) + parent := vfscommon.OSFindParent(osNewPath) err = createDir(parent) if err != nil { return fmt.Errorf("Failed to create parent dir: %s: %w", parent, err) diff --git a/vfs/vfscommon/path.go b/vfs/vfscommon/path.go index 77225df0f..93b42a93e 100644 --- a/vfs/vfscommon/path.go +++ b/vfs/vfscommon/path.go @@ -5,11 +5,11 @@ import ( "path/filepath" ) -// OsFindParent returns the parent directory of name, or "" for the +// OSFindParent returns the parent directory of name, or "" for the // root for OS native paths. -func OsFindParent(name string) string { +func OSFindParent(name string) string { parent := filepath.Dir(name) - if parent == "." || parent == "/" { + if parent == "." || (len(parent) == 1 && parent[0] == filepath.Separator) { parent = "" } return parent