"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
fs: Add Find method to DirTree
Nick Craig-Wood71fe046937cc
diff --git a/fs/walk.go b/fs/walk.goindex ef3c9e093..d2c0dff9b 100644--- a/fs/walk.go+++ b/fs/walk.go@@ -203,19 +203,27 @@ func (dt DirTree) addDir(entry DirEntry) {}}+// Find returns the DirEntry for filePath or nil if not found+func (dt DirTree) Find(filePath string) (parentPath string, entry DirEntry) {+ parentPath = parentDir(filePath)+ for _, entry := range dt[parentPath] {+ if entry.Remote() == filePath {+ return parentPath, entry+ }+ }+ return parentPath, nil+}+// check that dirPath has a *Dir in its parentfunc (dt DirTree) checkParent(root, dirPath string) {if dirPath == root {return}- parentPath := parentDir(dirPath)- entries := dt[parentPath]- for _, entry := range entries {- if entry.Remote() == dirPath {- return- }+ parentPath, entry := dt.Find(dirPath)+ if entry != nil {+ return}- dt[parentPath] = append(entries, NewDir(dirPath, time.Now()))+ dt[parentPath] = append(dt[parentPath], NewDir(dirPath, time.Now()))dt.checkParent(root, parentPath)}