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

drime: disable server side copy as it always fails

Nick Craig-Wood961266888fe7
diff --git a/backend/drime/drime.go b/backend/drime/drime.go
index 2499627f6..3b3978b13 100644
--- a/backend/drime/drime.go
+++ b/backend/drime/drime.go
@@ -420,14 +420,6 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
return f, nil
}
-// rootSlash returns root with a slash on if it is empty, otherwise empty string
-func (f *Fs) rootSlash() string {
- if f.root == "" {
- return f.root
- }
- return f.root + "/"
-}
-
// Return an Object from a path
//
// If it can't be found it returns the error fs.ErrorObjectNotFound.
@@ -1012,108 +1004,6 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
return nil
}
-// copy a file or a folder to a new directory
-func (f *Fs) copy(ctx context.Context, id, newDirID string) (item *api.Item, err error) {
- var resp *http.Response
- var request = api.CopyRequest{
- EntryIDs: []string{id},
- DestinationID: newDirID,
- }
- var result api.CopyResponse
- opts := rest.Opts{
- Method: "POST",
- Path: "/file-entries/duplicate",
- Parameters: url.Values{},
- }
- if f.opt.WorkspaceID != "" {
- opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
- }
- err = f.pacer.Call(func() (bool, error) {
- resp, err = f.srv.CallJSON(ctx, &opts, &request, &result)
- return shouldRetry(ctx, resp, err)
- })
- if err != nil {
- return nil, fmt.Errorf("failed to copy item: %w", err)
- }
- itemResult := result.Entries[0]
- return &itemResult, nil
-}
-
-// copy and rename a file or folder to directoryID with leaf
-func (f *Fs) copyTo(ctx context.Context, srcID, srcLeaf, dstLeaf, dstDirectoryID string) (info *api.Item, err error) {
- // Can have duplicates so don't have to be careful here
-
- // Copy to dstDirectoryID first
- info, err = f.copy(ctx, srcID, dstDirectoryID)
- if err != nil {
- return nil, err
- }
-
- // Rename if required
- if srcLeaf != dstLeaf {
- info, err = f.rename(ctx, info.ID.String(), dstLeaf)
- if err != nil {
- return nil, err
- }
- }
- return info, nil
-}
-
-// Copy src to this remote using server-side copy operations.
-//
-// This is stored with the remote path given.
-//
-// It returns the destination Object and a possible error.
-//
-// Will only be called if src.Fs().Name() == f.Name()
-//
-// If it isn't possible then return fs.ErrorCantCopy
-func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dst fs.Object, err error) {
- srcObj, ok := src.(*Object)
- if !ok {
- fs.Debugf(src, "Can't copy - not same remote type")
- return nil, fs.ErrorCantCopy
- }
- srcLeaf := path.Base(srcObj.remote)
-
- srcPath := srcObj.fs.rootSlash() + srcObj.remote
- dstPath := f.rootSlash() + remote
- if srcPath == dstPath {
- return nil, fmt.Errorf("can't copy %q -> %q as are same name", srcPath, dstPath)
- }
-
- // Find existing object
- existingObj, err := f.NewObject(ctx, remote)
- if err == nil {
- defer func() {
- // Don't remove existing object if returning an error
- if err != nil {
- return
- }
- fs.Debugf(existingObj, "Server side copy: removing existing object after successful copy")
- err = existingObj.Remove(ctx)
- }()
- }
-
- // Create temporary object
- dstObj, dstLeaf, dstDirectoryID, err := f.createObject(ctx, remote, srcObj.modTime, srcObj.size)
- if err != nil {
- return nil, err
- }
-
- // Copy the object
- info, err := f.copyTo(ctx, srcObj.id, srcLeaf, dstLeaf, dstDirectoryID)
- if err != nil {
- return nil, err
- }
- err = dstObj.setMetaData(info)
- if err != nil {
- return nil, err
- }
-
- return dstObj, nil
-}
-
// DirCacheFlush resets the directory cache - used in testing as an
// optional interface
func (f *Fs) DirCacheFlush() {
@@ -1672,7 +1562,6 @@ var (
_ fs.Fs = (*Fs)(nil)
_ fs.Purger = (*Fs)(nil)
_ fs.PutStreamer = (*Fs)(nil)
- _ fs.Copier = (*Fs)(nil)
_ fs.Mover = (*Fs)(nil)
_ fs.DirMover = (*Fs)(nil)
_ fs.DirCacheFlusher = (*Fs)(nil)
diff --git a/docs/data/backends/drime.yaml b/docs/data/backends/drime.yaml
index fa5c40997..546e54a50 100644
--- a/docs/data/backends/drime.yaml
+++ b/docs/data/backends/drime.yaml
@@ -14,7 +14,6 @@ remote: 'TestDrime:'
features:
- About
- CanHaveEmptyDirectories
-- Copy
- DirCacheFlush
- DirMove
- Move