Compare commits
2 commits
tcl/master
...
onedrive-s
Author | SHA1 | Date | |
---|---|---|---|
|
91faa2777a | ||
|
6e005b025a |
2 changed files with 34 additions and 3 deletions
|
@ -385,9 +385,19 @@ func (f *Fs) readMetaDataForPath(path string) (info *api.Item, resp *http.Respon
|
|||
var dirCacheFoundRoot bool
|
||||
var rootNormalizedID string
|
||||
if f.dirCache != nil {
|
||||
var ok bool
|
||||
if rootNormalizedID, ok = f.dirCache.Get(""); ok {
|
||||
dirCacheFoundRoot = true
|
||||
var dirCacheRootIDExists bool
|
||||
rootNormalizedID, dirCacheRootIDExists = f.dirCache.Get("")
|
||||
if f.root == "" {
|
||||
// if f.root == "", it means f.root is the absolute root of the drive
|
||||
// and its ID should have been found in NewFs
|
||||
dirCacheFoundRoot = dirCacheRootIDExists
|
||||
} else if _, err := f.dirCache.RootParentID(); err == nil {
|
||||
// if root is in a folder, it must have a parent folder, and
|
||||
// if dirCache has found root in NewFs, the parent folder's ID
|
||||
// should be present.
|
||||
// This RootParentID() check is a fix for #3164 which describes
|
||||
// a possible case where the root is not found.
|
||||
dirCacheFoundRoot = dirCacheRootIDExists
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1583,6 +1583,27 @@ func Run(t *testing.T, opt *Opt) {
|
|||
|
||||
})
|
||||
|
||||
// TestFsRootCollapse tests if the root of an fs "collapses" to the
|
||||
// absolute root. It creates a new fs of the same backend type with its
|
||||
// root set to a *non-existent* folder, and attempts to read the info of
|
||||
// an object in that folder, whose name is taken from a directory that
|
||||
// exists in the absolute root.
|
||||
// This test is added after
|
||||
// https://github.com/ncw/rclone/issues/3164.
|
||||
t.Run("FsRootCollapse", func(t *testing.T) {
|
||||
deepRemoteName := subRemoteName + "/deeper/nonexisting/directory"
|
||||
deepRemote, err := fs.NewFs(deepRemoteName)
|
||||
require.NoError(t, err)
|
||||
|
||||
colonIndex := strings.IndexRune(deepRemoteName, ':')
|
||||
firstSlashIndex := strings.IndexRune(deepRemoteName, '/')
|
||||
firstDir := deepRemoteName[colonIndex+1 : firstSlashIndex]
|
||||
_, err = deepRemote.NewObject(firstDir)
|
||||
require.Equal(t, fs.ErrorObjectNotFound, err)
|
||||
// If err is not fs.ErrorObjectNotFound, it means the backend is
|
||||
// somehow confused about root and absolute root.
|
||||
})
|
||||
|
||||
// Purge the folder
|
||||
err = operations.Purge(remote, "")
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Add table
Reference in a new issue