mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 06:52:43 +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 "globals.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
#include "pathlocks.hh"
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
|
@ -203,6 +204,8 @@ Path downloadFileCached(const string & url, bool unpack, string name)
|
||||||
Path dataFile = cacheDir + "/" + urlHash + ".info";
|
Path dataFile = cacheDir + "/" + urlHash + ".info";
|
||||||
Path fileLink = cacheDir + "/" + urlHash + "-file";
|
Path fileLink = cacheDir + "/" + urlHash + "-file";
|
||||||
|
|
||||||
|
PathLocks lock({fileLink}, fmt("waiting for lock on ‘%1%’...", fileLink));
|
||||||
|
|
||||||
Path storePath;
|
Path storePath;
|
||||||
|
|
||||||
string expectedETag;
|
string expectedETag;
|
||||||
|
|
@ -255,6 +258,7 @@ Path downloadFileCached(const string & url, bool unpack, string name)
|
||||||
|
|
||||||
if (unpack) {
|
if (unpack) {
|
||||||
Path unpackedLink = cacheDir + "/" + baseNameOf(storePath) + "-unpacked";
|
Path unpackedLink = cacheDir + "/" + baseNameOf(storePath) + "-unpacked";
|
||||||
|
PathLocks lock2({unpackedLink}, fmt("waiting for lock on ‘%1%’...", unpackedLink));
|
||||||
Path unpackedStorePath;
|
Path unpackedStorePath;
|
||||||
if (pathExists(unpackedLink)) {
|
if (pathExists(unpackedLink)) {
|
||||||
unpackedStorePath = readLink(unpackedLink);
|
unpackedStorePath = readLink(unpackedLink);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue