From c71f6c823783e0998f6316dc4cf276a80cd83134 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 12 Jun 2024 16:41:47 -0600 Subject: [PATCH] Updating FileGroup.title when renaming file. --- wrolpi/files/lib.py | 2 +- wrolpi/files/models.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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.