libstore: HttpBinaryCacheStore::{makeRequest -> makeURI}

it only sets the one field anyway (and the parent activity as a side
effect that does not depend on the exact location of the constructor
call). when FileTransferRequest goes away we would need this anyway.

Change-Id: I35cf2ed3533239181449a62cf34cd282b395e5db
This commit is contained in:
eldritch horrors 2024-10-26 17:53:48 +02:00
parent 59e364c2a8
commit a8d6577bf0

View file

@ -114,7 +114,7 @@ protected:
checkEnabled();
try {
FileTransferRequest request(makeRequest(path));
FileTransferRequest request{makeURI(path)};
request.head = true;
getFileTransfer()->transfer(request);
return true;
@ -132,7 +132,7 @@ protected:
std::shared_ptr<std::basic_iostream<char>> istream,
const std::string & mimeType) override
{
auto req = makeRequest(path);
FileTransferRequest req{makeURI(path)};
req.data = StreamToSourceAdapter(istream).drain();
req.mimeType = mimeType;
try {
@ -142,19 +142,18 @@ protected:
}
}
FileTransferRequest makeRequest(const std::string & path)
std::string makeURI(const std::string & path)
{
return FileTransferRequest(
path.starts_with("https://") || path.starts_with("http://") || path.starts_with("file://")
return path.starts_with("https://") || path.starts_with("http://")
|| path.starts_with("file://")
? path
: cacheUri + "/" + path);
: cacheUri + "/" + path;
}
box_ptr<Source> getFile(const std::string & path) override
{
checkEnabled();
auto request(makeRequest(path));
FileTransferRequest request{makeURI(path)};
try {
return getFileTransfer()->download(std::move(request));
} catch (FileTransferError & e) {
@ -169,7 +168,7 @@ protected:
{
checkEnabled();
auto request(makeRequest(path));
FileTransferRequest request{makeURI(path)};
try {
return std::move(getFileTransfer()->enqueueFileTransfer(request).get().data);