mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Updating FileGroup.title when renaming file.
This commit is contained in:
parent
27d55a1339
commit
c71f6c8237
2 changed files with 2 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue