|
@@ -69,11 +69,14 @@ JsonCommander::Response JsonCommander::executeList(const Json::Value &message) {
|
|
|
response.action = send;
|
|
|
response.json["command"] = "list";
|
|
|
|
|
|
- if(fileManager.isUploading()) {
|
|
|
+ if(fileManager.getRemainingListChunks()!=0) {
|
|
|
response.json["accept"] = false;
|
|
|
- response.json["error"] = "there is an upload already running";
|
|
|
+ response.json["error"] = "there is already an open list command";
|
|
|
+ } else if (fileManager.openList() == -1){
|
|
|
+ response.json["accept"] = false;
|
|
|
+ response.json["error"] = "there is a filename which is to long";
|
|
|
} else {
|
|
|
- response.json["chunks"] = fileManager.openList();
|
|
|
+ response.json["chunks"] = fileManager.getRemainingListChunks();
|
|
|
response.json["items"] = fileManager.getListSize();
|
|
|
response.json["error"] = "";
|
|
|
}
|
|
@@ -87,14 +90,17 @@ JsonCommander::Response JsonCommander::executeListData(const Json::Value &messag
|
|
|
response.json["command"] = "listdata";
|
|
|
Json::Value array;
|
|
|
|
|
|
- if(fileManager.getListSize()==0) {
|
|
|
+ if(fileManager.getRemainingListChunks()==0) {
|
|
|
+ response.json["accept"] = false;
|
|
|
+ response.json["error"] = "there are no chunks to send";
|
|
|
+ } else if(fileManager.getRemainingListChunks()-1!=message["chunk"].asInt()) {
|
|
|
response.json["accept"] = false;
|
|
|
- response.json["error"] = "nothing to upload";
|
|
|
+ response.json["error"] = "wrong chunk number";
|
|
|
} else {
|
|
|
std::vector<std::string> v = fileManager.getNextChunkFromList();
|
|
|
for(int i=0; i<v.size(); i++)
|
|
|
array.append(v.at(i));
|
|
|
- response.json["remaining"] = message["chunk"].asInt()-1;
|
|
|
+ response.json["remaining"] = fileManager.getRemainingListChunks();
|
|
|
response.json["cancel"] = false;
|
|
|
response.json["names"] = array;
|
|
|
response.json["error"] = "";
|