1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 16:51:15 +02:00

Implement caching of fetchurl/fetchTarball results

ETags are used to prevent redownloading unchanged files.
This commit is contained in:
Eelco Dolstra 2015-04-09 11:42:04 +02:00
parent 1711679ea5
commit 60340ce3e2
4 changed files with 152 additions and 29 deletions

View file

@ -413,6 +413,17 @@ void createSymlink(const Path & target, const Path & link)
}
void replaceSymlink(const Path & target, const Path & link)
{
Path tmp = canonPath(dirOf(link) + "/.new_" + baseNameOf(link));
createSymlink(target, tmp);
if (rename(tmp.c_str(), link.c_str()) != 0)
throw SysError(format("renaming %1% to %2%") % tmp % link);
}
LogType logType = ltPretty;
Verbosity verbosity = lvlInfo;
@ -1076,6 +1087,15 @@ string chomp(const string & s)
}
string trim(const string & s, const string & whitespace)
{
auto i = s.find_first_not_of(whitespace);
if (i == string::npos) return "";
auto j = s.find_last_not_of(whitespace);
return string(s, i, j == string::npos ? j : j - i + 1);
}
string statusToString(int status)
{
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {