diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-06-02 11:58:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 11:58:20 +0200 |
commit | 7dbba0a94e3d5ad0388131d5653808084c42db89 (patch) | |
tree | 282d3a769c0c3c1c311610ff19086d3d4c246e22 /src/libfetchers | |
parent | 89e0b3e2d62f72e48bdda63b77a086c69b314113 (diff) | |
parent | c254254a8088ca303e97b9430484cf25cf8f7806 (diff) |
Merge pull request #3645 from mkenigs/fetchOrSubstituteTree-improvements
Cache tree in fetchOrSubstituteTree
Diffstat (limited to 'src/libfetchers')
-rw-r--r-- | src/libfetchers/fetchers.cc | 2 | ||||
-rw-r--r-- | src/libfetchers/fetchers.hh | 2 | ||||
-rw-r--r-- | src/libfetchers/git.cc | 11 | ||||
-rw-r--r-- | src/libfetchers/github.cc | 5 | ||||
-rw-r--r-- | src/libfetchers/mercurial.cc | 13 | ||||
-rw-r--r-- | src/libfetchers/path.cc | 5 | ||||
-rw-r--r-- | src/libfetchers/tarball.cc | 10 |
7 files changed, 15 insertions, 33 deletions
diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc index f0d8f72c8..dae8b9fb2 100644 --- a/src/libfetchers/fetchers.cc +++ b/src/libfetchers/fetchers.cc @@ -117,7 +117,7 @@ std::pair<Tree, Input> Input::fetch(ref<Store> store) const auto actualPath = store->toRealPath(storePath); - return {fetchers::Tree { .actualPath = actualPath, .storePath = std::move(storePath) }, *this}; + return {fetchers::Tree(std::move(actualPath), std::move(storePath)), *this}; } catch (Error & e) { debug("substitution of input '%s' failed: %s", to_string(), e.what()); } diff --git a/src/libfetchers/fetchers.hh b/src/libfetchers/fetchers.hh index c43cfe50c..2e8c534b0 100644 --- a/src/libfetchers/fetchers.hh +++ b/src/libfetchers/fetchers.hh @@ -16,6 +16,8 @@ struct Tree { Path actualPath; StorePath storePath; + Tree(Path && actualPath, StorePath && storePath) : actualPath(actualPath), storePath(std::move(storePath)) {} + Tree (const Tree & rhs) : actualPath(rhs.actualPath), storePath(rhs.storePath.clone()) {} }; struct InputScheme; diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 4fcf3f542..af4efc9b1 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -189,10 +189,7 @@ struct GitInputScheme : InputScheme input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount")); input.attrs.insert_or_assign("lastModified", getIntAttr(infoAttrs, "lastModified")); return { - Tree { - .actualPath = store->toRealPath(storePath), - .storePath = std::move(storePath), - }, + Tree(store->toRealPath(storePath), std::move(storePath)), input }; }; @@ -273,10 +270,8 @@ struct GitInputScheme : InputScheme haveCommits ? std::stoull(runProgram("git", true, { "-C", actualUrl, "log", "-1", "--format=%ct", "HEAD" })) : 0); return { - Tree { - .actualPath = store->printStorePath(storePath), - .storePath = std::move(storePath), - }, input + Tree(store->printStorePath(storePath), std::move(storePath)), + input }; } } diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index d20b5d00c..cf2554a50 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -140,10 +140,7 @@ struct GitArchiveInputScheme : InputScheme if (auto res = getCache()->lookup(store, immutableAttrs)) { input.attrs.insert_or_assign("lastModified", getIntAttr(res->first, "lastModified")); return { - Tree{ - .actualPath = store->toRealPath(res->second), - .storePath = std::move(res->second), - }, + Tree(store->toRealPath(res->second), std::move(res->second)), input }; } diff --git a/src/libfetchers/mercurial.cc b/src/libfetchers/mercurial.cc index 49ed63243..9fae32b83 100644 --- a/src/libfetchers/mercurial.cc +++ b/src/libfetchers/mercurial.cc @@ -164,10 +164,10 @@ struct MercurialInputScheme : InputScheme auto storePath = store->addToStore("source", actualUrl, true, htSHA256, filter); - return {Tree { - .actualPath = store->printStorePath(storePath), - .storePath = std::move(storePath), - }, input}; + return { + Tree(store->printStorePath(storePath), std::move(storePath)), + input + }; } } @@ -189,10 +189,7 @@ struct MercurialInputScheme : InputScheme assert(!_input.getRev() || _input.getRev() == input.getRev()); input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount")); return { - Tree{ - .actualPath = store->toRealPath(storePath), - .storePath = std::move(storePath), - }, + Tree(store->toRealPath(storePath), std::move(storePath)), input }; }; diff --git a/src/libfetchers/path.cc b/src/libfetchers/path.cc index cbbb0fa02..99d4b4e8f 100644 --- a/src/libfetchers/path.cc +++ b/src/libfetchers/path.cc @@ -96,10 +96,7 @@ struct PathInputScheme : InputScheme storePath = store->addToStore("source", path); return { - Tree { - .actualPath = store->toRealPath(*storePath), - .storePath = std::move(*storePath), - }, + Tree(store->toRealPath(*storePath), std::move(*storePath)), input }; } diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index 624f8b3fb..9479bb1b3 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -117,10 +117,7 @@ std::pair<Tree, time_t> downloadTarball( if (cached && !cached->expired) return { - Tree { - .actualPath = store->toRealPath(cached->storePath), - .storePath = std::move(cached->storePath), - }, + Tree(store->toRealPath(cached->storePath), std::move(cached->storePath)), getIntAttr(cached->infoAttrs, "lastModified") }; @@ -157,10 +154,7 @@ std::pair<Tree, time_t> downloadTarball( immutable); return { - Tree { - .actualPath = store->toRealPath(*unpackedStorePath), - .storePath = std::move(*unpackedStorePath), - }, + Tree(store->toRealPath(*unpackedStorePath), std::move(*unpackedStorePath)), lastModified, }; } |