ulozto: fix server side moves between differently rooted remotes losing files
The Move method compared the source and destination paths relative to their own Fs roots, so a server side move between two differently rooted Fs instances on the same remote (as used by --backup-dir and sync moves between remotes) was skipped as "already there" whenever the relative paths coincided. With --backup-dir this destroyed the file which was supposed to be backed up. Compare the full paths including the Fs roots instead.
This commit is contained in:
@@ -572,17 +572,19 @@ func (f *Fs) Rmdir(ctx context.Context, dir string) error {
|
||||
|
||||
// Move implements the optional method fs.Mover.Move.
|
||||
func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, error) {
|
||||
if remote == src.Remote() {
|
||||
// Already there, do nothing
|
||||
return src, nil
|
||||
}
|
||||
|
||||
srcObj, ok := src.(*Object)
|
||||
if !ok {
|
||||
fs.Debugf(src, "Can't move - not same remote type")
|
||||
return nil, fs.ErrorCantMove
|
||||
}
|
||||
|
||||
// src may be on a differently rooted Fs (eg with --backup-dir) so
|
||||
// compare the full paths including the Fs roots
|
||||
if path.Join(srcObj.fs.root, srcObj.remote) == path.Join(f.root, remote) {
|
||||
// Already there, do nothing
|
||||
return src, nil
|
||||
}
|
||||
|
||||
filename, folderSlug, err := f.dirCache.FindPath(ctx, remote, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user