mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 23:42:43 +01:00
Create a second Store::getFSAccessor for a single store object
This is sometimes easier / more performant to implement, and independently it is also a more convenient interface for many callers. The existing store-wide `getFSAccessor` is only used for - `nix why-depends` - the evaluator I hope we can get rid of it for those, too, and then we have the option of getting rid of the store-wide method. Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
parent
0175f7e836
commit
a97d6d89d8
26 changed files with 125 additions and 57 deletions
|
|
@ -91,6 +91,23 @@ ref<SourceAccessor> LocalFSStore::getFSAccessor(bool requireValidPath)
|
|||
ref<LocalFSStore>(std::dynamic_pointer_cast<LocalFSStore>(shared_from_this())), requireValidPath);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceAccessor> LocalFSStore::getFSAccessor(const StorePath & path, bool requireValidPath)
|
||||
{
|
||||
auto absPath = std::filesystem::path{config.realStoreDir.get()} / path.to_string();
|
||||
if (requireValidPath) {
|
||||
/* Only return non-null if the store object is a fully-valid
|
||||
member of the store. */
|
||||
if (!isValidPath(path))
|
||||
return nullptr;
|
||||
} else {
|
||||
/* Return non-null as long as the some file system data exists,
|
||||
even if the store object is not fully registered. */
|
||||
if (!pathExists(absPath))
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<PosixSourceAccessor>(std::move(absPath));
|
||||
}
|
||||
|
||||
void LocalFSStore::narFromPath(const StorePath & path, Sink & sink)
|
||||
{
|
||||
if (!isValidPath(path))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue