diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-07-11T21·11+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-07-11T21·21+0200 |
commit | 8e8caf7f3e535d4e397f422f6c0effd81f497305 (patch) | |
tree | f463df5da7f5404c61b7a6c15a06ddba3e95c2bc /src | |
parent | 9c00fa417923087be00e7ba6f3da6045692b41a1 (diff) |
fetchTarball: Prevent concurrent downloads of the same file
Fixes #849.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/download.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 15eb68c69ea4..ac9a2b8fede3 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -6,6 +6,7 @@ #include "archive.hh" #include "s3.hh" #include "compression.hh" +#include "pathlocks.hh" #ifdef ENABLE_S3 #include <aws/core/client/ClientConfiguration.h> @@ -586,6 +587,8 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa Path dataFile = cacheDir + "/" + urlHash + ".info"; Path fileLink = cacheDir + "/" + urlHash + "-file"; + PathLocks lock({fileLink}, fmt("waiting for lock on ‘%1%’...", fileLink)); + Path storePath; string expectedETag; @@ -647,6 +650,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa if (unpack) { Path unpackedLink = cacheDir + "/" + baseNameOf(storePath) + "-unpacked"; + PathLocks lock2({unpackedLink}, fmt("waiting for lock on ‘%1%’...", unpackedLink)); Path unpackedStorePath; if (pathExists(unpackedLink)) { unpackedStorePath = readLink(unpackedLink); |