mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
fix: 去掉异步执行,添加可配置项
This commit is contained in:
@@ -49,6 +49,10 @@
|
||||
"Doc": "仓库识别导出结果模板",
|
||||
"arkPlanner": "{\"@type\": \"@penguin-statistics/depot\",\"items\": []}",
|
||||
"arkPlanner_Doc": "https://penguin-stats.cn/planner"
|
||||
},
|
||||
"debug": {
|
||||
"cleanFilesFreq": 100,
|
||||
"maxDebugFileNum": 1000
|
||||
}
|
||||
},
|
||||
"intent": {
|
||||
|
||||
@@ -53,6 +53,8 @@ bool asst::GeneralConfig::parse(const json::value& json)
|
||||
}
|
||||
m_options.depot_export_template.ark_planner =
|
||||
options_json.get("depotExportTemplate", "arkPlanner", std::string());
|
||||
m_options.debug.clean_files_freq = options_json.get("debug", "cleanFilesFreq", 100);
|
||||
m_options.debug.max_debug_file_num = options_json.get("debug", "maxDebugFileNum", 1000);
|
||||
}
|
||||
|
||||
for (const auto& [client_type, intent_name] : json.at("intent").as_object()) {
|
||||
|
||||
@@ -23,6 +23,12 @@ namespace asst
|
||||
std::string ark_planner;
|
||||
};
|
||||
|
||||
struct DebugConf
|
||||
{
|
||||
int clean_files_freq = 100;
|
||||
int max_debug_file_num = 1000;
|
||||
};
|
||||
|
||||
struct Options
|
||||
{
|
||||
int task_delay = 0; // 任务间延时:越快操作越快,但会增加CPU消耗
|
||||
@@ -48,6 +54,7 @@ namespace asst
|
||||
// 每次到结算界面,汇报掉落数据至企鹅物流 https://penguin-stats.cn/
|
||||
DepotExportTemplate depot_export_template; // 仓库识别结果导出模板
|
||||
RequestInfo yituliu_report; // 一图流大数据汇报:目前只有公招功能,https://yituliu.site/maarecruitdata
|
||||
DebugConf debug;
|
||||
};
|
||||
|
||||
struct AdbCfg
|
||||
|
||||
@@ -159,16 +159,13 @@ bool asst::AbstractTask::save_img(const std::filesystem::path& relative_dir)
|
||||
}
|
||||
std::string stem = utils::get_time_filestem();
|
||||
|
||||
// 第一次或每执行100次后执行清理
|
||||
// 第1次或每执行 debug.clean_files_freq(100) 次后执行清理
|
||||
// 限制文件数量 debug.max_debug_file_num
|
||||
if (m_save_file_cnt[relative_dir] == 0) {
|
||||
std::thread t([=]() {
|
||||
filenum_ctrl(relative_dir, 1000);
|
||||
});
|
||||
t.detach();
|
||||
|
||||
filenum_ctrl(relative_dir, Config.get_options().debug.max_debug_file_num);
|
||||
m_save_file_cnt[relative_dir] = 0;
|
||||
}
|
||||
m_save_file_cnt[relative_dir] = (m_save_file_cnt[relative_dir] + 1) % 100;
|
||||
m_save_file_cnt[relative_dir] = (m_save_file_cnt[relative_dir] + 1) % Config.get_options().debug.clean_files_freq;
|
||||
|
||||
auto relative_path = relative_dir / (stem + "_raw.png");
|
||||
Log.trace("Save image", relative_path);
|
||||
@@ -211,11 +208,10 @@ size_t asst::AbstractTask::filenum_ctrl(const std::filesystem::path& relative_di
|
||||
|
||||
for (int i = 0; i < to_del; ++i) {
|
||||
auto path = filepaths[i].second;
|
||||
std::cout << filepaths[i].first.time_since_epoch().count() << path << std::endl;
|
||||
if (std::filesystem::remove(path)) {
|
||||
deleted++;
|
||||
}
|
||||
}
|
||||
|
||||
LogTrace << "Finish folder cleanup delete " << deleted << " files from " << absolute_path;
|
||||
return deleted;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user