Remove InputAccessor::root()

This commit is contained in:
Eelco Dolstra 2023-11-30 16:44:54 +01:00
parent 305939655a
commit 43d9fb6cf1
4 changed files with 10 additions and 13 deletions

View file

@ -424,10 +424,9 @@ public:
SourcePath path() const SourcePath path() const
{ {
assert(internalType == tPath); assert(internalType == tPath);
return SourcePath { return SourcePath(
.accessor = ref(_path.accessor->shared_from_this()), ref(_path.accessor->shared_from_this()),
.path = CanonPath(CanonPath::unchecked_t(), _path.path) CanonPath(CanonPath::unchecked_t(), _path.path));
};
} }
std::string_view string_view() const std::string_view string_view() const

View file

@ -374,7 +374,7 @@ void InputScheme::clone(const Input & input, const Path & destDir) const
std::pair<StorePath, Input> InputScheme::fetch(ref<Store> store, const Input & input) std::pair<StorePath, Input> InputScheme::fetch(ref<Store> store, const Input & input)
{ {
auto [accessor, input2] = getAccessor(store, input); auto [accessor, input2] = getAccessor(store, input);
auto storePath = accessor->root().fetchToStore(store, input2.getName()); auto storePath = SourcePath(accessor).fetchToStore(store, input2.getName());
return {storePath, input2}; return {storePath, input2};
} }

View file

@ -53,11 +53,6 @@ StorePath InputAccessor::fetchToStore(
return storePath; return storePath;
} }
SourcePath InputAccessor::root()
{
return {ref(shared_from_this()), CanonPath::root};
}
std::ostream & operator << (std::ostream & str, const SourcePath & path) std::ostream & operator << (std::ostream & str, const SourcePath & path)
{ {
str << path.to_string(); str << path.to_string();
@ -88,7 +83,7 @@ SourcePath SourcePath::parent() const
SourcePath SourcePath::resolveSymlinks() const SourcePath SourcePath::resolveSymlinks() const
{ {
auto res = accessor->root(); auto res = SourcePath(accessor);
int linksAllowed = 1024; int linksAllowed = 1024;

View file

@ -36,8 +36,6 @@ struct InputAccessor : virtual SourceAccessor, std::enable_shared_from_this<Inpu
FileIngestionMethod method = FileIngestionMethod::Recursive, FileIngestionMethod method = FileIngestionMethod::Recursive,
PathFilter * filter = nullptr, PathFilter * filter = nullptr,
RepairFlag repair = NoRepair); RepairFlag repair = NoRepair);
SourcePath root();
}; };
/** /**
@ -51,6 +49,11 @@ struct SourcePath
ref<InputAccessor> accessor; ref<InputAccessor> accessor;
CanonPath path; CanonPath path;
SourcePath(ref<InputAccessor> accessor, CanonPath path = CanonPath::root)
: accessor(std::move(accessor))
, path(std::move(path))
{ }
std::string_view baseName() const; std::string_view baseName() const;
/** /**