mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
* Use deletePathWrapped() in more places.
This commit is contained in:
parent
fa33303146
commit
5f681988f2
3 changed files with 30 additions and 21 deletions
|
@ -531,14 +531,28 @@ void getOwnership(const Path & path)
|
|||
}
|
||||
|
||||
|
||||
static void deletePathWrapped(const Path & path)
|
||||
void deletePathWrapped(const Path & path,
|
||||
unsigned long long & bytesFreed)
|
||||
{
|
||||
/* When using build users and we're not root, we may not have
|
||||
sufficient permission to delete the path. So use the setuid
|
||||
helper to change ownership to us. */
|
||||
if (haveBuildUsers() && !amPrivileged())
|
||||
getOwnership(path);
|
||||
deletePath(path);
|
||||
try {
|
||||
/* First try to delete it ourselves. */
|
||||
deletePath(path, bytesFreed);
|
||||
} catch (SysError & e) {
|
||||
/* If this failed due to a permission error, then try it with
|
||||
the setuid helper. */
|
||||
if (haveBuildUsers() && !amPrivileged()) {
|
||||
getOwnership(path);
|
||||
deletePath(path, bytesFreed);
|
||||
} else
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void deletePathWrapped(const Path & path)
|
||||
{
|
||||
unsigned long long dummy;
|
||||
deletePathWrapped(path, dummy);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue