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]: """获取服务状态