1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 15:32:43 +01:00

fetchToStore(): Don't always respect settings.readOnlyMode

It's now up to the caller whether readOnlyMode should be applied. In
some contexts (like InputScheme::fetch()), we always need to fetch.
This commit is contained in:
Eelco Dolstra 2024-02-20 10:36:36 +01:00
parent 6162105675
commit 7cb4d0c5b7
7 changed files with 29 additions and 10 deletions

View file

@ -7,6 +7,7 @@ namespace nix {
StorePath fetchToStore(
Store & store,
const SourcePath & path,
FetchMode mode,
std::string_view name,
ContentAddressMethod method,
PathFilter * filter,
@ -33,21 +34,19 @@ StorePath fetchToStore(
} else
debug("source path '%s' is uncacheable", path);
auto readOnly = settings.readOnlyMode;
Activity act(*logger, lvlChatty, actUnknown,
fmt(readOnly ? "hashing '%s'" : "copying '%s' to the store", path));
fmt(mode == FetchMode::DryRun ? "hashing '%s'" : "copying '%s' to the store", path));
auto filter2 = filter ? *filter : defaultPathFilter;
auto storePath =
readOnly
mode == FetchMode::DryRun
? store.computeStorePath(
name, *path.accessor, path.path, method, HashAlgorithm::SHA256, {}, filter2).first
: store.addToStore(
name, *path.accessor, path.path, method, HashAlgorithm::SHA256, {}, filter2, repair);
if (cacheKey)
if (cacheKey && mode == FetchMode::Copy)
fetchers::getCache()->add(store, *cacheKey, {}, storePath, true);
return storePath;