mirror of
https://github.com/NixOS/nix
synced 2025-07-03 06:11:46 +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
|
@ -303,9 +303,11 @@ static Paths topoSort(const PathSet & paths)
|
|||
}
|
||||
|
||||
|
||||
void collectGarbage(GCAction action, PathSet & result)
|
||||
void collectGarbage(GCAction action, PathSet & result,
|
||||
unsigned long long & bytesFreed)
|
||||
{
|
||||
result.clear();
|
||||
bytesFreed = 0;
|
||||
|
||||
bool gcKeepOutputs =
|
||||
queryBoolSetting("gc-keep-outputs", false);
|
||||
|
@ -452,7 +454,9 @@ void collectGarbage(GCAction action, PathSet & result)
|
|||
printMsg(lvlInfo, format("deleting `%1%'") % *i);
|
||||
|
||||
/* Okay, it's safe to delete. */
|
||||
deleteFromStore(*i);
|
||||
unsigned long long freed;
|
||||
deleteFromStore(*i, freed);
|
||||
bytesFreed += freed;
|
||||
|
||||
if (fdLock != -1)
|
||||
/* Write token to stale (deleted) lock file. */
|
||||
|
|
|
@ -19,7 +19,8 @@ typedef enum {
|
|||
closure of) the roots. If `action' is `gcReturnDead', return the
|
||||
set of paths not reachable from the roots. If `action' is
|
||||
`gcDeleteDead', actually delete the latter set. */
|
||||
void collectGarbage(GCAction action, PathSet & result);
|
||||
void collectGarbage(GCAction action, PathSet & result,
|
||||
unsigned long long & bytesFreed);
|
||||
|
||||
/* Register a temporary GC root. This root will automatically
|
||||
disappear when this process exits. WARNING: this function should
|
||||
|
|
|
@ -746,8 +746,9 @@ Path addTextToStore(const string & suffix, const string & s,
|
|||
}
|
||||
|
||||
|
||||
void deleteFromStore(const Path & _path)
|
||||
void deleteFromStore(const Path & _path, unsigned long long & bytesFreed)
|
||||
{
|
||||
bytesFreed = 0;
|
||||
Path path(canonPath(_path));
|
||||
|
||||
assertStorePath(path);
|
||||
|
@ -763,7 +764,7 @@ void deleteFromStore(const Path & _path)
|
|||
}
|
||||
txn.commit();
|
||||
|
||||
deletePath(path);
|
||||
deletePath(path, bytesFreed);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ Path addTextToStore(const string & suffix, const string & s,
|
|||
const PathSet & references);
|
||||
|
||||
/* Delete a value from the nixStore directory. */
|
||||
void deleteFromStore(const Path & path);
|
||||
void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
|
||||
|
||||
void verifyStore(bool checkContents);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue