增加状态描述文件下载状态

publicsignpoll
youngS 3 years ago
parent ac8614b54c
commit 75d5a5df76
  1. 17
      fir_ser/api/migrations/0011_appudid_is_download.py
  2. 1
      fir_ser/api/models.py
  3. 34
      fir_ser/api/utils/app/supersignutils.py
  4. 5
      fir_ser/api/views/download.py

@ -0,0 +1,17 @@
# Generated by Django 3.2.3 on 2021-09-28 15:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0010_alter_userdomaininfo_domain_type'),
]
operations = [
migrations.AddField(
model_name='appudid',
name='is_download',
field=models.BooleanField(default=False, verbose_name='描述文件是否已经下载'),
),
]

@ -245,6 +245,7 @@ class AppUDID(models.Model):
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
is_signed = models.BooleanField(verbose_name="是否完成签名打包", default=False)
is_download = models.BooleanField(verbose_name="描述文件是否已经下载", default=False)
binary_file = models.CharField(max_length=128, blank=True, verbose_name="签名包名称", null=True)
class Meta:

@ -81,7 +81,7 @@ def udid_bytes_to_dict(xml_stream):
return new_uuid_info
def make_sign_udid_mobile_config(udid_url, app_id, bundle_id, app_name):
def make_sign_udid_mobile_config(udid_url, short, bundle_id, app_name):
if MOBILE_CONFIG_SIGN_SSL.get("open"):
ssl_key_path = MOBILE_CONFIG_SIGN_SSL.get("ssl_key_path", None)
ssl_pem_path = MOBILE_CONFIG_SIGN_SSL.get("ssl_pem_path", None)
@ -91,7 +91,7 @@ def make_sign_udid_mobile_config(udid_url, app_id, bundle_id, app_name):
if not os.path.exists(mobile_config_tmp_dir):
os.makedirs(mobile_config_tmp_dir)
sign_mobile_config_path = os.path.join(mobile_config_tmp_dir, 'sign_' + app_id)
sign_mobile_config_path = os.path.join(mobile_config_tmp_dir, 'sign_' + short)
logger.info(f"make sing mobile config {sign_mobile_config_path}")
if os.path.isfile(sign_mobile_config_path):
return open(sign_mobile_config_path, 'rb')
@ -430,6 +430,8 @@ class IosUtils(object):
def update_developer_used_data(self):
udid_obj = AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).first()
udid_obj.is_download = True
udid_obj.save(update_fields=['is_download'])
APPSuperSignUsedInfo.objects.update_or_create(app_id=self.app_obj,
user_id=self.user_obj,
developerid=self.developer_obj,
@ -465,7 +467,9 @@ class IosUtils(object):
else:
obj.update_sign_data(random_file_name, release_obj)
else:
return status, e_result
d_result['code'] = 1004
d_result['msg'] = '签名失败,请检查包是否正常'
return status, d_result
else:
msg = f"app_id {app_obj} download profile failed. {result} time:{time.time() - start_time}"
d_result['code'] = 1002
@ -503,14 +507,22 @@ class IosUtils(object):
logger.error(d_result)
return False, d_result
app_udid_obj = AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).first()
if app_udid_obj and app_udid_obj.is_signed:
release_obj = AppReleaseInfo.objects.filter(app_id=self.app_obj, is_master=True).first()
for apptodev_obj in APPToDeveloper.objects.filter(app_id=self.app_obj).all():
if release_obj.release_id == apptodev_obj.release_file:
msg = "udid %s exists app_id %s" % (self.udid_info.get('udid'), self.app_obj)
d_result['msg'] = msg
logger.info(d_result)
return True, d_result
if app_udid_obj and app_udid_obj.is_download:
if app_udid_obj.is_signed:
release_obj = AppReleaseInfo.objects.filter(app_id=self.app_obj, is_master=True).first()
for apptodev_obj in APPToDeveloper.objects.filter(app_id=self.app_obj).all():
if release_obj.release_id == apptodev_obj.release_file:
msg = "udid %s exists app_id %s" % (self.udid_info.get('udid'), self.app_obj)
d_result['msg'] = msg
logger.info(d_result)
return True, d_result
else:
with cache.lock("%s_%s_%s" % ('run_sign', self.app_obj.app_id, self.developer_obj.issuer_id),
timeout=60 * 10):
logger.info("start run_sign ...")
return IosUtils.run_sign(self.user_obj, self.app_obj, self.developer_obj, 1, self, time.time(),
None)
logger.info("udid %s not exists app_id %s ,need sign" % (self.udid_info.get('udid'), self.app_obj))
if consume_user_download_times_by_app_obj(self.app_obj):

@ -83,9 +83,10 @@ class DownloadView(APIView):
elif f_type == 'mobileconifg':
release_obj = AppReleaseInfo.objects.filter(release_id=filename.split('.')[0]).first()
if release_obj:
udid_url = get_post_udid_url(request, release_obj.app_id.short)
app_obj = release_obj.app_id
ios_udid_mobile_config = make_sign_udid_mobile_config(udid_url, app_obj.app_id, app_obj.bundle_id,
udid_url = get_post_udid_url(request, app_obj.short)
ios_udid_mobile_config = make_sign_udid_mobile_config(udid_url, f'{app_obj.app_id}_{app_obj.short}',
app_obj.bundle_id,
app_obj.name)
return file_response(ios_udid_mobile_config, make_random_uuid() + '.mobileconfig',
"application/x-apple-aspen-config")

Loading…
Cancel
Save