mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 02:14:42 +01:00
Fix downloads - missing is the modified check so it downloads everything
This commit is contained in:
parent
e41a8b9a02
commit
a3e28e6b97
@ -39,3 +39,9 @@ Make a wrapper in connection which
|
|||||||
and resetting it if it has
|
and resetting it if it has
|
||||||
|
|
||||||
Check the locking in swift module!
|
Check the locking in swift module!
|
||||||
|
|
||||||
|
501 not implemented for paths with a ? in them! Probably need to do some escaping...
|
||||||
|
hello? sausage: Failed to read info: HTTP Error: 501: 501 Not Implemented
|
||||||
|
|
||||||
|
Need to make directory objects otherwise can't upload an empty directory
|
||||||
|
* Or could upload empty directories only?
|
||||||
|
54
swiftsync.go
54
swiftsync.go
@ -39,6 +39,11 @@ var (
|
|||||||
uploaders = flag.Int("uploaders", 4, "Number of uploaders to run in parallel.")
|
uploaders = flag.Int("uploaders", 4, "Number of uploaders to run in parallel.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Make this an interface?
|
||||||
|
//
|
||||||
|
// Have an implementation for SwiftObjects and FsObjects?
|
||||||
|
//
|
||||||
|
// This represents an object in the filesystem
|
||||||
type FsObject struct {
|
type FsObject struct {
|
||||||
rel string
|
rel string
|
||||||
path string
|
path string
|
||||||
@ -291,6 +296,8 @@ func upload(c *swift.Connection, root, container string) {
|
|||||||
uploaderWg.Wait()
|
uploaderWg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME should be an FsOject method
|
||||||
|
//
|
||||||
// Get an object to the filepath making directories if necessary
|
// Get an object to the filepath making directories if necessary
|
||||||
func get(c *swift.Connection, container, name, filepath string) {
|
func get(c *swift.Connection, container, name, filepath string) {
|
||||||
log.Printf("Download %s to %s", name, filepath)
|
log.Printf("Download %s to %s", name, filepath)
|
||||||
@ -308,22 +315,35 @@ func get(c *swift.Connection, container, name, filepath string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, geterr := c.ObjectGet(container, name, out, true, nil)
|
h, getErr := c.ObjectGet(container, name, out, true, nil)
|
||||||
if geterr != nil {
|
if getErr != nil {
|
||||||
log.Printf("Failed to download %q: %s", name, geterr)
|
log.Printf("Failed to download %q: %s", name, getErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = out.Close()
|
closeErr := out.Close()
|
||||||
if err != nil {
|
if closeErr != nil {
|
||||||
log.Printf("Error closing %q: %s", filepath, err)
|
log.Printf("Error closing %q: %s", filepath, closeErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if geterr != nil {
|
if getErr != nil || closeErr != nil {
|
||||||
log.Printf("Removing failed download %q", filepath)
|
log.Printf("Removing failed download %q", filepath)
|
||||||
err = os.Remove(filepath)
|
err = os.Remove(filepath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to remove %q: %s", filepath, err)
|
log.Printf("Failed to remove %q: %s", filepath, err)
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the mtime
|
||||||
|
// FIXME should be a FsObject method?
|
||||||
|
modTime, err := h.ObjectMetadata().GetModTime()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to read mtime from object: %s", err)
|
||||||
|
} else {
|
||||||
|
err = os.Chtimes(filepath, modTime, modTime)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to set mtime on file: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,16 +369,16 @@ func download(c *swift.Connection, container, root string) {
|
|||||||
for i := range objects {
|
for i := range objects {
|
||||||
object := &objects[i]
|
object := &objects[i]
|
||||||
filepath := path.Join(root, object.Name)
|
filepath := path.Join(root, object.Name)
|
||||||
fs := NewFsObject(root, filepath)
|
// fs := NewFsObject(root, filepath)
|
||||||
if fs == nil {
|
// if fs == nil {
|
||||||
log.Printf("%s: Download: not found", object.Name)
|
// log.Printf("%s: Download: not found", object.Name)
|
||||||
} else if !fs.storable(c, container) {
|
// } else if !fs.storable(c, container) {
|
||||||
fs.Debugf("Skip: not storable")
|
// fs.Debugf("Skip: not storable")
|
||||||
continue
|
// continue
|
||||||
} else if !fs.changed(c, container) {
|
// } else if !fs.changed(c, container) {
|
||||||
fs.Debugf("Skip: not changed")
|
// fs.Debugf("Skip: not changed")
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
get(c, container, object.Name, filepath)
|
get(c, container, object.Name, filepath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user