mirror of
https://github.com/NixOS/nix.git
synced 2025-11-25 11:49:35 +01:00
create cache entry for paths already in the nix store
This allows path:/nix/store/* paths to not be copied twice to the nix
store.
(cherry picked from commit 61c6210dbf)
This commit is contained in:
parent
6d53506ae3
commit
651df50996
3 changed files with 30 additions and 7 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#include "nix/store/store-api.hh"
|
||||
#include "nix/util/archive.hh"
|
||||
#include "nix/fetchers/store-path-accessor.hh"
|
||||
#include "nix/fetchers/cache.hh"
|
||||
#include "nix/fetchers/fetch-to-store.hh"
|
||||
|
||||
namespace nix::fetchers {
|
||||
|
||||
|
|
@ -142,6 +144,14 @@ struct PathInputScheme : InputScheme
|
|||
storePath = store->addToStoreFromDump(*src, "source");
|
||||
}
|
||||
|
||||
// To avoid copying the path again to the /nix/store, we need to add a cache entry.
|
||||
ContentAddressMethod method = ContentAddressMethod::Raw::NixArchive;
|
||||
auto fp = getFingerprint(store, input);
|
||||
if (fp) {
|
||||
auto cacheKey = makeFetchToStoreCacheKey(input.getName(), *fp, method, "/");
|
||||
fetchers::getCache()->upsert(cacheKey, *store, {}, *storePath);
|
||||
}
|
||||
|
||||
/* Trust the lastModified value supplied by the user, if
|
||||
any. It's not a "secure" attribute so we don't care. */
|
||||
if (!input.getLastModified())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue