about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07T15·54+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07T15·54+0000
commitec23ecc64d40b7f65585c23592db123127967221 (patch)
treead52f71354eccf862e1e7350f746d18ca0662a3c /src/libstore/local-store.cc
parenta0a43c32062f756b32feca7d04e89fb5d01767db (diff)
* In the garbage collector, if deleting a path fails, try to fix its
  ownership, then try again.

Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 143f093e5bac..237800209714 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -710,7 +710,18 @@ void deleteFromStore(const Path & _path, unsigned long long & bytesFreed)
     }
     txn.commit();
 
-    deletePath(path, 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;
+    }
 }