mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
Ensure that Callback is called only once
Also, make Callback movable but uncopyable.
This commit is contained in:
parent
8c4ea7a451
commit
7348653ff4
5 changed files with 36 additions and 17 deletions
|
@ -365,8 +365,10 @@ void Store::queryPathInfo(const Path & storePath,
|
|||
|
||||
} catch (...) { return callback.rethrow(); }
|
||||
|
||||
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
|
||||
|
||||
queryPathInfoUncached(storePath,
|
||||
{[this, storePath, hashPart, callback](std::future<std::shared_ptr<ValidPathInfo>> fut) {
|
||||
{[this, storePath, hashPart, callbackPtr](std::future<std::shared_ptr<ValidPathInfo>> fut) {
|
||||
|
||||
try {
|
||||
auto info = fut.get();
|
||||
|
@ -386,8 +388,8 @@ void Store::queryPathInfo(const Path & storePath,
|
|||
throw InvalidPath("path '%s' is not valid", storePath);
|
||||
}
|
||||
|
||||
callback(ref<ValidPathInfo>(info));
|
||||
} catch (...) { callback.rethrow(); }
|
||||
(*callbackPtr)(ref<ValidPathInfo>(info));
|
||||
} catch (...) { callbackPtr->rethrow(); }
|
||||
}});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue