From 479c5a514acf1b029f17963700da7310764ef7a9 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 28 Jun 2017 21:14:53 +0100 Subject: [PATCH] swift, s3, gcs: create container if necessary on server side copy --- googlecloudstorage/googlecloudstorage.go | 4 ++++ s3/s3.go | 6 +++++- swift/swift.go | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/googlecloudstorage/googlecloudstorage.go b/googlecloudstorage/googlecloudstorage.go index 430b17a44..4218c5492 100644 --- a/googlecloudstorage/googlecloudstorage.go +++ b/googlecloudstorage/googlecloudstorage.go @@ -550,6 +550,10 @@ func (f *Fs) Precision() time.Duration { // // If it isn't possible then return fs.ErrorCantCopy func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) { + err := f.Mkdir("") + if err != nil { + return nil, err + } srcObj, ok := src.(*Object) if !ok { fs.Debugf(src, "Can't copy - not same remote type") diff --git a/s3/s3.go b/s3/s3.go index 63649e3f0..c0b34979e 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -755,6 +755,10 @@ func (f *Fs) Precision() time.Duration { // // If it isn't possible then return fs.ErrorCantCopy func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) { + err := f.Mkdir("") + if err != nil { + return nil, err + } srcObj, ok := src.(*Object) if !ok { fs.Debugf(src, "Can't copy - not same remote type") @@ -769,7 +773,7 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) { CopySource: &source, MetadataDirective: aws.String(s3.MetadataDirectiveCopy), } - _, err := f.c.CopyObject(&req) + _, err = f.c.CopyObject(&req) if err != nil { return nil, err } diff --git a/swift/swift.go b/swift/swift.go index 9fdad6514..344317e70 100644 --- a/swift/swift.go +++ b/swift/swift.go @@ -520,13 +520,17 @@ func (f *Fs) Purge() error { // // If it isn't possible then return fs.ErrorCantCopy func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) { + err := f.Mkdir("") + if err != nil { + return nil, err + } srcObj, ok := src.(*Object) if !ok { fs.Debugf(src, "Can't copy - not same remote type") return nil, fs.ErrorCantCopy } srcFs := srcObj.fs - _, err := f.c.ObjectCopy(srcFs.container, srcFs.root+srcObj.remote, f.container, f.root+remote, nil) + _, err = f.c.ObjectCopy(srcFs.container, srcFs.root+srcObj.remote, f.container, f.root+remote, nil) if err != nil { return nil, err }