增加数据文件保存配置选项

This commit is contained in:
2026-07-07 17:04:19 +08:00
parent 1c6b72e55f
commit cf77afdce0
+9 -7
View File
@@ -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]:
"""获取服务状态