Skip to content
Snippets Groups Projects
Commit 4ec90da2 authored by Simon Künzel's avatar Simon Künzel
Browse files

Fix Sorter sorting unknown file formats

parent e244a192
No related branches found
No related tags found
No related merge requests found
......@@ -15,11 +15,10 @@ from videoag_common.objects.medium import SorterFileStatus
logger = logging.getLogger(__name__)
# TODO more?
# List of formats which can be automatically sorted because we can detect weather they are fully uploaded
_AUTOMATIC_SORT_FILE_FORMATS = [
"mp4", "mp3",
"png", "jpg", "jpeg",
"mp4", "webm", "webp", "m4a", "m4v", "mka", "mkv", "mts",
"mp3", "ogg", "wav",
"png", "jpg", "jpeg", "gif",
]
_MIN_SECONDS_NO_MODIFICATION = videoag_common.config["SORTER_MIN_SECONDS_NO_MODIFICATION"]
_SORTER_DIR_NAME = videoag_common.config["SORTER_DIR"]
......@@ -58,7 +57,9 @@ def _check_file(
if db_path in files_in_sorter_dir:
file = files_in_sorter_dir[db_path]
if status == SorterFileStatus.SORTING_UPCOMING and file.status == SorterFileStatus.ERROR:
if (status == SorterFileStatus.SORTING_UPCOMING
and file.status == SorterFileStatus.ERROR
and file.file_modification_time == file_mod_time):
status = SorterFileStatus.ERROR
error_message = file.sorter_error_message
else:
......@@ -71,15 +72,7 @@ def _check_file(
session.add(file)
logger.info(f"Adding new file {db_path} to database")
sort_now = False
if file.force_immediate_sort:
sort_now = True
if status == SorterFileStatus.SORTING_UPCOMING:
sort_now = True
if file.file_modification_time != file_mod_time:
sort_now = True
if sort_now:
status = SorterFileStatus.SORTING_UPCOMING
logger.info(f"Status for {db_path}: {status} (error: {error_message})")
......@@ -90,7 +83,7 @@ def _check_file(
file.sorter_error_message = error_message
file.update_time = get_standard_datetime_now()
if sort_now:
if status == SorterFileStatus.SORTING_UPCOMING:
logger.info(f"Queuing {db_path} to be sorted")
to_sort_file_db_paths.append(db_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment