From 4028a4192f8d800df41d0054aac398780a826c51 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 28 Dec 2012 16:38:51 +0000 Subject: [PATCH] Use swift.ObjectsWalk --- fs_local.go | 5 ++--- fs_swift.go | 20 +++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/fs_local.go b/fs_local.go index bf6054172..7348f26d1 100644 --- a/fs_local.go +++ b/fs_local.go @@ -51,10 +51,9 @@ func (f *FsLocal) NewFsObject(remote string) FsObject { return f.NewFsObjectWithInfo(remote, nil) } -// Walk the path returning a channel of FsObjects +// List the path returning a channel of FsObjects // -// FIXME ignore symlinks? -// FIXME what about hardlinks / etc +// Ignores everything which isn't Storable, eg links etc func (f *FsLocal) List() FsObjectsChan { out := make(FsObjectsChan, *checkers) go func() { diff --git a/fs_swift.go b/fs_swift.go index 47bfa14ec..77913bdef 100644 --- a/fs_swift.go +++ b/fs_swift.go @@ -57,23 +57,21 @@ func (f *FsSwift) NewFsObject(remote string) FsObject { } // Walk the path returning a channel of FsObjects -// -// FIXME ignore symlinks? -// FIXME what about hardlinks / etc -// -// FIXME not returning error if dir not found? func (f *FsSwift) List() FsObjectsChan { out := make(FsObjectsChan, *checkers) go func() { // FIXME use a smaller limit? - err := f.c.ObjectsAllFn(f.container, nil, func(objects []swift.Object) bool { - for i := range objects { - object := &objects[i] - if fs := f.NewFsObjectWithInfo(object.Name, object); fs != nil { - out <- fs + err := f.c.ObjectsWalk(f.container, nil, func(opts *swift.ObjectsOpts) (interface{}, error) { + objects, err := f.c.Objects(f.container, opts) + if err == nil { + for i := range objects { + object := &objects[i] + if fs := f.NewFsObjectWithInfo(object.Name, object); fs != nil { + out <- fs + } } } - return false + return objects, err }) if err != nil { log.Printf("Couldn't read container %q: %s", f.container, err)