mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 20:04:52 +01:00
onedrive: implement --onedrive-server-side-across-configs - fixes #4058
This commit is contained in:
parent
37d5e75a56
commit
77e94be280
@ -252,6 +252,16 @@ delete OneNote files or otherwise want them to show up in directory
|
|||||||
listing, set this option.`,
|
listing, set this option.`,
|
||||||
Default: false,
|
Default: false,
|
||||||
Advanced: true,
|
Advanced: true,
|
||||||
|
}, {
|
||||||
|
Name: "server_side_across_configs",
|
||||||
|
Default: false,
|
||||||
|
Help: `Allow server side operations (eg copy) to work across different onedrive configs.
|
||||||
|
|
||||||
|
This can be useful if you wish to do a server side copy between two
|
||||||
|
different Onedrives. Note that this isn't enabled by default
|
||||||
|
because it isn't easy to tell if it will work between any two
|
||||||
|
configurations.`,
|
||||||
|
Advanced: true,
|
||||||
}, {
|
}, {
|
||||||
Name: config.ConfigEncoding,
|
Name: config.ConfigEncoding,
|
||||||
Help: config.ConfigEncodingHelp,
|
Help: config.ConfigEncodingHelp,
|
||||||
@ -308,6 +318,7 @@ type Options struct {
|
|||||||
DriveID string `config:"drive_id"`
|
DriveID string `config:"drive_id"`
|
||||||
DriveType string `config:"drive_type"`
|
DriveType string `config:"drive_type"`
|
||||||
ExposeOneNoteFiles bool `config:"expose_onenote_files"`
|
ExposeOneNoteFiles bool `config:"expose_onenote_files"`
|
||||||
|
ServerSideAcrossConfigs bool `config:"server_side_across_configs"`
|
||||||
Enc encoder.MultiEncoder `config:"encoding"`
|
Enc encoder.MultiEncoder `config:"encoding"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,6 +588,7 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
|
|||||||
CaseInsensitive: true,
|
CaseInsensitive: true,
|
||||||
ReadMimeType: true,
|
ReadMimeType: true,
|
||||||
CanHaveEmptyDirectories: true,
|
CanHaveEmptyDirectories: true,
|
||||||
|
ServerSideAcrossConfigs: opt.ServerSideAcrossConfigs,
|
||||||
}).Fill(f)
|
}).Fill(f)
|
||||||
f.srv.SetErrorHandler(errorHandler)
|
f.srv.SetErrorHandler(errorHandler)
|
||||||
|
|
||||||
@ -989,11 +1001,14 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check we aren't overwriting a file on the same remote
|
||||||
|
if srcObj.fs == f {
|
||||||
srcPath := srcObj.rootPath()
|
srcPath := srcObj.rootPath()
|
||||||
dstPath := f.rootPath(remote)
|
dstPath := f.rootPath(remote)
|
||||||
if strings.ToLower(srcPath) == strings.ToLower(dstPath) {
|
if strings.ToLower(srcPath) == strings.ToLower(dstPath) {
|
||||||
return nil, errors.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
return nil, errors.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create temporary object
|
// Create temporary object
|
||||||
dstObj, leaf, directoryID, err := f.createObject(ctx, remote, srcObj.modTime, srcObj.size)
|
dstObj, leaf, directoryID, err := f.createObject(ctx, remote, srcObj.modTime, srcObj.size)
|
||||||
|
Loading…
Reference in New Issue
Block a user