diff --git a/job_controller/jobs/source_file_sorter/job.py b/job_controller/jobs/source_file_sorter/job.py index a532c7d98c1230fa6ff65d4da1ee9aa13555ce78..12b285914fb20a7fa33d00b441c0e35f23065aa9 100644 --- a/job_controller/jobs/source_file_sorter/job.py +++ b/job_controller/jobs/source_file_sorter/job.py @@ -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)