mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:32:29 +08:00
vfs: fix rename of directory containing files to be uploaded
Before this change, if you renamed a directory containg files yet to be uploaded then deleted the directory the files would still be uploaded. This fixes the problem by changing the directory path in all the file objects in a directory when it is renamed. This wasn't necessary until we introduced virtual files and directories which lived beyond the directory flush mechanism. Fixes #6809
This commit is contained in:
parent
17854663de
commit
28a8ebce5b
11
vfs/dir.go
11
vfs/dir.go
|
@ -325,10 +325,15 @@ func (d *Dir) renameTree(dirPath string) {
|
|||
d.entry = fs.NewDirCopy(context.TODO(), d.entry).SetRemote(dirPath)
|
||||
}
|
||||
|
||||
// Do the same to any child directories
|
||||
// Do the same to any child directories and files
|
||||
for leaf, node := range d.items {
|
||||
if dir, ok := node.(*Dir); ok {
|
||||
dir.renameTree(path.Join(dirPath, leaf))
|
||||
switch x := node.(type) {
|
||||
case *Dir:
|
||||
x.renameTree(path.Join(dirPath, leaf))
|
||||
case *File:
|
||||
x.renameDir(dirPath)
|
||||
default:
|
||||
panic("bad dir entry")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,13 @@ func (f *File) Node() Node {
|
|||
return f
|
||||
}
|
||||
|
||||
// renameDir - call when parent directory has been renamed
|
||||
func (f *File) renameDir(dPath string) {
|
||||
f.mu.RLock()
|
||||
f.dPath = dPath
|
||||
f.mu.RUnlock()
|
||||
}
|
||||
|
||||
// applyPendingRename runs a previously set rename operation if there are no
|
||||
// more remaining writers. Call without lock held.
|
||||
func (f *File) applyPendingRename() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user