"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
cache: Remove entries that no longer exist in the source
dcpuc0084f43dd4f
diff --git a/backend/cache/cache.go b/backend/cache/cache.goindex 6e3f092f0..2caaf4069 100644--- a/backend/cache/cache.go+++ b/backend/cache/cache.go@@ -11,6 +11,7 @@ import ("os/signal""path""path/filepath"+ "sort""strconv""strings""sync"@@ -891,7 +892,6 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) {fs.Debugf(dir, "list: cached entries: %v", entries)return entries, nil}- // FIXME need to clean existing cached listing// we first search any temporary files stored locallyvar cachedEntries fs.DirEntries@@ -917,27 +917,42 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) {}// search from the source- entries, err = f.Fs.List(dir)+ sourceEntries, err := f.Fs.List(dir)if err != nil {return nil, err}- fs.Debugf(dir, "list: read %v from source", len(entries))- fs.Debugf(dir, "list: source entries: %v", entries)+ fs.Debugf(dir, "list: read %v from source", len(sourceEntries))+ fs.Debugf(dir, "list: source entries: %v", sourceEntries)++ sort.Sort(sourceEntries)+ for _, entry := range entries {+ entryRemote := entry.Remote()+ i := sort.Search(len(sourceEntries), func(i int) bool { return sourceEntries[i].Remote() >= entryRemote })+ if i < len(sourceEntries) && sourceEntries[i].Remote() == entryRemote {+ continue+ }+ fp := path.Join(f.Root(), entryRemote)+ switch entry.(type) {+ case fs.Object:+ _ = f.cache.RemoveObject(fp)+ case fs.Directory:+ _ = f.cache.RemoveDir(fp)+ }+ fs.Debugf(dir, "list: remove entry: %v", entryRemote)+ }+ entries = nil// and then iterate over the ones from source (temp Objects will override source ones)var batchDirectories []*Directory- for _, entry := range entries {+ sort.Sort(cachedEntries)+ tmpCnt := len(cachedEntries)+ for _, entry := range sourceEntries {switch o := entry.(type) {case fs.Object:// skip over temporary objects (might be uploading)- found := false- for _, t := range cachedEntries {- if t.Remote() == o.Remote() {- found = true- break- }- }- if found {+ oRemote := o.Remote()+ i := sort.Search(tmpCnt, func(i int) bool { return cachedEntries[i].Remote() >= oRemote })+ if i < tmpCnt && cachedEntries[i].Remote() == oRemote {continue}co := ObjectFromOriginal(f, o).persist()