Handle amount of disk space saved by hard linking being negative

Fixes bogus messages like "currently hard linking saves
17592186044416.00 MiB".
This commit is contained in:
Eelco Dolstra 2012-08-05 21:45:27 -04:00
parent b6c989b801
commit d025142f52
1 changed files with 2 additions and 2 deletions

View File

@ -580,7 +580,7 @@ void LocalStore::removeUnusedLinks(const GCState & state)
AutoCloseDir dir = opendir(linksDir.c_str());
if (!dir) throw SysError(format("opening directory `%1%'") % linksDir);
unsigned long long actualSize = 0, unsharedSize = 0;
long long actualSize = 0, unsharedSize = 0;
struct dirent * dirent;
while (errno = 0, dirent = readdir(dir)) {
@ -611,7 +611,7 @@ void LocalStore::removeUnusedLinks(const GCState & state)
struct stat st;
if (stat(linksDir.c_str(), &st) == -1)
throw SysError(format("statting `%1%'") % linksDir);
unsigned long long overhead = st.st_blocks * 512ULL;
long long overhead = st.st_blocks * 512ULL;
printMsg(lvlInfo, format("note: currently hard linking saves %.2f MiB")
% ((unsharedSize - actualSize - overhead) / (1024.0 * 1024.0)));