优化代码

dependabot/npm_and_yarn/fir_admin/url-parse-1.5.10
nineven 3 years ago
parent 9f2fea094d
commit 192d4cadc0
  1. 7
      fir_ser/api/utils/app/supersignutils.py
  2. 10
      fir_ser/api/utils/utils.py

@ -41,7 +41,7 @@ def check_org_file(user_obj, org_file):
os.makedirs(os.path.dirname(org_file)) os.makedirs(os.path.dirname(org_file))
if os.path.isfile(org_file): if os.path.isfile(org_file):
return return True
storage_obj = Storage(user_obj) storage_obj = Storage(user_obj)
return download_files_form_oss(storage_obj, org_file) return download_files_form_oss(storage_obj, org_file)
@ -474,7 +474,10 @@ class IosUtils(object):
def exec_sign(user_obj, app_obj, developer_obj, random_file_name, release_obj): def exec_sign(user_obj, app_obj, developer_obj, random_file_name, release_obj):
resign_app_obj = IosUtils.get_resign_obj(user_obj, developer_obj) resign_app_obj = IosUtils.get_resign_obj(user_obj, developer_obj)
org_file = os.path.join(MEDIA_ROOT, release_obj.release_id + ".ipa") org_file = os.path.join(MEDIA_ROOT, release_obj.release_id + ".ipa")
check_org_file(user_obj, org_file) if not check_org_file(user_obj, org_file):
msg = f"{user_obj} {developer_obj} {app_obj} sign_ipa failed ERROR:'签名包检测失败,或许文件下载失败'"
logger.error(msg)
return False, msg
new_file = os.path.join(MEDIA_ROOT, random_file_name + ".ipa") new_file = os.path.join(MEDIA_ROOT, random_file_name + ".ipa")
properties_info = {} properties_info = {}
if app_obj.new_bundle_id: if app_obj.new_bundle_id:

@ -204,10 +204,10 @@ def change_storage_and_change_advert_img(user_obj, new_storage_obj, clean_old_da
migrating_storage_file_data(user_obj, user_advert_obj.ad_pic, new_storage_obj, clean_old_data) migrating_storage_file_data(user_obj, user_advert_obj.ad_pic, new_storage_obj, clean_old_data)
def download_files_form_oss(storage_obj, org_file): def download_files_form_oss(storage_obj, org_file, force=False):
with cache.lock("%s_%s" % ('download_files_form_oss', org_file), timeout=60 * 30): with cache.lock("%s_%s" % ('download_files_form_oss', org_file), timeout=60 * 30):
if os.path.isfile(org_file): if os.path.isfile(org_file) and not force:
return return True
if storage_obj.download_file(os.path.basename(org_file), org_file + ".check.tmp"): 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"): if os.path.isfile(org_file) and os.path.exists(org_file + ".check.tmp"):
os.remove(org_file) os.remove(org_file)
@ -252,12 +252,12 @@ def migrating_storage_file_data(user_obj, filename, new_storage_obj, clean_old_d
else: else:
if new_storage_obj.get_storage_type() == 3: if new_storage_obj.get_storage_type() == 3:
# 云存储下载 本地,并删除云存储 # 云存储下载 本地,并删除云存储
if download_files_form_oss(old_storage_obj, local_file_full_path): if download_files_form_oss(old_storage_obj, local_file_full_path, True):
if clean_old_data: if clean_old_data:
old_storage_obj.delete_file(filename) old_storage_obj.delete_file(filename)
else: else:
# 云存储互传,先下载本地,然后上传新云存储,删除本地和老云存储 # 云存储互传,先下载本地,然后上传新云存储,删除本地和老云存储
if download_files_form_oss(old_storage_obj, local_file_full_path): if download_files_form_oss(old_storage_obj, local_file_full_path, True):
new_storage_obj.upload_file(local_file_full_path) new_storage_obj.upload_file(local_file_full_path)
delete_local_files(filename) delete_local_files(filename)
if clean_old_data: if clean_old_data:

Loading…
Cancel
Save