mirror of
https://github.com/NixOS/nix.git
synced 2025-12-04 16:10:59 +01:00
Merge pull request #14675 from NixOS/cleanup-verb-filetransfer
libstore: Split FileTransferRequest::verb into verb + noun
This commit is contained in:
commit
5b175ace18
2 changed files with 24 additions and 10 deletions
|
|
@ -101,7 +101,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
, act(*logger,
|
, act(*logger,
|
||||||
lvlTalkative,
|
lvlTalkative,
|
||||||
actFileTransfer,
|
actFileTransfer,
|
||||||
fmt("%sing '%s'", request.verb(), request.uri),
|
fmt("%s '%s'", request.verb(/*continuous=*/true), request.uri),
|
||||||
{request.uri.to_string()},
|
{request.uri.to_string()},
|
||||||
request.parentAct)
|
request.parentAct)
|
||||||
, callback(std::move(callback))
|
, callback(std::move(callback))
|
||||||
|
|
@ -166,7 +166,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
std::rethrow_exception(ex);
|
std::rethrow_exception(ex);
|
||||||
} catch (nix::Error & e) {
|
} catch (nix::Error & e) {
|
||||||
/* Add more context to the error message. */
|
/* Add more context to the error message. */
|
||||||
e.addTrace({}, "during %s of '%s'", Uncolored(request.verb()), request.uri.to_string());
|
e.addTrace({}, "during %s of '%s'", Uncolored(request.noun()), request.uri.to_string());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
/* Can't add more context to the error. */
|
/* Can't add more context to the error. */
|
||||||
}
|
}
|
||||||
|
|
@ -510,7 +510,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
|
|
||||||
debug(
|
debug(
|
||||||
"finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes, duration = %.2f s",
|
"finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes, duration = %.2f s",
|
||||||
request.verb(),
|
request.noun(),
|
||||||
request.uri,
|
request.uri,
|
||||||
code,
|
code,
|
||||||
httpStatus,
|
httpStatus,
|
||||||
|
|
@ -610,7 +610,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
Interrupted,
|
Interrupted,
|
||||||
std::move(response),
|
std::move(response),
|
||||||
"%s of '%s' was interrupted",
|
"%s of '%s' was interrupted",
|
||||||
request.verb(),
|
request.noun(),
|
||||||
request.uri)
|
request.uri)
|
||||||
: httpStatus != 0
|
: httpStatus != 0
|
||||||
? FileTransferError(
|
? FileTransferError(
|
||||||
|
|
@ -845,7 +845,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & item : incoming) {
|
for (auto & item : incoming) {
|
||||||
debug("starting %s of %s", item->request.verb(), item->request.uri);
|
debug("starting %s of %s", item->request.noun(), item->request.uri);
|
||||||
item->init();
|
item->init();
|
||||||
curl_multi_add_handle(curlm, item->req);
|
curl_multi_add_handle(curlm, item->req);
|
||||||
item->active = true;
|
item->active = true;
|
||||||
|
|
|
||||||
|
|
@ -169,11 +169,25 @@ struct FileTransferRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the verb root for logging purposes.
|
* Returns the method description for logging purposes.
|
||||||
* The returned string is intended to be concatenated with "ing" to form the gerund,
|
|
||||||
* e.g., "download" + "ing" -> "downloading", "upload" + "ing" -> "uploading".
|
|
||||||
*/
|
*/
|
||||||
std::string verb() const
|
std::string verb(bool continuous = false) const
|
||||||
|
{
|
||||||
|
switch (method) {
|
||||||
|
case HttpMethod::Head:
|
||||||
|
case HttpMethod::Get:
|
||||||
|
return continuous ? "downloading" : "download";
|
||||||
|
case HttpMethod::Put:
|
||||||
|
case HttpMethod::Post:
|
||||||
|
assert(data);
|
||||||
|
return continuous ? "uploading" : "upload";
|
||||||
|
case HttpMethod::Delete:
|
||||||
|
return continuous ? "deleting" : "delete";
|
||||||
|
}
|
||||||
|
unreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string noun() const
|
||||||
{
|
{
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case HttpMethod::Head:
|
case HttpMethod::Head:
|
||||||
|
|
@ -184,7 +198,7 @@ struct FileTransferRequest
|
||||||
assert(data);
|
assert(data);
|
||||||
return "upload";
|
return "upload";
|
||||||
case HttpMethod::Delete:
|
case HttpMethod::Delete:
|
||||||
return "delet";
|
return "deletion";
|
||||||
}
|
}
|
||||||
unreachable();
|
unreachable();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue