From 12015b0007f8853e35080b39e920377e5939e7f2 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 2 Jan 2013 15:34:25 +0000 Subject: [PATCH] Run ls in parallel so can parallelise the slow ModTime operations --- notes.txt | 4 +++- swiftsync.go | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) 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