mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:41:44 +08:00
S3: Fix mkdir not to error if bucket exists and implement SetModTime
This commit is contained in:
parent
b9e468ebbd
commit
38ce4c3629
34
fs_s3.go
34
fs_s3.go
|
@ -248,7 +248,13 @@ func (f *FsS3) Put(src FsObject) {
|
|||
|
||||
// Mkdir creates the bucket if it doesn't exist
|
||||
func (f *FsS3) Mkdir() error {
|
||||
return f.b.PutBucket(f.perm)
|
||||
err := f.b.PutBucket(f.perm)
|
||||
if err, ok := err.(*s3.Error); ok {
|
||||
if err.Code == "BucketAlreadyOwnedByYou" {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Rmdir deletes the bucket
|
||||
|
@ -329,20 +335,18 @@ func (fs *FsObjectS3) ModTime() time.Time {
|
|||
|
||||
// Sets the modification time of the local fs object
|
||||
func (fs *FsObjectS3) SetModTime(modTime time.Time) {
|
||||
// FIXME goamz can't set metadata, though it is possible with a PUT and copy
|
||||
FsLog(fs, "Can't set mod time yet: %s", modTime)
|
||||
// err := fs.readMetaData()
|
||||
// if err != nil {
|
||||
// stats.Error()
|
||||
// FsLog(fs, "Failed to read metadata: %s", err)
|
||||
// return
|
||||
// }
|
||||
// fs.meta.SetModTime(modTime)
|
||||
// err = fs.s3.c.ObjectUpdate(fs.s3.bucket, fs.remote, fs.meta.ObjectHeaders())
|
||||
// if err != nil {
|
||||
// stats.Error()
|
||||
// FsLog(fs, "Failed to update remote mtime: %s", err)
|
||||
// }
|
||||
err := fs.readMetaData()
|
||||
if err != nil {
|
||||
stats.Error()
|
||||
FsLog(fs, "Failed to read metadata: %s", err)
|
||||
return
|
||||
}
|
||||
fs.meta[metaMtime] = swift.TimeToFloatString(modTime)
|
||||
_, err = fs.s3.b.Update(fs.remote, fs.s3.perm, fs.meta)
|
||||
if err != nil {
|
||||
stats.Error()
|
||||
FsLog(fs, "Failed to update remote mtime: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Is this object storable
|
||||
|
|
|
@ -2,7 +2,7 @@ Todo
|
|||
* Factor fses into own packages
|
||||
* FIXME: ls without an argument for buckets/containers?
|
||||
* FIXME: More -dry-run checks for object transfer
|
||||
* FIXME: EU Region not working
|
||||
* Might be quicker to check md5sums first? for swift <-> swift certainly, and maybe for small files
|
||||
* Ignoring the pseudo directories
|
||||
* if object.PseudoDirectory {
|
||||
* fmt.Printf("%9s %19s %s\n", "Directory", "-", fs.Remote())
|
||||
|
|
Loading…
Reference in New Issue
Block a user