A lot of file transfer updates
This commit is contained in:
parent
b60608ff94
commit
a4febf7b5a
@ -6,6 +6,11 @@
|
||||
|
||||
using namespace ts;
|
||||
|
||||
#define str(x) #x
|
||||
|
||||
#define define_error_description(type, description) \
|
||||
{ error::type, str(type), description }
|
||||
|
||||
const std::vector<ErrorType> ts::avariableErrors = {
|
||||
{0x0000, "ok" , "ok" },
|
||||
{0x0001, "undefined" , "undefined error" },
|
||||
@ -95,6 +100,8 @@ const std::vector<ErrorType> ts::avariableErrors = {
|
||||
{0x0605, "parameter_invalid_size" , "invalid parameter size" },
|
||||
{0x0606, "parameter_missing" , "missing required parameter" },
|
||||
{0x0607, "parameter_checksum" , "invalid checksum" },
|
||||
define_error_description(parameter_constraint_violation, "parameter does not fits its constraint"),
|
||||
/* example: all name= parameter in a bulk must start with /icon_ */
|
||||
|
||||
{0x0700, "vs_critical" , "virtual server got a critical error" },
|
||||
{0x0701, "connection_lost" , "Connection lost" },
|
||||
@ -134,7 +141,8 @@ const std::vector<ErrorType> ts::avariableErrors = {
|
||||
{0x0815, "file_transfer_client_quota_exceeded" , "file transfer client quota exceeded" },
|
||||
{0x0816, "file_transfer_reset" , "file transfer reset" },
|
||||
{0x0817, "file_transfer_limit_reached" , "file transfer limit reached" },
|
||||
|
||||
define_error_description(file_api_timeout, "the file API call has been timed out"),
|
||||
define_error_description(file_virtual_server_not_registered, "the file server does not know our virtual server"),
|
||||
|
||||
{0x0A08, "server_insufficeient_permissions" , "insufficient client permissions" },
|
||||
|
||||
|
21
src/Error.h
21
src/Error.h
@ -105,6 +105,8 @@ namespace ts {
|
||||
parameter_invalid_size = 0x605,
|
||||
parameter_missing = 0x606,
|
||||
parameter_checksum = 0x607,
|
||||
parameter_constraint_violation = 0x6010,
|
||||
|
||||
vs_critical = 0x700,
|
||||
connection_lost = 0x701,
|
||||
not_connected = 0x702,
|
||||
@ -118,6 +120,7 @@ namespace ts {
|
||||
serverlibrary_not_initialised = 0x70a,
|
||||
whisper_too_many_targets = 0x70b,
|
||||
whisper_no_targets = 0x70c,
|
||||
|
||||
file_invalid_name = 0x800,
|
||||
file_invalid_permissions = 0x801,
|
||||
file_already_exists = 0x802,
|
||||
@ -142,6 +145,12 @@ namespace ts {
|
||||
file_transfer_client_quota_exceeded = 0x815,
|
||||
file_transfer_reset = 0x816,
|
||||
file_transfer_limit_reached = 0x817,
|
||||
|
||||
file_api_timeout = 0x820,
|
||||
file_virtual_server_not_registered = 0x821,
|
||||
file_server_transfer_limit_reached = 0x822,
|
||||
file_client_transfer_limit_reached = 0x823,
|
||||
|
||||
server_insufficeient_permissions = 0xa08,
|
||||
accounting_slot_limit_reached = 0xb01,
|
||||
server_connect_banned = 0xd01,
|
||||
@ -380,6 +389,14 @@ namespace ts {
|
||||
result.release_data();
|
||||
}
|
||||
|
||||
inline size_t length() const {
|
||||
return this->results.size();
|
||||
}
|
||||
|
||||
inline const ts::command_result& response(size_t index) const {
|
||||
return this->results[index];
|
||||
}
|
||||
|
||||
inline void reserve(size_t length) {
|
||||
this->results.reserve(length);
|
||||
}
|
||||
@ -388,6 +405,10 @@ namespace ts {
|
||||
this->results.push_back(std::forward<ts::command_result>(result));
|
||||
}
|
||||
|
||||
inline void set_result(size_t index, ts::command_result&& result) {
|
||||
this->results[index].reset(std::forward<ts::command_result>(result));
|
||||
}
|
||||
|
||||
inline void emplace_result(permission::PermissionType permission) {
|
||||
this->results.emplace_back(permission);
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ namespace license {
|
||||
return "MyTsIdSign";
|
||||
case LicenseType::EPHEMERAL:
|
||||
return "Ephemeral";
|
||||
case LicenseType::TOKEN:
|
||||
return "Token";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ namespace ts {
|
||||
[[nodiscard]] operator T(){ return this->as<T>(); }
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] T as_save() const {
|
||||
[[nodiscard]] T as_save(const std::function<T()> defaultValue = []{ return T{}; }) const {
|
||||
try {
|
||||
std::lock_guard lock(this->data_ptr->value_lock);
|
||||
if(this->data_ptr->casted_value.type() == typeid(T))
|
||||
@ -776,7 +776,7 @@ namespace ts {
|
||||
this->data_ptr->casted_value = ts::converter<T>::from_string_view(this->data_ptr->value);
|
||||
return std::any_cast<T>(this->data_ptr->casted_value);
|
||||
} catch(std::exception&) {
|
||||
return T{};
|
||||
return defaultValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,8 @@ namespace ts::buffer {
|
||||
return 1024;
|
||||
case Bytes_1536:
|
||||
return 1536;
|
||||
case unset:
|
||||
case max:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -184,6 +184,10 @@ namespace ts {
|
||||
this->bulk.reserve(length + (accumulative ? this->bulk.size() : 0));
|
||||
}
|
||||
|
||||
inline void reset() {
|
||||
this->bulk.clear();
|
||||
}
|
||||
|
||||
inline void put(const std::string_view& key, const std::string_view& value) {
|
||||
size_t begin, end;
|
||||
if(impl::value_raw_impl(this->bulk, key, begin, &end)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user