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