Skip to content

Commit

Permalink
Reset oldParent modifications on rename conflict too
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalif committed Nov 22, 2022
1 parent 50a811d commit dafe410
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,8 @@ func (inode *Inode) SendUpload() bool {
s3Log.Warnf("Conflict detected: failed to copy %v to %v: %v. File is removed remotely, dropping cache", from, key, err)
inode.mu.Lock()
newParent := inode.Parent
oldParent := inode.oldParent
oldName := inode.oldName
inode.oldParent = nil
inode.oldName = ""
inode.renamingTo = false
Expand All @@ -1301,6 +1303,12 @@ func (inode *Inode) SendUpload() bool {
newParent.mu.Lock()
newParent.removeChildUnlocked(inode)
newParent.mu.Unlock()
if oldParent != nil {
oldParent.mu.Lock()
delete(oldParent.dir.DeletedChildren, oldName)
oldParent.addModified(-1)
oldParent.mu.Unlock()
}
} else {
log.Debugf("Failed to copy %v to %v (rename): %v", from, key, err)
inode.mu.Lock()
Expand Down

0 comments on commit dafe410

Please sign in to comment.