修复新应用短连接重复异常上传问题

publicsignpoll
youngS 3 years ago
parent b772d2921e
commit e7d4df5941
  1. 32
      fir_client/src/components/apps/FirApps.vue
  2. 9
      fir_ser/api/utils/app/apputils.py
  3. 5
      fir_ser/api/views/apps.py
  4. 4
      fir_ser/api/views/uploads.py

@ -627,6 +627,18 @@
PaymentQuestionMsg: '', PaymentQuestionMsg: '',
} }
}, methods: { }, methods: {
check_short(short, callback) {
apputils(data => {
if (data.code === 1000 && data.data === 0) {
callback()
} else {
this.$message.error("短连接已经存在")
}
}, {
"methods": "POST",
"app_id": short
})
},
multirun(process, keylist, func) { multirun(process, keylist, func) {
let thr = []; let thr = [];
for (let i = 0; i < process; i++) { for (let i = 0; i < process; i++) {
@ -775,6 +787,14 @@
} else { } else {
this.$message.success(analyseappinfo.appname + ' 入库成功'); this.$message.success(analyseappinfo.appname + ' 入库成功');
} }
} else {
if (!multiFlag) {
this.$message.error(analyseappinfo.appname + ' 入库失败 ' + data.msg);
loading.close();
this.closeUpload();
this.currentfile = undefined;
return
}
} }
loading.close(); loading.close();
const start = this.multiFileList.indexOf(file); const start = this.multiFileList.indexOf(file);
@ -857,7 +877,7 @@
}) })
} }
}, },
uploadcloud(analyseappinfo, binary_file, multiFlag, resolve) { uploadcloudFun(analyseappinfo, binary_file, multiFlag, resolve) {
if (analyseappinfo.binary_url !== '') { if (analyseappinfo.binary_url !== '') {
this.$confirm(`该应用 ${analyseappinfo.appname} 存在第三方下载链接 <a target="_blank" href="${analyseappinfo.binary_url}"> ${analyseappinfo.binary_url} </a>更新之后,将不会自动跳转第三方下载;若您还需要第三方跳转,请在第三方平台更新该应用。`, '确定更新应用?', { this.$confirm(`该应用 ${analyseappinfo.appname} 存在第三方下载链接 <a target="_blank" href="${analyseappinfo.binary_url}"> ${analyseappinfo.binary_url} </a>更新之后,将不会自动跳转第三方下载;若您还需要第三方跳转,请在第三方平台更新该应用。`, '确定更新应用?', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -889,6 +909,16 @@
this.uploadstorage(analyseappinfo, binary_file, multiFlag, resolve) this.uploadstorage(analyseappinfo, binary_file, multiFlag, resolve)
} }
}, },
uploadcloud(analyseappinfo, binary_file, multiFlag, resolve) {
if (analyseappinfo.is_new && !multiFlag) {
// eslint-disable-next-line no-unused-vars
this.check_short(this.short, res => {
this.uploadcloudFun(analyseappinfo, binary_file, multiFlag, resolve)
});
} else {
this.uploadcloudFun(analyseappinfo, binary_file, multiFlag, resolve)
}
},
uploadstorage(analyseappinfo, binary_file, multiFlag, resolve) { uploadstorage(analyseappinfo, binary_file, multiFlag, resolve) {
if (!multiFlag) { if (!multiFlag) {
this.uploadflag = true; this.uploadflag = true;

@ -102,13 +102,14 @@ def get_app_type(app_file_name):
return 2 return 2
def get_random_short(): def get_random_short(number=4):
short_url = ''.join(random.sample( short_url = ''.join(random.sample(
['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f',
'e', 'd', 'c', 'b', 'a'], 4)) 'e', 'd', 'c', 'b', 'a'], number))
app_obj = Apps.objects.filter(short=short_url).first() app_obj = Apps.objects.filter(short=short_url).first()
if app_obj: if app_obj:
return get_random_short() number += 2
return get_random_short(number)
else: else:
return short_url return short_url
@ -133,6 +134,8 @@ def save_app_infos(app_file_name, user_obj, app_info, bundle_id, app_img, short,
"wxeasytype": False if get_user_domain_name(user_obj) else True "wxeasytype": False if get_user_domain_name(user_obj) else True
} }
try: try:
if Apps.objects.filter(short=short).count() == 1:
appdata['short'] = get_random_short()
app_obj = Apps.objects.create(**appdata) app_obj = Apps.objects.create(**appdata)
except Exception as e: except Exception as e:
logger.error(f"create new app failed,appdata:{appdata} Exception:{e}") logger.error(f"create new app failed,appdata:{appdata} Exception:{e}")

@ -251,6 +251,11 @@ class AppInfoView(APIView):
return Response(res.dict) return Response(res.dict)
def post(self, request, app_id):
res = BaseResponse()
res.data = Apps.objects.filter(short=app_id).count()
return Response(res.dict)
class AppReleaseInfoView(APIView): class AppReleaseInfoView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ] authentication_classes = [ExpiringTokenAuthentication, ]

@ -127,6 +127,8 @@ class AppAnalyseView(APIView):
else: else:
storage.delete_file(app_tmp_filename) storage.delete_file(app_tmp_filename)
storage.delete_file(png_tmp_filename) storage.delete_file(png_tmp_filename)
res.code = 10003
res.msg = '应用信息保存失败'
# 删除redis key # 删除redis key
upload_file_tmp_name("del", app_tmp_filename, request.user.id) upload_file_tmp_name("del", app_tmp_filename, request.user.id)
upload_file_tmp_name("del", png_tmp_filename, request.user.id) upload_file_tmp_name("del", png_tmp_filename, request.user.id)
@ -134,7 +136,7 @@ class AppAnalyseView(APIView):
except Exception as e: except Exception as e:
logger.error(f"user {request.user} save app {data.get('bundleid')} info {app_info} failed Exception:{e}") logger.error(f"user {request.user} save app {data.get('bundleid')} info {app_info} failed Exception:{e}")
res.code = 10003 res.code = 10003
res.msg = 'save app info failed' res.msg = '应用信息保存失败'
return Response(res.dict) return Response(res.dict)

Loading…
Cancel
Save