Removing unnecessary flush.

This commit is contained in:
Roland 2022-12-16 09:21:22 -07:00
parent 3d7d5c7858
commit a322d1a0a9
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 5 additions and 4 deletions

View file

@ -382,7 +382,7 @@ def save_channels_config(session=None, preserve_favorites: bool = True):
def import_channels_config():
"""Import channel settings to the DB. Existing channels will be updated."""
if PYTEST and not TEST_CHANNELS_CONFIG:
logger.warning(f'Not importing channels during this test. Use `test_channels_config` fixture if you would'
logger.warning(f'Not importing channels during this test. Use `test_channels_config` fixture if you would '
f'like to call this.')
return

View file

@ -805,8 +805,10 @@ def register_modeler(modeler: callable):
def apply_modelers(files, session: Session):
from wrolpi.files.lib import split_path_stem_and_suffix, get_mimetype
from wrolpi.files.models import File
"""
Group Files by stem, send those groups to the modelers. Each modeler will model what Files are valid.
"""
from wrolpi.files.lib import split_path_stem_and_suffix
if not files:
return

View file

@ -186,7 +186,6 @@ async def _refresh_files_list(paths: List[pathlib.Path], idempotency: datetime.d
if new_paths := (chunk - existing_paths):
new_files = [File(path=i, idempotency=idempotency, mimetype=get_mimetype(i)) for i in new_paths]
session.add_all(new_files)
session.flush(new_files)
# Apply models to all files. Many files will have no model.
all_files = existing_files + new_files
apply_modelers(all_files, session)