|
|
@ -290,135 +290,6 @@ _get_kvs_key(const httplib::Request &req_, |
|
|
"application/json"); |
|
|
"application/json"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// New endpoints for enhanced UI
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
_get_branches(const httplib::Request &req_, |
|
|
|
|
|
httplib::Response &res_) |
|
|
|
|
|
{ |
|
|
|
|
|
if(not req_.has_param("mount")) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.status = 400; |
|
|
|
|
|
res_.set_content("{\"error\":\"mount param not set\"}", |
|
|
|
|
|
"application/json"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fs::path mount; |
|
|
|
|
|
std::string val; |
|
|
|
|
|
|
|
|
|
|
|
mount = req_.get_param_value("mount"); |
|
|
|
|
|
|
|
|
|
|
|
if(mergerfs::api::get_kv(mount,"branches",&val) >= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.set_content(val, "text/plain"); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
res_.set_content("", "text/plain"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
_post_branches(const httplib::Request &req_, |
|
|
|
|
|
httplib::Response &res_) |
|
|
|
|
|
{ |
|
|
|
|
|
if(not req_.has_param("mount")) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.status = 400; |
|
|
|
|
|
res_.set_content("{\"error\":\"mount param not set\"}", |
|
|
|
|
|
"application/json"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fs::path mount; |
|
|
|
|
|
std::string val; |
|
|
|
|
|
|
|
|
|
|
|
mount = req_.get_param_value("mount"); |
|
|
|
|
|
val = req_.body; |
|
|
|
|
|
|
|
|
|
|
|
int rv = mergerfs::api::set_kv(mount,"branches",val); |
|
|
|
|
|
|
|
|
|
|
|
if(rv >= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.set_content("{\"result\":\"success\"}", "application/json"); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
res_.status = 400; |
|
|
|
|
|
res_.set_content("{\"result\":\"error\",\"message\":\"Failed to set branches\"}", "application/json"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
_get_xattr(const httplib::Request &req_, |
|
|
|
|
|
httplib::Response &res_) |
|
|
|
|
|
{ |
|
|
|
|
|
if(not req_.has_param("mount")) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.status = 400; |
|
|
|
|
|
res_.set_content("{\"error\":\"mount param not set\"}", |
|
|
|
|
|
"application/json"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fs::path mount; |
|
|
|
|
|
std::string key; |
|
|
|
|
|
std::string val; |
|
|
|
|
|
|
|
|
|
|
|
mount = req_.get_param_value("mount"); |
|
|
|
|
|
key = req_.path_params.at("key"); |
|
|
|
|
|
|
|
|
|
|
|
int rv = mergerfs::api::get_kv(mount,key,&val); |
|
|
|
|
|
|
|
|
|
|
|
if(rv >= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.set_content("\"" + val + "\"", "application/json"); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
res_.status = 404; |
|
|
|
|
|
res_.set_content("{\"error\":\"xattr not found\"}", "application/json"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
_post_xattr(const httplib::Request &req_, |
|
|
|
|
|
httplib::Response &res_) |
|
|
|
|
|
{ |
|
|
|
|
|
if(not req_.has_param("mount")) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.status = 400; |
|
|
|
|
|
res_.set_content("{\"error\":\"mount param not set\"}", |
|
|
|
|
|
"application/json"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fs::path mount; |
|
|
|
|
|
std::string key; |
|
|
|
|
|
std::string val; |
|
|
|
|
|
|
|
|
|
|
|
mount = req_.get_param_value("mount"); |
|
|
|
|
|
key = req_.path_params.at("key"); |
|
|
|
|
|
val = req_.body; |
|
|
|
|
|
|
|
|
|
|
|
int rv = mergerfs::api::set_kv(mount,key,val); |
|
|
|
|
|
|
|
|
|
|
|
if(rv >= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
res_.set_content("{\"result\":\"success\"}", "application/json"); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
res_.status = 400; |
|
|
|
|
|
res_.set_content("{\"result\":\"error\",\"message\":\"Failed to set xattr\"}", "application/json"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
_execute_command(const httplib::Request &req_, |
|
|
_execute_command(const httplib::Request &req_, |
|
|
|