修正deleteRecordDirectory接口拼写错误并精简代码

This commit is contained in:
ziyue 2022-08-05 16:01:31 +08:00
parent 024c3e1a28
commit 7458a67c66
2 changed files with 7 additions and 9 deletions

View File

@ -946,19 +946,19 @@
"response": [] "response": []
}, },
{ {
"name": "删除录像文件夹(deleteRecordDirectroy)", "name": "删除录像文件夹(deleteRecordDirectory)",
"request": { "request": {
"method": "GET", "method": "GET",
"header": [], "header": [],
"url": { "url": {
"raw": "{{ZLMediaKit_URL}}/index/api/deleteRecordDirectroy?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=proxy&stream=2&period=2020-01-01", "raw": "{{ZLMediaKit_URL}}/index/api/deleteRecordDirectory?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=proxy&stream=2&period=2020-01-01",
"host": [ "host": [
"{{ZLMediaKit_URL}}" "{{ZLMediaKit_URL}}"
], ],
"path": [ "path": [
"index", "index",
"api", "api",
"deleteRecordDirectroy" "deleteRecordDirectory"
], ],
"query": [ "query": [
{ {

View File

@ -1335,20 +1335,18 @@ void installWebApi() {
// 删除录像文件夹 // 删除录像文件夹
// http://127.0.0.1/index/api/deleteRecordDirectroy?vhost=__defaultVhost__&app=live&stream=ss&period=2020-01-01 // http://127.0.0.1/index/api/deleteRecordDirectroy?vhost=__defaultVhost__&app=live&stream=ss&period=2020-01-01
api_regist("/index/api/deleteRecordDirectroy", [](API_ARGS_MAP) { api_regist("/index/api/deleteRecordDirectory", [](API_ARGS_MAP) {
CHECK_SECRET(); CHECK_SECRET();
CHECK_ARGS("vhost", "app", "stream"); CHECK_ARGS("vhost", "app", "stream");
auto record_path = Recorder::getRecordPath(Recorder::type_mp4, allArgs["vhost"], allArgs["app"], allArgs["stream"], allArgs["customized_path"]); auto record_path = Recorder::getRecordPath(Recorder::type_mp4, allArgs["vhost"], allArgs["app"], allArgs["stream"], allArgs["customized_path"]);
auto period = allArgs["period"]; auto period = allArgs["period"];
record_path = record_path + period + "/"; record_path = record_path + period + "/";
int result = File::delete_file(record_path.data()); int result = File::delete_file(record_path.data());
if (result != 0) { if (result) {
// 不等于0时代表失败
record_path = "delete error"; record_path = "delete error";
val["path"] = record_path;
} else {
val["path"] = record_path.data();
} }
val["path"] = record_path;
val["code"] = result; val["code"] = result;
}); });