Updating FileGroup.title when renaming file.

This commit is contained in:
Roland 2024-06-12 16:41:47 -06:00
parent 27d55a1339
commit c71f6c8237
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 2 additions and 1 deletions

View file

@ -1289,7 +1289,7 @@ async def rename_file(path: pathlib.Path, new_name: str) -> pathlib.Path:
raise FileConflict(f'Cannot rename {path} because {new_path} already exists')
with get_db_session(commit=True) as session:
fg = session.query(FileGroup).filter(FileGroup.primary_path == path).one_or_none()
fg: FileGroup = session.query(FileGroup).filter(FileGroup.primary_path == path).one_or_none()
if not fg:
# File wasn't yet in the DB.
fg = FileGroup.from_paths(session, path)

View file

@ -332,6 +332,7 @@ class FileGroup(ModelHelper, Base):
new_files[idx]['path'] = new_path
self.files = new_files
self.primary_path = new_primary_path
self.title = self.primary_path.name
# Need to re-index for self.data.
self.indexed = False
# Flush the changes to the FileGroup.