Skip to content

Commit 4a3f28c

Browse files
ncwyuval-cloudinary
authored andcommitted
gofile: fix Move a file
For some reason the parent ID got out of date in the Object (exact reason not known - but the fact that this was OK before suggests a change in the provider). However we know the parent ID as it is in the directory cache, so use that instead.
1 parent afc848c commit 4a3f28c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

backend/gofile/gofile.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,14 +1105,20 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
11051105
return nil, fs.ErrorCantMove
11061106
}
11071107

1108+
// Find existing object
1109+
srcLeaf, srcDirectoryID, err := srcObj.fs.dirCache.FindPath(ctx, srcObj.remote, false)
1110+
if err != nil {
1111+
return nil, err
1112+
}
1113+
11081114
// Create temporary object
11091115
dstObj, dstLeaf, dstDirectoryID, err := f.createObject(ctx, remote, srcObj.modTime, srcObj.size)
11101116
if err != nil {
11111117
return nil, err
11121118
}
11131119

11141120
// Do the move
1115-
info, err := f.moveTo(ctx, srcObj.id, path.Base(srcObj.remote), dstLeaf, srcObj.dirID, dstDirectoryID)
1121+
info, err := f.moveTo(ctx, srcObj.id, srcLeaf, dstLeaf, srcDirectoryID, dstDirectoryID)
11161122
if err != nil {
11171123
return nil, err
11181124
}

0 commit comments

Comments
 (0)