forked from TrueCloudLab/rclone
dircache: expose FoundRoot flag
This commit is contained in:
parent
ed72c678f8
commit
1a82ba196b
1 changed files with 8 additions and 6 deletions
|
@ -131,10 +131,6 @@ func (dc *DirCache) _findDirInCache(path string) string {
|
||||||
|
|
||||||
// Unlocked findDir - must have mu
|
// Unlocked findDir - must have mu
|
||||||
func (dc *DirCache) _findDir(path string, create bool) (pathID string, err error) {
|
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)
|
pathID = dc._findDirInCache(path)
|
||||||
if pathID != "" {
|
if pathID != "" {
|
||||||
return pathID, nil
|
return pathID, nil
|
||||||
|
@ -204,12 +200,11 @@ func (dc *DirCache) FindRoot(create bool) error {
|
||||||
if dc.foundRoot {
|
if dc.foundRoot {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
dc.foundRoot = true
|
|
||||||
rootID, err := dc._findDir(dc.root, create)
|
rootID, err := dc._findDir(dc.root, create)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dc.foundRoot = false
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
dc.foundRoot = true
|
||||||
dc.rootID = rootID
|
dc.rootID = rootID
|
||||||
|
|
||||||
// Find the parent of the root while we still have the root
|
// 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
|
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
|
// RootID returns the ID of the root directory
|
||||||
//
|
//
|
||||||
// This should be called after FindRoot
|
// This should be called after FindRoot
|
||||||
|
|
Loading…
Reference in a new issue