forked from lix-project/lix
queryPathInfoUncached(): Return const ValidPathInfo
This commit is contained in:
parent
992a2ad475
commit
e5319a87ce
|
@ -296,7 +296,7 @@ void BinaryCacheStore::narFromPath(const Path & storePath, Sink & sink)
|
|||
}
|
||||
|
||||
void BinaryCacheStore::queryPathInfoUncached(const Path & storePath,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
||||
{
|
||||
auto uri = getUri();
|
||||
auto act = std::make_shared<Activity>(*logger, lvlTalkative, actQueryPathInfo,
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
bool isValidPathUncached(const Path & path) override;
|
||||
|
||||
void queryPathInfoUncached(const Path & path,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept override;
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override;
|
||||
|
||||
Path queryPathFromHashPart(const string & hashPart) override
|
||||
{ unsupported("queryPathFromHashPart"); }
|
||||
|
|
|
@ -88,7 +88,7 @@ struct LegacySSHStore : public Store
|
|||
}
|
||||
|
||||
void queryPathInfoUncached(const Path & path,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept override
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override
|
||||
{
|
||||
try {
|
||||
auto conn(connections->get());
|
||||
|
|
|
@ -632,7 +632,7 @@ uint64_t LocalStore::addValidPath(State & state,
|
|||
|
||||
|
||||
void LocalStore::queryPathInfoUncached(const Path & path,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
||||
{
|
||||
try {
|
||||
auto info = std::make_shared<ValidPathInfo>();
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
PathSet queryAllValidPaths() override;
|
||||
|
||||
void queryPathInfoUncached(const Path & path,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept override;
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override;
|
||||
|
||||
void queryReferrers(const Path & path, PathSet & referrers) override;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void Store::computeFSClosure(const PathSet & startPaths,
|
|||
state->pending++;
|
||||
}
|
||||
|
||||
queryPathInfo(path, {[&, path](std::future<ref<ValidPathInfo>> fut) {
|
||||
queryPathInfo(path, {[&, path](std::future<ref<const ValidPathInfo>> fut) {
|
||||
// FIXME: calls to isValidPath() should be async
|
||||
|
||||
try {
|
||||
|
|
|
@ -219,7 +219,7 @@ public:
|
|||
|
||||
void upsertNarInfo(
|
||||
const std::string & uri, const std::string & hashPart,
|
||||
std::shared_ptr<ValidPathInfo> info) override
|
||||
std::shared_ptr<const ValidPathInfo> info) override
|
||||
{
|
||||
retrySQLite<void>([&]() {
|
||||
auto state(_state.lock());
|
||||
|
@ -228,7 +228,7 @@ public:
|
|||
|
||||
if (info) {
|
||||
|
||||
auto narInfo = std::dynamic_pointer_cast<NarInfo>(info);
|
||||
auto narInfo = std::dynamic_pointer_cast<const NarInfo>(info);
|
||||
|
||||
assert(hashPart == storePathToHash(info->path));
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
virtual void upsertNarInfo(
|
||||
const std::string & uri, const std::string & hashPart,
|
||||
std::shared_ptr<ValidPathInfo> info) = 0;
|
||||
std::shared_ptr<const ValidPathInfo> info) = 0;
|
||||
};
|
||||
|
||||
/* Return a singleton cache object that can be used concurrently by
|
||||
|
|
|
@ -350,7 +350,7 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
|
|||
|
||||
|
||||
void RemoteStore::queryPathInfoUncached(const Path & path,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
||||
{
|
||||
try {
|
||||
std::shared_ptr<ValidPathInfo> info;
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
PathSet queryAllValidPaths() override;
|
||||
|
||||
void queryPathInfoUncached(const Path & path,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept override;
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override;
|
||||
|
||||
void queryReferrers(const Path & path, PathSet & referrers) override;
|
||||
|
||||
|
|
|
@ -320,10 +320,10 @@ bool Store::isValidPathUncached(const Path & path)
|
|||
|
||||
ref<const ValidPathInfo> Store::queryPathInfo(const Path & storePath)
|
||||
{
|
||||
std::promise<ref<ValidPathInfo>> promise;
|
||||
std::promise<ref<const ValidPathInfo>> promise;
|
||||
|
||||
queryPathInfo(storePath,
|
||||
{[&](std::future<ref<ValidPathInfo>> result) {
|
||||
{[&](std::future<ref<const ValidPathInfo>> result) {
|
||||
try {
|
||||
promise.set_value(result.get());
|
||||
} catch (...) {
|
||||
|
@ -336,7 +336,7 @@ ref<const ValidPathInfo> Store::queryPathInfo(const Path & storePath)
|
|||
|
||||
|
||||
void Store::queryPathInfo(const Path & storePath,
|
||||
Callback<ref<ValidPathInfo>> callback) noexcept
|
||||
Callback<ref<const ValidPathInfo>> callback) noexcept
|
||||
{
|
||||
std::string hashPart;
|
||||
|
||||
|
@ -351,7 +351,7 @@ void Store::queryPathInfo(const Path & storePath,
|
|||
stats.narInfoReadAverted++;
|
||||
if (!*res)
|
||||
throw InvalidPath(format("path '%s' is not valid") % storePath);
|
||||
return callback(ref<ValidPathInfo>(*res));
|
||||
return callback(ref<const ValidPathInfo>(*res));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ void Store::queryPathInfo(const Path & storePath,
|
|||
(res.second->path != storePath && storePathToName(storePath) != ""))
|
||||
throw InvalidPath(format("path '%s' is not valid") % storePath);
|
||||
}
|
||||
return callback(ref<ValidPathInfo>(res.second));
|
||||
return callback(ref<const ValidPathInfo>(res.second));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ void Store::queryPathInfo(const Path & storePath,
|
|||
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
|
||||
|
||||
queryPathInfoUncached(storePath,
|
||||
{[this, storePath, hashPart, callbackPtr](std::future<std::shared_ptr<ValidPathInfo>> fut) {
|
||||
{[this, storePath, hashPart, callbackPtr](std::future<std::shared_ptr<const ValidPathInfo>> fut) {
|
||||
|
||||
try {
|
||||
auto info = fut.get();
|
||||
|
@ -396,7 +396,7 @@ void Store::queryPathInfo(const Path & storePath,
|
|||
throw InvalidPath("path '%s' is not valid", storePath);
|
||||
}
|
||||
|
||||
(*callbackPtr)(ref<ValidPathInfo>(info));
|
||||
(*callbackPtr)(ref<const ValidPathInfo>(info));
|
||||
} catch (...) { callbackPtr->rethrow(); }
|
||||
}});
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti
|
|||
|
||||
auto doQuery = [&](const Path & path ) {
|
||||
checkInterrupt();
|
||||
queryPathInfo(path, {[path, &state_, &wakeup](std::future<ref<ValidPathInfo>> fut) {
|
||||
queryPathInfo(path, {[path, &state_, &wakeup](std::future<ref<const ValidPathInfo>> fut) {
|
||||
auto state(state_.lock());
|
||||
try {
|
||||
auto info = fut.get();
|
||||
|
|
|
@ -258,7 +258,7 @@ protected:
|
|||
|
||||
struct State
|
||||
{
|
||||
LRUCache<std::string, std::shared_ptr<ValidPathInfo>> pathInfoCache;
|
||||
LRUCache<std::string, std::shared_ptr<const ValidPathInfo>> pathInfoCache;
|
||||
};
|
||||
|
||||
Sync<State> state;
|
||||
|
@ -361,12 +361,12 @@ public:
|
|||
|
||||
/* Asynchronous version of queryPathInfo(). */
|
||||
void queryPathInfo(const Path & path,
|
||||
Callback<ref<ValidPathInfo>> callback) noexcept;
|
||||
Callback<ref<const ValidPathInfo>> callback) noexcept;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void queryPathInfoUncached(const Path & path,
|
||||
Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept = 0;
|
||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept = 0;
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in a new issue