deleteRecordDirectory接口忽略正在录制的mp4文件 (#3032)

This commit is contained in:
xiongziliang 2023-12-02 15:22:16 +08:00
parent 10663fd3b4
commit e1f199c986

View File

@ -1536,13 +1536,29 @@ void installWebApi() {
if (!name.empty()) { if (!name.empty()) {
record_path += name; record_path += name;
} }
int result = File::delete_file(record_path.data()); bool recording = false;
if (result) { {
// 不等于0时代表失败 auto src = MediaSource::find(allArgs["vhost"], allArgs["app"], allArgs["stream"]);
record_path = "delete error"; if (src && src->isRecording(Recorder::type_mp4)) {
recording = true;
}
} }
val["path"] = record_path; val["path"] = record_path;
val["code"] = result; if (!recording) {
val["code"] = File::delete_file(record_path.data());
return;
}
File::scanDir(record_path, [](const string &path, bool is_dir) {
if (is_dir) {
return true;
}
if (path.find("./") != std::string::npos) {
File::delete_file(path.data());
} else {
TraceL << "Ignore tmp mp4 file: " << path;
}
return true;
}, true);
}); });
//获取录像文件夹列表或mp4文件列表 //获取录像文件夹列表或mp4文件列表