|
@@ -66,21 +66,18 @@ JsonCommander::executeClose(const Json::Value &message) {
|
|
|
|
|
|
JsonCommander::Response JsonCommander::executeList(const Json::Value &message) {
|
|
|
JsonCommander::Response response;
|
|
|
- response.action = send;
|
|
|
response.json["command"] = "list";
|
|
|
- response.json["accept"] = true;
|
|
|
-
|
|
|
- int chunks = 0;
|
|
|
|
|
|
- std::vector<std::string> v = fileManager.listFiles();
|
|
|
- for(int i=0; i<v.size(); i++) {
|
|
|
- chunks += fileManager.getChunksFromFile(v.at(i));
|
|
|
+ if(fileManager.isUploading()) {
|
|
|
+ response.action = send;
|
|
|
+ response.json["accept"] = false;
|
|
|
+ response.json["error"] = "there is an upload already running";
|
|
|
+ } else {
|
|
|
+ response.json["chunks"] = fileManager.openList();
|
|
|
+ response.json["items"] = fileManager.getListSize();
|
|
|
+ response.json["error"] = "";
|
|
|
}
|
|
|
|
|
|
- response.json["items"] = (int) v.size();
|
|
|
- response.json["chunks"] = chunks;
|
|
|
- response.json["error"] = "";
|
|
|
-
|
|
|
return response;
|
|
|
}
|
|
|
|
|
@@ -90,16 +87,19 @@ JsonCommander::Response JsonCommander::executeListData(const Json::Value &messag
|
|
|
response.json["command"] = "listdata";
|
|
|
Json::Value array;
|
|
|
|
|
|
- std::vector<std::string> v = fileManager.listFiles();
|
|
|
- for(int i=0; i<v.size(); i++) {
|
|
|
- array.append(v.at(i));
|
|
|
+ if(fileManager.getListSize()==0) {
|
|
|
+ response.json["accept"] = false;
|
|
|
+ response.json["error"] = "nothing to upload";
|
|
|
+ } 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();
|
|
|
+ response.json["cancel"] = false;
|
|
|
+ response.json["names"] = array;
|
|
|
+ response.json["error"] = "";
|
|
|
}
|
|
|
|
|
|
- response.json["remaining"] = (int) v.size();
|
|
|
- response.json["cancel"] = false;
|
|
|
- response.json["names"] = array;
|
|
|
- response.json["error"] = "";
|
|
|
-
|
|
|
return response;
|
|
|
}
|
|
|
|