mirror of
https://github.com/rclone/rclone
synced 2024-12-22 13:03:02 +01:00
Add optional interface DirCacheFlush for making the tests more reliable
This is defined for the users of dircache drive, onedrive, and acd. This helps fix the DirMove tests on acd.
This commit is contained in:
parent
d911bf3889
commit
48a2e3844d
@ -636,6 +636,11 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
}
|
}
|
||||||
fs.Debug(src, "Attempting to move to %q", remote)
|
fs.Debug(src, "Attempting to move to %q", remote)
|
||||||
return srcObj.move(remote, false)
|
return srcObj.move(remote, false)
|
||||||
|
|
||||||
|
// DirCacheFlush resets the directory cache - used in testing as an
|
||||||
|
// optional interface
|
||||||
|
func (f *Fs) DirCacheFlush() {
|
||||||
|
f.dirCache.ResetRoot()
|
||||||
}
|
}
|
||||||
|
|
||||||
// DirMove moves src directory to this remote using server side move
|
// DirMove moves src directory to this remote using server side move
|
||||||
@ -1122,8 +1127,9 @@ var (
|
|||||||
_ fs.Fs = (*Fs)(nil)
|
_ fs.Fs = (*Fs)(nil)
|
||||||
_ fs.Purger = (*Fs)(nil)
|
_ fs.Purger = (*Fs)(nil)
|
||||||
// _ fs.Copier = (*Fs)(nil)
|
// _ fs.Copier = (*Fs)(nil)
|
||||||
_ fs.Mover = (*Fs)(nil)
|
_ fs.Mover = (*Fs)(nil)
|
||||||
_ fs.DirMover = (*Fs)(nil)
|
_ fs.DirMover = (*Fs)(nil)
|
||||||
_ fs.Object = (*Object)(nil)
|
_ fs.DirCacheFlusher = (*Fs)(nil)
|
||||||
_ fs.MimeTyper = &Object{}
|
_ fs.Object = (*Object)(nil)
|
||||||
|
_ fs.MimeTyper = &Object{}
|
||||||
)
|
)
|
||||||
|
@ -799,6 +799,12 @@ func (f *Fs) DirMove(src fs.Fs) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DirCacheFlush resets the directory cache - used in testing as an
|
||||||
|
// optional interface
|
||||||
|
func (f *Fs) DirCacheFlush() {
|
||||||
|
f.dirCache.ResetRoot()
|
||||||
|
}
|
||||||
|
|
||||||
// Hashes returns the supported hash sets.
|
// Hashes returns the supported hash sets.
|
||||||
func (f *Fs) Hashes() fs.HashSet {
|
func (f *Fs) Hashes() fs.HashSet {
|
||||||
return fs.HashSet(fs.HashMD5)
|
return fs.HashSet(fs.HashMD5)
|
||||||
@ -1079,12 +1085,13 @@ func (o *Object) MimeType() string {
|
|||||||
|
|
||||||
// Check the interfaces are satisfied
|
// Check the interfaces are satisfied
|
||||||
var (
|
var (
|
||||||
_ fs.Fs = (*Fs)(nil)
|
_ fs.Fs = (*Fs)(nil)
|
||||||
_ fs.Purger = (*Fs)(nil)
|
_ fs.Purger = (*Fs)(nil)
|
||||||
_ fs.Copier = (*Fs)(nil)
|
_ fs.Copier = (*Fs)(nil)
|
||||||
_ fs.Mover = (*Fs)(nil)
|
_ fs.Mover = (*Fs)(nil)
|
||||||
_ fs.DirMover = (*Fs)(nil)
|
_ fs.DirMover = (*Fs)(nil)
|
||||||
_ fs.PutUncheckeder = (*Fs)(nil)
|
_ fs.DirCacheFlusher = (*Fs)(nil)
|
||||||
_ fs.Object = (*Object)(nil)
|
_ fs.PutUncheckeder = (*Fs)(nil)
|
||||||
_ fs.MimeTyper = &Object{}
|
_ fs.Object = (*Object)(nil)
|
||||||
|
_ fs.MimeTyper = &Object{}
|
||||||
)
|
)
|
||||||
|
7
fs/fs.go
7
fs/fs.go
@ -275,6 +275,13 @@ type UnWrapper interface {
|
|||||||
UnWrap() Fs
|
UnWrap() Fs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DirCacheFlusher is an optional interface for Fs
|
||||||
|
type DirCacheFlusher interface {
|
||||||
|
// DirCacheFlush resets the directory cache - used in testing
|
||||||
|
// as an optional interface
|
||||||
|
DirCacheFlush()
|
||||||
|
}
|
||||||
|
|
||||||
// PutUncheckeder is an optional interface for Fs
|
// PutUncheckeder is an optional interface for Fs
|
||||||
type PutUncheckeder interface {
|
type PutUncheckeder interface {
|
||||||
// Put in to the remote path with the modTime given of the given size
|
// Put in to the remote path with the modTime given of the given size
|
||||||
|
@ -175,6 +175,10 @@ func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, expectedDirs
|
|||||||
sleep *= 2
|
sleep *= 2
|
||||||
t.Logf("Sleeping for %v for list eventual consistency: %d/%d", sleep, i, retries)
|
t.Logf("Sleeping for %v for list eventual consistency: %d/%d", sleep, i, retries)
|
||||||
time.Sleep(sleep)
|
time.Sleep(sleep)
|
||||||
|
if do, ok := f.(fs.DirCacheFlusher); ok {
|
||||||
|
t.Logf("Flushing the directory cache")
|
||||||
|
do.DirCacheFlush()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, obj := range objs {
|
for _, obj := range objs {
|
||||||
require.NotNil(t, obj)
|
require.NotNil(t, obj)
|
||||||
|
@ -635,6 +635,12 @@ func (f *Fs) Purge() error {
|
|||||||
return f.purgeCheck("", false)
|
return f.purgeCheck("", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DirCacheFlush resets the directory cache - used in testing as an
|
||||||
|
// optional interface
|
||||||
|
func (f *Fs) DirCacheFlush() {
|
||||||
|
f.dirCache.ResetRoot()
|
||||||
|
}
|
||||||
|
|
||||||
// Hashes returns the supported hash sets.
|
// Hashes returns the supported hash sets.
|
||||||
func (f *Fs) Hashes() fs.HashSet {
|
func (f *Fs) Hashes() fs.HashSet {
|
||||||
return fs.HashSet(fs.HashSHA1)
|
return fs.HashSet(fs.HashSHA1)
|
||||||
@ -960,6 +966,7 @@ var (
|
|||||||
_ fs.Copier = (*Fs)(nil)
|
_ fs.Copier = (*Fs)(nil)
|
||||||
// _ fs.Mover = (*Fs)(nil)
|
// _ fs.Mover = (*Fs)(nil)
|
||||||
// _ fs.DirMover = (*Fs)(nil)
|
// _ fs.DirMover = (*Fs)(nil)
|
||||||
_ fs.Object = (*Object)(nil)
|
_ fs.DirCacheFlusher = (*Fs)(nil)
|
||||||
_ fs.MimeTyper = &Object{}
|
_ fs.Object = (*Object)(nil)
|
||||||
|
_ fs.MimeTyper = &Object{}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user