1
mirror of https://github.com/rclone/rclone synced 2024-12-19 09:05:56 +01:00

Fix relative vs absolute path confusion in logging

This commit is contained in:
Nick Craig-Wood 2012-11-28 11:32:04 +00:00
parent e3096508dd
commit 3e4f75b558
2 changed files with 13 additions and 15 deletions

View File

@ -19,6 +19,4 @@ FIXME progress meter would be nice! Do this by wrapping the Reader with a progre
Do bandwidth limit by wrapping the Reader too Do bandwidth limit by wrapping the Reader too
If length is same but remote has no mtime, then could fall back to checking the checksum and if that was OK then just update the object meta time.
Could have an integrity check mode where we check the MD5sums of the local vs the remote Could have an integrity check mode where we check the MD5sums of the local vs the remote

View File

@ -70,34 +70,34 @@ func md5sum(path string) (string, error) {
func (fs *FsObject) changed(c *swift.Connection, container string) bool { func (fs *FsObject) changed(c *swift.Connection, container string) bool {
obj, h, err := c.Object(container, fs.rel) obj, h, err := c.Object(container, fs.rel)
if err != nil { if err != nil {
log.Printf("Failed to read info %s: %s", fs.path, err) log.Printf("Failed to read info %s: %s", fs.rel, err)
return true return true
} }
if obj.Bytes != fs.info.Size() { if obj.Bytes != fs.info.Size() {
log.Printf("Sizes differ %s", fs.path) log.Printf("Sizes differ %s", fs.rel)
return true return true
} }
m := h.ObjectMetadata() m := h.ObjectMetadata()
t, err := m.GetModTime() t, err := m.GetModTime()
if err != nil { if err != nil {
log.Printf("Failed to read mtime %s: %s", fs.path, err) log.Printf("Failed to read mtime %s: %s", fs.rel, err)
localMd5, err := md5sum(fs.path) localMd5, err := md5sum(fs.path)
// log.Printf("Local MD5 %s", localMd5) // log.Printf("Local MD5 %s", localMd5)
// log.Printf("Remote MD5 %s", obj.Hash) // log.Printf("Remote MD5 %s", obj.Hash)
if err != nil { if err != nil {
log.Printf("Failed to calculate md5 %s: %s", fs.path, err) log.Printf("Failed to calculate md5 %s: %s", fs.rel, err)
return true return true
} }
if localMd5 != strings.ToLower(obj.Hash) { if localMd5 != strings.ToLower(obj.Hash) {
log.Printf("Md5sums differ %s", fs.path) log.Printf("Md5sums differ %s", fs.rel)
return true return true
} }
log.Printf("Md5sums identical - skipping %s", fs.path) log.Printf("Md5sums identical - skipping %s", fs.rel)
// FIXME update the mtime of the remote object here // FIXME update the mtime of the remote object here
return false return false
} }
if !t.Equal(fs.info.ModTime()) { if !t.Equal(fs.info.ModTime()) {
log.Printf("mtimes differ: %s", fs.path) log.Printf("mtimes differ: %s", fs.rel)
return true return true
} }
return false return false
@ -107,20 +107,20 @@ func (fs *FsObject) changed(c *swift.Connection, container string) bool {
func (fs *FsObject) put(c *swift.Connection, container string) { func (fs *FsObject) put(c *swift.Connection, container string) {
mode := fs.info.Mode() mode := fs.info.Mode()
if mode&(os.ModeSymlink|os.ModeNamedPipe|os.ModeSocket|os.ModeDevice) != 0 { if mode&(os.ModeSymlink|os.ModeNamedPipe|os.ModeSocket|os.ModeDevice) != 0 {
log.Printf("Can't transfer non file/directory %s", fs.path) log.Printf("Can't transfer non file/directory %s", fs.rel)
} else if mode&os.ModeDir != 0 { } else if mode&os.ModeDir != 0 {
// Debug? // Debug?
log.Printf("FIXME Skipping directory %s", fs.path) log.Printf("FIXME Skipping directory %s", fs.rel)
} else { } else {
// Check to see if changed or not // Check to see if changed or not
if !fs.changed(c, container) { if !fs.changed(c, container) {
log.Printf("Unchanged skipping %s", fs.path) log.Printf("Unchanged skipping %s", fs.rel)
return return
} }
// FIXME content type // FIXME content type
in, err := os.Open(fs.path) in, err := os.Open(fs.path)
if err != nil { if err != nil {
log.Printf("Failed to open %s: %s", fs.path, err) log.Printf("Failed to open %s: %s", fs.rel, err)
return return
} }
defer in.Close() defer in.Close()
@ -128,10 +128,10 @@ func (fs *FsObject) put(c *swift.Connection, container string) {
m.SetModTime(fs.info.ModTime()) m.SetModTime(fs.info.ModTime())
_, err = c.ObjectPut(container, fs.rel, in, true, "", "", m.ObjectHeaders()) _, err = c.ObjectPut(container, fs.rel, in, true, "", "", m.ObjectHeaders())
if err != nil { if err != nil {
log.Printf("Failed to upload %s: %s", fs.path, err) log.Printf("Failed to upload %s: %s", fs.rel, err)
return return
} }
log.Printf("Uploaded %s", fs.path) log.Printf("Uploaded %s", fs.rel)
} }
} }