From cf77afdce0d2efb4ba529908b7f08eccf84a298e Mon Sep 17 00:00:00 2001 From: leon Date: Tue, 7 Jul 2026 17:04:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BF=9D=E5=AD=98=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compute_service.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/compute_service.py b/compute_service.py index 67eb75e..709c802 100644 --- a/compute_service.py +++ b/compute_service.py @@ -192,7 +192,7 @@ class ComputeService: # 保存MAT文件 savemat(mat_path, mat_data, appendmat=False) logger.info(f"Converted CSV to MAT: {csv_path} -> {mat_path}") - + return mat_path except Exception as e: @@ -491,12 +491,6 @@ class ComputeService: if not out_path or not result: return json.dumps({'error': 'Compute failed'}) - # 删除输出文件 - try: - os.remove(out_path) - except: - pass - # 转换为JSON result_json = json.dumps(result, cls=CustomFloatEncoder) @@ -512,6 +506,14 @@ class ComputeService: except Exception as e: logger.error(f"Failed to compute file: {e}") return json.dumps({'error': str(e)}) + finally: + if not config_manager.get('data_file_save', True): + if csv_path and os.path.exists(csv_path): + os.remove(csv_path) + if mat_path and os.path.exists(mat_path): + os.remove(mat_path) + if out_path and os.path.exists(out_path): + os.remove(out_path) def get_status(self) -> Dict[str, Any]: """获取服务状态