|
@@ -131,16 +131,23 @@ CmdMan::CmdRet CmdMan::cmdPut(vector<string> args) {
|
|
|
root["accept"] = false;
|
|
|
root["error"] = "not enough arguments, at least 1 argument required";
|
|
|
} else {
|
|
|
- bool opened = fileman.openPut(args[0]);
|
|
|
- root["file"] = fileman.getPutName();
|
|
|
- if (opened) {
|
|
|
- root["size"] = fileman.getPutSize();
|
|
|
- root["chunks"] = fileman.getPutChunks();
|
|
|
- retval.type = send;
|
|
|
- } else {
|
|
|
+ if (fileman.isPutting()) {
|
|
|
retval.type = error;
|
|
|
+ root["file"] = args[0];
|
|
|
root["accept"] = false;
|
|
|
- root["error"] = "couldnt open local file \"" + args[0] + "\"";
|
|
|
+ root["error"] = "already putting file \"" + fileman.getPutName() + "\"";
|
|
|
+ } else {
|
|
|
+ bool opened = fileman.openPut(args[0]);
|
|
|
+ root["file"] = fileman.getPutName();
|
|
|
+ if (opened) {
|
|
|
+ root["size"] = fileman.getPutSize();
|
|
|
+ root["chunks"] = fileman.getPutChunks();
|
|
|
+ retval.type = send;
|
|
|
+ } else {
|
|
|
+ retval.type = error;
|
|
|
+ root["accept"] = false;
|
|
|
+ root["error"] = "couldnt open local file \"" + args[0] + "\"";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -175,14 +182,21 @@ CmdMan::CmdRet CmdMan::cmdGet(vector<string> args) {
|
|
|
root["accept"] = false;
|
|
|
root["error"] = "not enough arguments, at least 1 argument required";
|
|
|
} else {
|
|
|
- bool opened = fileman.openGet(args[0]);
|
|
|
- root["file"] = fileman.getGetName();
|
|
|
- if (opened) {
|
|
|
- retval.type = send;
|
|
|
- } else {
|
|
|
+ if (fileman.isGetting()) {
|
|
|
retval.type = error;
|
|
|
+ root["file"] = args[0];
|
|
|
root["accept"] = false;
|
|
|
- root["error"] = "local file \"" + args[0] + "\" already exists";
|
|
|
+ root["error"] = "already getting file \"" + fileman.getGetName() + "\"";
|
|
|
+ } else {
|
|
|
+ bool opened = fileman.openGet(args[0]);
|
|
|
+ root["file"] = fileman.getGetName();
|
|
|
+ if (opened) {
|
|
|
+ retval.type = send;
|
|
|
+ } else {
|
|
|
+ retval.type = error;
|
|
|
+ root["accept"] = false;
|
|
|
+ root["error"] = "local file \"" + args[0] + "\" already exists";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|