file_manager: metadata move fix

If the destination exits in the metadata database it is necessary
to either overwrite it with the source metadata or delete it
so that the new metadata can be rescanned.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-12-08 15:25:29 -05:00
parent 18b84b8d9f
commit f5f87bf08c
1 changed files with 4 additions and 0 deletions

View File

@ -1523,6 +1523,10 @@ class MetadataStorage:
metadata: Optional[Dict[str, Any]]
metadata = self.mddb.pop(prev_fname, None)
if metadata is None:
# If this move overwrites an existing file it is necessary
# to rescan which requires that we remove any existing
# metadata.
self.mddb.pop(new_fname, None)
return False
self.mddb[new_fname] = metadata
prev_dir = os.path.dirname(os.path.join(self.gc_path, prev_fname))