Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Add support for server side move operations

Too Much IOca017980a3e9
diff --git a/amazonclouddrive/amazonclouddrive.go b/amazonclouddrive/amazonclouddrive.go
index cc6cc287f..2d9d86963 100644
--- a/amazonclouddrive/amazonclouddrive.go
+++ b/amazonclouddrive/amazonclouddrive.go
@@ -674,6 +674,51 @@ func (f *Fs) Hashes() fs.HashSet {
return fs.HashSet(fs.HashMD5)
}
+func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
+ srcObj, ok := src.(*Object)
+ if !ok {
+ fs.Debug(src, "Can't move - not same remote type")
+ return nil, fs.ErrorCantMove
+ }
+
+ // Temporary Object under construction
+ dstObj := &Object{
+ fs: f,
+ remote: remote,
+ }
+
+ var err error
+ _, directoryID, err := f.dirCache.FindPath(remote, false)
+ if err != nil {
+ return nil, err
+ }
+
+ var info *acd.Node
+ var resp *http.Response
+ if directoryID == srcObj.info.Parents[0] {
+ // Do the rename
+ err = f.pacer.Call(func() (bool, error) {
+ info, resp, err = srcObj.info.Rename(remote)
+ return srcObj.fs.shouldRetry(resp, err)
+ })
+ if err != nil {
+ return nil, err
+ }
+ } else {
+ // Do the move
+ err = f.pacer.Call(func() (bool, error) {
+ info, resp, err = srcObj.info.Move(directoryID)
+ return srcObj.fs.shouldRetry(resp, err)
+ })
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ dstObj.info = info
+ return dstObj, nil
+}
+
// Copy src to this remote using server side copy operations.
//
// This is stored with the remote path given
@@ -881,7 +926,7 @@ var (
_ fs.Fs = (*Fs)(nil)
_ fs.Purger = (*Fs)(nil)
// _ fs.Copier = (*Fs)(nil)
- // _ fs.Mover = (*Fs)(nil)
+ _ fs.Mover = (*Fs)(nil)
// _ fs.DirMover = (*Fs)(nil)
_ fs.Object = (*Object)(nil)
_ fs.MimeTyper = &Object{}