-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine
AbstractPos
, PosAdapter
, and Pos
Also move `SourcePath` into `libutil`. These changes allow `error.hh` and `error.cc` to access source path and position information, which we can use to produce better error messages (for example, we could consider omitting filenames when two or more consecutive stack frames originate from the same file).
- Loading branch information
Showing
36 changed files
with
611 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#include "editor-for.hh" | ||
#include "environment-variables.hh" | ||
#include "source-path.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
///@file | ||
|
||
#include "types.hh" | ||
#include "input-accessor.hh" | ||
#include "source-path.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "fetch-to-store.hh" | ||
#include "fetchers.hh" | ||
#include "cache.hh" | ||
|
||
namespace nix { | ||
|
||
StorePath fetchToStore( | ||
Store & store, | ||
const SourcePath & path, | ||
std::string_view name, | ||
ContentAddressMethod method, | ||
PathFilter * filter, | ||
RepairFlag repair) | ||
{ | ||
// FIXME: add an optimisation for the case where the accessor is | ||
// an FSInputAccessor pointing to a store path. | ||
|
||
std::optional<fetchers::Attrs> cacheKey; | ||
|
||
if (!filter && path.accessor->fingerprint) { | ||
cacheKey = fetchers::Attrs{ | ||
{"_what", "fetchToStore"}, | ||
{"store", store.storeDir}, | ||
{"name", std::string(name)}, | ||
{"fingerprint", *path.accessor->fingerprint}, | ||
{ | ||
"method", | ||
std::visit(overloaded { | ||
[](const TextIngestionMethod &) { | ||
return "text"; | ||
}, | ||
[](const FileIngestionMethod & fim) { | ||
switch (fim) { | ||
case FileIngestionMethod::Flat: return "flat"; | ||
case FileIngestionMethod::Recursive: return "nar"; | ||
default: assert(false); | ||
} | ||
}, | ||
}, method.raw), | ||
}, | ||
{"path", path.path.abs()} | ||
}; | ||
if (auto res = fetchers::getCache()->lookup(store, *cacheKey)) { | ||
debug("store path cache hit for '%s'", path); | ||
return res->second; | ||
} | ||
} else | ||
debug("source path '%s' is uncacheable", path); | ||
|
||
Activity act(*logger, lvlChatty, actUnknown, fmt("copying '%s' to the store", path)); | ||
|
||
auto filter2 = filter ? *filter : defaultPathFilter; | ||
|
||
auto storePath = | ||
settings.readOnlyMode | ||
? 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) | ||
fetchers::getCache()->add(store, *cacheKey, {}, storePath, true); | ||
|
||
return storePath; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "file-ingestion-method.hh" | ||
#include "source-path.hh" | ||
#include "store-api.hh" | ||
#include "file-system.hh" | ||
#include "repair-flag.hh" | ||
|
||
namespace nix { | ||
|
||
/** | ||
* Copy the `path` to the Nix store. | ||
*/ | ||
StorePath fetchToStore( | ||
Store & store, | ||
const SourcePath & path, | ||
std::string_view name = "source", | ||
ContentAddressMethod method = FileIngestionMethod::Recursive, | ||
PathFilter * filter = nullptr, | ||
RepairFlag repair = NoRepair); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include "input-accessor.hh" | ||
#include "source-path.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include "input-accessor.hh" | ||
#include "source-path.hh" | ||
|
||
namespace nix { | ||
|
||
|
Oops, something went wrong.