Browse Source

fix get implementation

Missingmew 5 years ago
parent
commit
ce067a2902
1 changed files with 3 additions and 2 deletions
  1. 3 2
      cli/src/machineiomanager.cpp

+ 3 - 2
cli/src/machineiomanager.cpp

@@ -156,7 +156,7 @@ void MachineIoManager::run() {
 	    break;
     }
     case CMD_GET: {
-	    int chunks;
+	    int chunks, rec = 0;
 	    std::vector<char> wtmp;
 	    char wbuf[BLOCKSIZE];
 	    if(tokens.size() < 2) {
@@ -182,7 +182,6 @@ void MachineIoManager::run() {
 	    if(recv["accept"].asBool()) {
 		    // for ACK
 		    root["command"] = "get";
-		    root["remaining"] = 0;
 		    root["cancel"] = false;
 		    // request ok, start receiving
 		    chunks = std::numeric_limits<int>::max();
@@ -195,10 +194,12 @@ void MachineIoManager::run() {
 			    wtmp = base64::decodeVector(recv["data"].asString());
 			    fs.write(wtmp.data(), wtmp.size());
 			    chunks = recv["remaining"].asInt();
+			    root["received"] = rec;
 			    if(!sendJson(root)) {
 				// couldnt ACK
 				break;
 			    }
+			    rec++;
 		    }
 	    }
 	    if(recv["cancel"].asBool()) std::cerr << "transfer was cancelled" << std::endl;