|
@@ -316,23 +316,29 @@ JsonCommander::Response JsonCommander::executeHead(const Json::Value &message) {
|
|
|
response.action = send;
|
|
|
response.json["command"] = "head";
|
|
|
|
|
|
- if(!message["file"].isString()) {
|
|
|
+ if (!message["file"].isString()) {
|
|
|
response.json["accept"] = false;
|
|
|
response.json["file"] = "";
|
|
|
response.json["data"] = "";
|
|
|
response.json["error"] = "incorrect head command request";
|
|
|
} else {
|
|
|
- std::pair<std::vector<char>,std::string>res = fileManager.getBytesFromFile(message["file"].asString(), 4);
|
|
|
- if (res.second == "") {
|
|
|
+ std::pair<std::vector<char>, FileManager::headError> res =
|
|
|
+ fileManager.getBytesFromFile(message["file"].asString(), 4);
|
|
|
+ if (res.second == FileManager::headError::no_error) {
|
|
|
response.json["accept"] = true;
|
|
|
- response.json["file"] = message["file"];
|
|
|
+ response.json["file"] = message["file"].asString();
|
|
|
response.json["data"] = base64::encodeVector(res.first);
|
|
|
response.json["error"] = "";
|
|
|
+ } else if (res.second == FileManager::headError::no_such_file) {
|
|
|
+ response.json["accept"] = true;
|
|
|
+ response.json["file"] = message["file"].asString();
|
|
|
+ response.json["data"] = "";
|
|
|
+ response.json["error"] = "no such file";
|
|
|
} else {
|
|
|
response.json["accept"] = true;
|
|
|
- response.json["file"] = message["file"];
|
|
|
- response.json["data"] ="";
|
|
|
- response.json["error"] = res.second;
|
|
|
+ response.json["file"] = message["file"].asString();
|
|
|
+ response.json["data"] = "";
|
|
|
+ response.json["error"] = "file is smaller than specified size";
|
|
|
}
|
|
|
}
|
|
|
|