Some updates
This commit is contained in:
parent
b987583770
commit
c7751efa71
@ -273,7 +273,9 @@ namespace ts::server::file {
|
||||
NETWORK_IO_ERROR,
|
||||
|
||||
UNEXPECTED_CLIENT_DISCONNECT,
|
||||
UNEXPECTED_DISK_EOF
|
||||
UNEXPECTED_DISK_EOF,
|
||||
|
||||
USER_REQUEST
|
||||
} error_type{UNKNOWN};
|
||||
std::string error_message{};
|
||||
};
|
||||
|
@ -248,6 +248,15 @@ std::shared_ptr<ExecuteResponse<TransferInitError, std::shared_ptr<Transfer>>> L
|
||||
response->emplace_fail(TransferInitError::IO_ERROR, "file_size");
|
||||
return response;
|
||||
}
|
||||
|
||||
if(info.download_client_quota_limit > 0 && info.download_client_quota_limit <= transfer->expected_file_size) {
|
||||
response->emplace_fail(TransferInitError::CLIENT_QUOTA_EXCEEDED, "");
|
||||
return response;
|
||||
}
|
||||
if(info.download_server_quota_limit > 0 && info.download_server_quota_limit <= transfer->expected_file_size) {
|
||||
response->emplace_fail(TransferInitError::SERVER_QUOTA_EXCEEDED, "");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@ -297,11 +306,13 @@ std::shared_ptr<ExecuteResponse<TransferActionError>> LocalFileTransfer::stop_tr
|
||||
}
|
||||
|
||||
if(connected_transfer) {
|
||||
this->invoke_aborted_callback(connected_transfer, { TransferError::USER_REQUEST, "" });
|
||||
logMessage(LOG_FT, "{} Stopping transfer due to an user request.", connected_transfer->log_prefix());
|
||||
|
||||
std::unique_lock slock{connected_transfer->state_mutex};
|
||||
this->disconnect_client(connected_transfer, slock, flush);
|
||||
} else {
|
||||
this->invoke_aborted_callback(transfer, { TransferError::USER_REQUEST, "" });
|
||||
logMessage(LOG_FT, "Removing pending file transfer for id {}", id);
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,10 @@ void FileServerHandler::callback_transfer_aborted(const std::shared_ptr<transfer
|
||||
case ErrorType::UNEXPECTED_DISK_EOF:
|
||||
notify.put_unchecked(0, "status", (int) error::file_transfer_interrupted);
|
||||
notify.put_unchecked(0, "msg", findError(error::file_transfer_interrupted).message);
|
||||
|
||||
case ErrorType::USER_REQUEST:
|
||||
notify.put_unchecked(0, "status", (int) error::file_transfer_canceled);
|
||||
notify.put_unchecked(0, "msg", findError(error::file_transfer_canceled).message);
|
||||
break;
|
||||
}
|
||||
notify.put_unchecked(0, "extra_msg", error.error_message);
|
||||
|
@ -569,6 +569,11 @@ command_result ConnectedClient::handleCommandFTInitUpload(ts::Command &cmd) {
|
||||
std::shared_ptr<file::ExecuteResponse<file::transfer::TransferInitError, std::shared_ptr<file::transfer::Transfer>>> transfer_response{};
|
||||
|
||||
info.max_bandwidth = -1;
|
||||
{
|
||||
auto max_quota = this->calculate_permission(permission::i_ft_max_bandwidth_upload, this->getClientId());
|
||||
if(max_quota.has_value)
|
||||
info.max_bandwidth = max_quota.value;
|
||||
}
|
||||
info.file_offset = 0;
|
||||
info.expected_file_size = cmd["size"].as<size_t>();
|
||||
info.override_exiting = cmd["overwrite"].as<bool>();
|
||||
@ -721,6 +726,12 @@ command_result ConnectedClient::handleCommandFTInitDownload(ts::Command &cmd) {
|
||||
}
|
||||
|
||||
info.max_bandwidth = -1;
|
||||
{
|
||||
auto max_quota = this->calculate_permission(permission::i_ft_max_bandwidth_download, this->getClientId());
|
||||
if(max_quota.has_value)
|
||||
info.max_bandwidth = max_quota.value;
|
||||
}
|
||||
|
||||
info.file_offset = cmd["seekpos"].as<size_t>();
|
||||
info.override_exiting = false;
|
||||
info.file_path = cmd["name"].string();
|
||||
|
2
shared
2
shared
@ -1 +1 @@
|
||||
Subproject commit a4febf7b5af191d41c566292958c55155128f16f
|
||||
Subproject commit f404d5e1fa5ed1cfbe3ef9a97c0e81c1fba943ff
|
Loading…
Reference in New Issue
Block a user