From 3e9b3530844cd1732e53d5476f587566aa8f13ce Mon Sep 17 00:00:00 2001 From: ffont Date: Thu, 16 Nov 2023 12:51:46 +0100 Subject: [PATCH] Ingore errors removing "process before description" files --- utils/filesystem.py | 4 ++-- utils/sound_upload.py | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/utils/filesystem.py b/utils/filesystem.py index e7e695d15..bddf2a7c3 100644 --- a/utils/filesystem.py +++ b/utils/filesystem.py @@ -86,8 +86,8 @@ def crc32file(filename): return hex(crc32)[2:] -def remove_directory(path): - shutil.rmtree(path) +def remove_directory(path, ignore_errors=False): + shutil.rmtree(path, ignore_errors=ignore_errors) def remove_directory_if_empty(path): diff --git a/utils/sound_upload.py b/utils/sound_upload.py index 06da120ca..9c75b9852 100644 --- a/utils/sound_upload.py +++ b/utils/sound_upload.py @@ -72,7 +72,14 @@ def _remove_user_uploads_folder_if_empty(user): def clean_processing_before_describe_files(audio_file_path): directory_path = get_processing_before_describe_sound_folder(audio_file_path) if os.path.exists(directory_path): - remove_directory(directory_path) + # Note we use ignore_errors=True below because we've found issues with remove_directory similar + # to those described here https://github.com/ansible/ansible/issues/34335 (sort of race confitions) + # We suspect these errors can happen if the user describes the sound before it has finished "processing + # before description" (maybe the case of long sounds?). In that case the directory will be removed while + # new sounds are being added to it. If this happens, the error will be ignored and the folder will not be + # removed at this time. Nevertheless an async job that cleans old unnecessary folders form the data volume + # will eventually identify this folder and remove it later. + remove_directory(directory_path, ignore_errors=True) def get_duration_from_processing_before_describe_files(audio_file_path):