Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Run ls in parallel so can parallelise the slow ModTime operations

Nick Craig-Wood12015b0007f8
diff --git a/notes.txt b/notes.txt
index 342bbbfe7..839416d17 100644
--- a/notes.txt
+++ b/notes.txt
@@ -1,6 +1,8 @@
Todo
* FIXME: More -dry-run checks for object transfer
- * FIXME ls is very slow also - need to run mtimes in parallel
+ * Ignoring the pseudo directories
+ * if object.PseudoDirectory {
+ * fmt.Printf("%9s %19s %s\n", "Directory", "-", fs.Remote())
* Check logging in various parts
* Make logging controllable with flags (mostly done)
* progress meter would be nice! Do this by wrapping the Reader with a progress bar
diff --git a/swiftsync.go b/swiftsync.go
index 9d8294477..8e7cd9763 100644
--- a/swiftsync.go
+++ b/swiftsync.go
@@ -241,20 +241,22 @@ func Check(fdst, fsrc Fs) {
}
// List the Fs to stdout
+//
+// Lists in parallel which may get them out of order
func List(f Fs) {
- // FIXME error?
in := f.List()
- for fs := range in {
- // FIXME
- // if object.PseudoDirectory {
- // fmt.Printf("%9s %19s %s\n", "Directory", "-", fs.Remote())
- // } else {
- // FIXME ModTime is expensive?
- modTime := fs.ModTime()
- fmt.Printf("%9d %19s %s\n", fs.Size(), modTime.Format("2006-01-02 15:04:05"), fs.Remote())
- // fmt.Printf("%9d %19s %s\n", fs.Size(), object.LastModified.Format("2006-01-02 15:04:05"), fs.Remote())
- // }
+ var wg sync.WaitGroup
+ wg.Add(*checkers)
+ for i := 0; i < *checkers; i++ {
+ go func() {
+ defer wg.Done()
+ for fs := range in {
+ modTime := fs.ModTime()
+ fmt.Printf("%9d %19s %s\n", fs.Size(), modTime.Format("2006-01-02 15:04:05"), fs.Remote())
+ }
+ }()
}
+ wg.Wait()
}
// Lists files in a container