提交 c91dc202 authored 作者: blu's avatar blu

bugfix: check 0 sized file

上级 c2075f4a
...@@ -738,21 +738,27 @@ private: ...@@ -738,21 +738,27 @@ private:
string delReleaseBundle(string bid) { string delReleaseBundle(string bid) {
string ret; string ret;
int stackId = -1; int stackId = -1;
bool handled = false;
bool isNumber = true;
if(bid.empty()) { if(bid.empty()) {
ret = "empty release bundle id"; ret = "empty release bundle id";
}else{ }else{
try{ try{
stackId = stoi(bid); stackId = stoi(bid);
}catch(exception &e) { }catch(exception &e) {
stackId = -1; isNumber = false;
} }
if(this->releaseBundle.size() != 0 && this->releaseBundle.count("bundles") != 0) { if(this->releaseBundle.size() != 0 && this->releaseBundle.count("bundles") != 0) {
auto &bunds = this->releaseBundle["bundles"]; auto &bunds = this->releaseBundle["bundles"];
bool handled = false; if(isNumber) {
int idx = bunds.size() - 1 - stackId; int idx = bunds.size() - 1 - stackId;
if(idx < 0) {
ret = "no such release config";
return ret;
}
spdlog::info("idx: {}", idx); spdlog::info("idx: {}", idx);
if(stackId >=0 && idx>= 0) {
if(idx == this->releaseBundle["activeIdx"].get<int>()){ if(idx == this->releaseBundle["activeIdx"].get<int>()){
ret = "can't delete active release bundle"; ret = "can't delete active release bundle";
}else{ }else{
...@@ -763,28 +769,15 @@ private: ...@@ -763,28 +769,15 @@ private:
handled = true; handled = true;
} }
} }
else if(stackId >=0 && bunds.size() - 1 - stackId < 0)
{
ret = "release bundle not exist";
}
else{ else{
// releaseId style // releaseId style
int idx = 0; int idx = 0;
for(auto r: bunds) { for(auto r: bunds) {
if(r["releaseId"] == bid) { if(r["releaseId"] == bid) {
bunds.erase(idx); return delReleaseBundle(to_string(idx));
handled = true;
break;
} }
idx++; idx++;
} }
if(handled) {
if(idx < this->releaseBundle["activeIdx"]) {
this->releaseBundle["activeIdx"] = this->releaseBundle["activeIdx"].get<int>() -1;
}
}else{
ret = "release bundle not exist";
}
} }
if(handled) { if(handled) {
// save // save
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论