mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
fetchTarball: Prevent concurrent downloads of the same file
Fixes #849.
(cherry picked from commit 8e8caf7f3e)
This commit is contained in:
parent
7577d35895
commit
b59788fc48
1 changed files with 4 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "globals.hh"
|
||||
#include "hash.hh"
|
||||
#include "store-api.hh"
|
||||
#include "pathlocks.hh"
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
|
|
@ -203,6 +204,8 @@ Path downloadFileCached(const string & url, bool unpack, string name)
|
|||
Path dataFile = cacheDir + "/" + urlHash + ".info";
|
||||
Path fileLink = cacheDir + "/" + urlHash + "-file";
|
||||
|
||||
PathLocks lock({fileLink}, fmt("waiting for lock on ‘%1%’...", fileLink));
|
||||
|
||||
Path storePath;
|
||||
|
||||
string expectedETag;
|
||||
|
|
@ -255,6 +258,7 @@ Path downloadFileCached(const string & url, bool unpack, string name)
|
|||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue