mirror of
https://github.com/NixOS/nix
synced 2025-06-26 20:01:15 +02:00
* `nix-store --gc' prints out the number of bytes freed on stdout
(even when it is interrupted by a signal).
This commit is contained in:
parent
5144f750c4
commit
530b27df1e
7 changed files with 45 additions and 11 deletions
|
@ -194,7 +194,7 @@ void writeFile(const Path & path, const string & s)
|
|||
}
|
||||
|
||||
|
||||
static void _deletePath(const Path & path)
|
||||
static void _deletePath(const Path & path, unsigned long long & bytesFreed)
|
||||
{
|
||||
checkInterrupt();
|
||||
|
||||
|
@ -204,6 +204,8 @@ static void _deletePath(const Path & path)
|
|||
if (lstat(path.c_str(), &st))
|
||||
throw SysError(format("getting attributes of path `%1%'") % path);
|
||||
|
||||
bytesFreed += st.st_size;
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
Strings names = readDirectory(path);
|
||||
|
||||
|
@ -214,7 +216,7 @@ static void _deletePath(const Path & path)
|
|||
}
|
||||
|
||||
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
||||
_deletePath(path + "/" + *i);
|
||||
_deletePath(path + "/" + *i, bytesFreed);
|
||||
}
|
||||
|
||||
if (remove(path.c_str()) == -1)
|
||||
|
@ -223,10 +225,18 @@ static void _deletePath(const Path & path)
|
|||
|
||||
|
||||
void deletePath(const Path & path)
|
||||
{
|
||||
unsigned long long dummy;
|
||||
deletePath(path, dummy);
|
||||
}
|
||||
|
||||
|
||||
void deletePath(const Path & path, unsigned long long & bytesFreed)
|
||||
{
|
||||
startNest(nest, lvlDebug,
|
||||
format("recursively deleting path `%1%'") % path);
|
||||
_deletePath(path);
|
||||
bytesFreed = 0;
|
||||
_deletePath(path, bytesFreed);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue