about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-09T00·26+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-09T00·26+0000
commit5f681988f210dd8edbb0d13da7d00e1c0e2a1769 (patch)
treeb6668269225fd8098c26463307c5dea096339f0d /src/libstore/build.cc
parentfa333031464ca394317a55a0e7c6b773f068aae2 (diff)
* Use deletePathWrapped() in more places.
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index a86fa0f947a0..14388a7b56dc 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -531,14 +531,28 @@ void getOwnership(const Path & path)
 }
 
 
-static void deletePathWrapped(const Path & path)
-{
-    /* 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);
+void deletePathWrapped(const Path & path,
+    unsigned long long & bytesFreed)
+{
+    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);
 }