Use filesystem walk ordering rather than hash order

s3-about
Nick Craig-Wood 2012-11-28 11:38:14 +00:00
parent 3e4f75b558
commit a49b8ca0b6
2 changed files with 3 additions and 5 deletions

View File

@ -13,8 +13,6 @@ subargs.append('x-object-meta-mtime:%d' % getmtime(options.input_))
Need an iterate all objects routine... Could use a channel
- could just be a flag to Objects()
FIXME ordering not hash order
FIXME progress meter would be nice! Do this by wrapping the Reader with a progress bar
Do bandwidth limit by wrapping the Reader too

View File

@ -40,7 +40,7 @@ type FsObject struct {
info os.FileInfo
}
type FsObjects map[string]FsObject
type FsObjects []FsObject
// md5sum calculates the md5sum of a file returning a lowercase hex string
func md5sum(path string) (string, error) {
@ -141,7 +141,7 @@ func (fs *FsObject) put(c *swift.Connection, container string) {
// FIXME ignore symlinks?
// FIXME what about hardlinks / etc
func walk(root string) FsObjects {
files := make(FsObjects)
files := make(FsObjects, 0, 1024)
err := filepath.Walk(root, func(path string, f os.FileInfo, err error) error {
if err != nil {
log.Printf("Failed to open directory: %s: %s", path, err)
@ -159,7 +159,7 @@ func walk(root string) FsObjects {
if rel == "." {
rel = ""
}
files[rel] = FsObject{rel: rel, path: path, info: info}
files = append(files, FsObject{rel: rel, path: path, info: info})
}
return nil
})