diff options
author | eldritch horrors <pennae@lix.systems> | 2024-05-11 00:22:21 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-07-11 11:39:18 +0000 |
commit | 5587dbdcf078586dcc5b9c54af614c1915e9da0a (patch) | |
tree | 52c1de6713edddd1579f9d4740afd7e7a4cd4abe /src/libstore/s3-binary-cache-store.cc | |
parent | df8851f286a407c46ea9107ca403888291f1afbe (diff) |
libstore: make BinaryCacheStore::getFile return a source
this lets us remove the last true remaining uses of
makeDecompressionSink.
Change-Id: I146ca2bbe1a9ae9a367117a7b8a304b23a63e5e2
Diffstat (limited to 'src/libstore/s3-binary-cache-store.cc')
-rw-r--r-- | src/libstore/s3-binary-cache-store.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc index 4aed791ce..4683f00f9 100644 --- a/src/libstore/s3-binary-cache-store.cc +++ b/src/libstore/s3-binary-cache-store.cc @@ -455,7 +455,7 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual uploadFile(path, istream, mimeType, ""); } - void getFile(const std::string & path, Sink & sink) override + box_ptr<Source> getFile(const std::string & path) override { stats.get++; @@ -469,7 +469,11 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual printTalkative("downloaded 's3://%s/%s' (%d bytes) in %d ms", bucketName, path, res.data->size(), res.durationMs); - sink(*res.data); + return make_box_ptr<GeneratorSource>( + [](std::string data) -> Generator<Bytes> { + co_yield std::span{data.data(), data.size()}; + }(std::move(*res.data)) + ); } else throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache '%s'", path, getUri()); } |