Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

dircache: expose FoundRoot flag

Nick Craig-Wood1a82ba196bea
diff --git a/dircache/dircache.go b/dircache/dircache.go
index e8bc6c46f..4b7f8f1b3 100644
--- a/dircache/dircache.go
+++ b/dircache/dircache.go
@@ -131,10 +131,6 @@ func (dc *DirCache) _findDirInCache(path string) string {
// Unlocked findDir - must have mu
func (dc *DirCache) _findDir(path string, create bool) (pathID string, err error) {
- // if !dc.foundRoot {
- // return "", fmt.Errorf("FindDir called before FindRoot")
- // }
-
pathID = dc._findDirInCache(path)
if pathID != "" {
return pathID, nil
@@ -204,12 +200,11 @@ func (dc *DirCache) FindRoot(create bool) error {
if dc.foundRoot {
return nil
}
- dc.foundRoot = true
rootID, err := dc._findDir(dc.root, create)
if err != nil {
- dc.foundRoot = false
return err
}
+ dc.foundRoot = true
dc.rootID = rootID
// Find the parent of the root while we still have the root
@@ -224,6 +219,13 @@ func (dc *DirCache) FindRoot(create bool) error {
return nil
}
+// FoundRoot returns whether the root directory has been found yet
+//
+// Call this from FindLeaf or CreateDir only
+func (dc *DirCache) FoundRoot() bool {
+ return dc.foundRoot
+}
+
// RootID returns the ID of the root directory
//
// This should be called after FindRoot