aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/download.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/download.cc')
-rw-r--r--src/libstore/download.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 61e88c5c1..38faa1bfd 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -818,6 +818,7 @@ CachedDownloadResult Downloader::downloadCached(
CachedDownloadResult result;
result.storePath = expectedStorePath;
result.path = store->toRealPath(expectedStorePath);
+ assert(!request.getLastModified); // FIXME
return result;
}
}
@@ -902,6 +903,8 @@ CachedDownloadResult Downloader::downloadCached(
store->addTempRoot(unpackedStorePath);
if (!store->isValidPath(unpackedStorePath))
unpackedStorePath = "";
+ else
+ result.lastModified = lstat(unpackedLink).st_mtime;
}
if (unpackedStorePath.empty()) {
printInfo("unpacking '%s'...", url);
@@ -912,9 +915,13 @@ CachedDownloadResult Downloader::downloadCached(
if (members.size() != 1)
throw nix::Error("tarball '%s' contains an unexpected number of top-level files", url);
auto topDir = tmpDir + "/" + members.begin()->name;
+ result.lastModified = lstat(topDir).st_mtime;
unpackedStorePath = store->addToStore(name, topDir, true, htSHA256, defaultPathFilter, NoRepair);
}
- replaceSymlink(unpackedStorePath, unpackedLink);
+ // Store the last-modified date of the tarball in the symlink
+ // mtime. This saves us from having to store it somewhere
+ // else.
+ replaceSymlink(unpackedStorePath, unpackedLink, result.lastModified);
storePath = unpackedStorePath;
}
@@ -927,6 +934,9 @@ CachedDownloadResult Downloader::downloadCached(
url, request.expectedHash.to_string(), gotHash.to_string());
}
+ if (request.gcRoot)
+ store->addIndirectRoot(fileLink);
+
result.storePath = storePath;
result.path = store->toRealPath(storePath);
return result;