about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-02T02·34-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-02T02·34-0400
commit01d56c1eeca497de247413a64a544605c53d9d41 (patch)
tree11f42a290a031e6a23781c379f7b34fb6bbc0ff3 /src/libutil
parent967d066d8e452e59507ebae7585d6f34a4edf687 (diff)
Drop the block count in the garbage collector
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc21
-rw-r--r--src/libutil/util.hh3
2 files changed, 9 insertions, 15 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 689fc543af31..9d8e4afed37d 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -297,8 +297,7 @@ void computePathSize(const Path & path,
 }
 
 
-static void _deletePath(const Path & path, unsigned long long & bytesFreed,
-    unsigned long long & blocksFreed)
+static void _deletePath(const Path & path, unsigned long long & bytesFreed)
 {
     checkInterrupt();
 
@@ -308,10 +307,8 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed,
 
     if (S_ISDIR(st.st_mode) || S_ISREG(st.st_mode)) makeMutable(path);
 
-    if (!S_ISDIR(st.st_mode) && st.st_nlink == 1) {
-        bytesFreed += st.st_size;
-        blocksFreed += st.st_blocks;
-    }
+    if (!S_ISDIR(st.st_mode) && st.st_nlink == 1)
+        bytesFreed += st.st_blocks * 512;
 
     if (S_ISDIR(st.st_mode)) {
 	Strings names = readDirectory(path);
@@ -323,7 +320,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed,
 	}
 
 	for (Strings::iterator i = names.begin(); i != names.end(); ++i)
-            _deletePath(path + "/" + *i, bytesFreed, blocksFreed);
+            _deletePath(path + "/" + *i, bytesFreed);
     }
 
     if (remove(path.c_str()) == -1)
@@ -333,19 +330,17 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed,
 
 void deletePath(const Path & path)
 {
-    unsigned long long dummy1, dummy2;
-    deletePath(path, dummy1, dummy2);
+    unsigned long long dummy;
+    deletePath(path, dummy);
 }
 
 
-void deletePath(const Path & path, unsigned long long & bytesFreed,
-    unsigned long long & blocksFreed)
+void deletePath(const Path & path, unsigned long long & bytesFreed)
 {
     startNest(nest, lvlDebug,
         format("recursively deleting path `%1%'") % path);
     bytesFreed = 0;
-    blocksFreed = 0;
-    _deletePath(path, bytesFreed, blocksFreed);
+    _deletePath(path, bytesFreed);
 }
 
 
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 9b8656f70485..edb7c0fa6c60 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -80,8 +80,7 @@ void computePathSize(const Path & path,
    returns the number of bytes and blocks freed. */
 void deletePath(const Path & path);
 
-void deletePath(const Path & path, unsigned long long & bytesFreed,
-    unsigned long long & blocksFreed);
+void deletePath(const Path & path, unsigned long long & bytesFreed);
 
 /* Make a path read-only recursively. */
 void makePathReadOnly(const Path & path);