fetchTarball: Prevent concurrent downloads of the same file
Fixes #849.
This commit is contained in:
parent
9c00fa4179
commit
8e8caf7f3e
1 changed files with 4 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include "archive.hh"
|
#include "archive.hh"
|
||||||
#include "s3.hh"
|
#include "s3.hh"
|
||||||
#include "compression.hh"
|
#include "compression.hh"
|
||||||
|
#include "pathlocks.hh"
|
||||||
|
|
||||||
#ifdef ENABLE_S3
|
#ifdef ENABLE_S3
|
||||||
#include <aws/core/client/ClientConfiguration.h>
|
#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 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;
|
||||||
|
@ -647,6 +650,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
|
||||||
|
|
||||||
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…
Reference in a new issue