mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
Merge pull request #8135 from patricksjackson/copyPaths-datarace
Fix data race in copyPaths
This commit is contained in:
commit
623115fc0f
1 changed files with 6 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include "archive.hh"
|
#include "archive.hh"
|
||||||
#include "callback.hh"
|
#include "callback.hh"
|
||||||
#include "remote-store.hh"
|
#include "remote-store.hh"
|
||||||
|
#include "sync.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
@ -1101,7 +1102,8 @@ std::map<StorePath, StorePath> copyPaths(
|
||||||
return storePathForDst;
|
return storePathForDst;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t total = 0;
|
// total is accessed by each copy, which are each handled in separate threads
|
||||||
|
Sync<uint64_t> _total = 0;
|
||||||
|
|
||||||
for (auto & missingPath : sortedMissing) {
|
for (auto & missingPath : sortedMissing) {
|
||||||
auto info = srcStore.queryPathInfo(missingPath);
|
auto info = srcStore.queryPathInfo(missingPath);
|
||||||
|
@ -1124,8 +1126,9 @@ std::map<StorePath, StorePath> copyPaths(
|
||||||
PushActivity pact(act.id);
|
PushActivity pact(act.id);
|
||||||
|
|
||||||
LambdaSink progressSink([&](std::string_view data) {
|
LambdaSink progressSink([&](std::string_view data) {
|
||||||
total += data.size();
|
auto total(_total.lock());
|
||||||
act.progress(total, info->narSize);
|
*total += data.size();
|
||||||
|
act.progress(*total, info->narSize);
|
||||||
});
|
});
|
||||||
TeeSink tee { sink, progressSink };
|
TeeSink tee { sink, progressSink };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue