From 32bdc4ba9e87620fab1f26ed0ea2e4d292a6aded Mon Sep 17 00:00:00 2001 From: nineven Date: Fri, 28 Jan 2022 06:11:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/utils/utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fir_ser/api/utils/utils.py b/fir_ser/api/utils/utils.py index bb90418..f205f74 100644 --- a/fir_ser/api/utils/utils.py +++ b/fir_ser/api/utils/utils.py @@ -205,13 +205,14 @@ def change_storage_and_change_advert_img(user_obj, new_storage_obj, clean_old_da def download_files_form_oss(storage_obj, org_file): - if storage_obj.download_file(os.path.basename(org_file), org_file + ".check.tmp"): - if os.path.isfile(org_file) and os.path.exists(org_file + ".check.tmp"): - os.remove(org_file) - if os.path.exists(org_file + ".check.tmp"): - os.rename(os.path.join(org_file + ".check.tmp"), org_file) - return True - return False + with cache.lock("%s_%s" % ('download_files_form_oss', org_file), timeout=60 * 30): + if storage_obj.download_file(os.path.basename(org_file), org_file + ".check.tmp"): + if os.path.isfile(org_file) and os.path.exists(org_file + ".check.tmp"): + os.remove(org_file) + if os.path.exists(org_file + ".check.tmp"): + os.rename(os.path.join(org_file + ".check.tmp"), org_file) + return True + return False def check_storage_is_new_storage(user_obj, new_storage_obj):