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

Delete dead code

We had multiple copies of some static functions after splitting out
`DerivationBuilder` by mistake.
This commit is contained in:
John Ericson 2025-04-28 11:19:36 -04:00
parent 3d39864b96
commit 46030181d4
2 changed files with 26 additions and 59 deletions

View file

@ -661,7 +661,32 @@ static void movePath(const Path & src, const Path & dst)
}
extern void replaceValidPath(const Path & storePath, const Path & tmpPath);
static void replaceValidPath(const Path & storePath, const Path & tmpPath)
{
/* We can't atomically replace storePath (the original) with
tmpPath (the replacement), so we have to move it out of the
way first. We'd better not be interrupted here, because if
we're repairing (say) Glibc, we end up with a broken system. */
Path oldPath = fmt("%1%.old-%2%-%3%", storePath, getpid(), rand());
if (pathExists(storePath))
movePath(storePath, oldPath);
try {
movePath(tmpPath, storePath);
} catch (...) {
try {
// attempt to recover
movePath(oldPath, storePath);
} catch (...) {
ignoreExceptionExceptInterrupt();
}
throw;
}
deletePath(oldPath);
}
bool DerivationBuilderImpl::cleanupDecideWhetherDiskFull()