Make ModTime fall back to LastModified header

Which means it no longer needs to report an error which simplifies the code
This commit is contained in:
Nick Craig-Wood
2013-01-02 15:21:55 +00:00
parent 90a2c86eb3
commit ecb863dd4f
5 changed files with 26 additions and 37 deletions

View File

@ -183,12 +183,7 @@ func (f *FsSwift) Put(src FsObject) {
// Set the mtime
m := swift.Metadata{}
modTime, err := src.ModTime()
if err != nil {
FsDebug(fs, "Failed to read mtime from object: %s", err)
} else {
m.SetModTime(modTime)
}
m.SetModTime(src.ModTime())
_, err = fs.swift.c.ObjectPut(fs.swift.container, fs.remote, in, true, "", "", m.ObjectHeaders())
if err != nil {
@ -246,18 +241,22 @@ func (fs *FsObjectSwift) readMetaData() (err error) {
}
// ModTime returns the modification time of the object
func (fs *FsObjectSwift) ModTime() (modTime time.Time, err error) {
err = fs.readMetaData()
//
//
// It attempts to read the objects mtime and if that isn't present the
// LastModified returned in the http headers
func (fs *FsObjectSwift) ModTime() time.Time {
err := fs.readMetaData()
if err != nil {
FsLog(fs, "Failed to read metadata: %s", err)
return
// FsLog(fs, "Failed to read metadata: %s", err)
return fs.info.LastModified
}
modTime, err = fs.meta.GetModTime()
modTime, err := fs.meta.GetModTime()
if err != nil {
FsLog(fs, "Failed to read mtime from object: %s", err)
return
// FsLog(fs, "Failed to read mtime from object: %s", err)
return fs.info.LastModified
}
return
return modTime
}
// Sets the modification time of the local fs object