diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc index f26ee811b..5cb0dac17 100644 --- a/src/libfetchers/fetchers.cc +++ b/src/libfetchers/fetchers.cc @@ -311,6 +311,19 @@ void InputScheme::clone(const Input & input, const Path & destDir) throw Error("do not know how to clone input '%s'", input.to_string()); } +std::pair InputScheme::fetch(ref store, const Input & input) +{ + auto [accessor, input2] = lazyFetch(store, input); + + auto source = sinkToSource([&](Sink & sink) { + accessor->dumpPath(CanonPath::root, sink); + }); + + auto storePath = store->addToStoreFromDump(*source, "source"); + + return {storePath, input2}; +} + std::pair, Input> InputScheme::lazyFetch(ref store, const Input & input) { auto [storePath, input2] = fetch(store, input); diff --git a/src/libfetchers/fetchers.hh b/src/libfetchers/fetchers.hh index 9c67217ee..6ca798b71 100644 --- a/src/libfetchers/fetchers.hh +++ b/src/libfetchers/fetchers.hh @@ -135,7 +135,11 @@ struct InputScheme virtual void markChangedFile(const Input & input, std::string_view file, std::optional commitMsg); - virtual std::pair fetch(ref store, const Input & input) = 0; + /* Note: the default implementations of fetch() and lazyFetch() + are defined using the other, so implementations have to + override at least one. */ + + virtual std::pair fetch(ref store, const Input & input); virtual std::pair, Input> lazyFetch(ref store, const Input & input); diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index 93138398a..da115478e 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -134,7 +134,9 @@ struct GitArchiveInputScheme : InputScheme bool hasAllInfo(const Input & input) override { - return input.getRev() && maybeGetIntAttr(input.attrs, "lastModified"); + return input.getRev() && + true; // FIXME + //maybeGetIntAttr(input.attrs, "lastModified"); } Input applyOverrides( @@ -224,11 +226,6 @@ struct GitArchiveInputScheme : InputScheme return {res.storePath, input}; } - std::pair fetch(ref store, const Input & _input) override - { - throw UnimplementedError("GitArchive::fetch()"); - } - std::pair, Input> lazyFetch(ref store, const Input & input) override { auto [storePath, input2] = downloadArchive(store, input);