diff --git a/CHANGES.md b/CHANGES.md index 860815c..e791b46 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,8 @@ - [新增]文档页面支持OGP协议; - [修复]开启「全站登录」后URL跳转异常的问题; - [优化]用户禁止同名文集创建,文集下禁止同名文档创建; +- [优化]文集导出异常提示; + ### v0.6.7 2021-05-29 - [新增]表格文档支持Excel文件(.xlsx格式)导入; diff --git a/app_doc/views.py b/app_doc/views.py index 2bf89d3..dd27c2c 100644 --- a/app_doc/views.py +++ b/app_doc/views.py @@ -2031,9 +2031,11 @@ def report_md(request): md_file_filename = os.path.split(md_file_path)[-1] # 提取文件名 md_file = "/media/reportmd_temp/"+ md_file_filename # 拼接相对链接 return JsonResponse({'status':True,'data':md_file}) + except ObjectDoesNotExist as e: + return JsonResponse({'status': False, 'data': _('文集不存在')}) except Exception as e: logger.exception(_("导出文集MD文件出错")) - return JsonResponse({'status':False,'data':_('文集不存在')}) + return JsonResponse({'status': False, 'data': _('导出文集异常')}) elif types == 'multi': project_list = pro_id.split(',') for project in project_list: @@ -2045,7 +2047,11 @@ def report_md(request): project_id_list = project_list, username = request.user.username ) - md_file_path = project_md.work() # 生成并获取MD文件压缩包绝对路径 + try: + md_file_path = project_md.work() # 生成并获取MD文件压缩包绝对路径 + except: + logger.exception("文集导出异常") + return JsonResponse({'status': False, 'data': _('文集导出异常')}) md_file_filename = os.path.split(md_file_path)[-1] # 提取文件名 md_file = "/media/reportmd_temp/" + md_file_filename # 拼接相对链接 return JsonResponse({'status': True, 'data': md_file})