mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 14:22:04 +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
|
// Mkdir creates the bucket if it doesn't exist
|
||||||
func (f *FsS3) Mkdir() error {
|
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
|
// Rmdir deletes the bucket
|
||||||
|
@ -329,20 +335,18 @@ func (fs *FsObjectS3) ModTime() time.Time {
|
||||||
|
|
||||||
// Sets the modification time of the local fs object
|
// Sets the modification time of the local fs object
|
||||||
func (fs *FsObjectS3) SetModTime(modTime time.Time) {
|
func (fs *FsObjectS3) SetModTime(modTime time.Time) {
|
||||||
// FIXME goamz can't set metadata, though it is possible with a PUT and copy
|
err := fs.readMetaData()
|
||||||
FsLog(fs, "Can't set mod time yet: %s", modTime)
|
if err != nil {
|
||||||
// err := fs.readMetaData()
|
stats.Error()
|
||||||
// if err != nil {
|
FsLog(fs, "Failed to read metadata: %s", err)
|
||||||
// stats.Error()
|
return
|
||||||
// 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)
|
||||||
// fs.meta.SetModTime(modTime)
|
if err != nil {
|
||||||
// err = fs.s3.c.ObjectUpdate(fs.s3.bucket, fs.remote, fs.meta.ObjectHeaders())
|
stats.Error()
|
||||||
// if err != nil {
|
FsLog(fs, "Failed to update remote mtime: %s", err)
|
||||||
// stats.Error()
|
}
|
||||||
// FsLog(fs, "Failed to update remote mtime: %s", err)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this object storable
|
// Is this object storable
|
||||||
|
|
|
@ -2,7 +2,7 @@ Todo
|
||||||
* Factor fses into own packages
|
* Factor fses into own packages
|
||||||
* FIXME: ls without an argument for buckets/containers?
|
* FIXME: ls without an argument for buckets/containers?
|
||||||
* FIXME: More -dry-run checks for object transfer
|
* 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
|
* Ignoring the pseudo directories
|
||||||
* if object.PseudoDirectory {
|
* if object.PseudoDirectory {
|
||||||
* fmt.Printf("%9s %19s %s\n", "Directory", "-", fs.Remote())
|
* fmt.Printf("%9s %19s %s\n", "Directory", "-", fs.Remote())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user