diff --git a/wrolpi/files/lib.py b/wrolpi/files/lib.py index 9ae2163a..f9e96482 100644 --- a/wrolpi/files/lib.py +++ b/wrolpi/files/lib.py @@ -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) diff --git a/wrolpi/files/models.py b/wrolpi/files/models.py index f2b4547a..cfadd2e7 100644 --- a/wrolpi/files/models.py +++ b/wrolpi/files/models.py @@ -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.