about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-06-19T12·19+0200
committerEelco Dolstra <edolstra@gmail.com>2017-06-19T12·19+0200
commitb5bdfdef7320d74a98af1e53d64371e0cef2dbbe (patch)
tree52c0d65568a1b738d6a3c96f3130b1b4c6bf2520 /src/libstore
parenta10951de08117dd2f9e7117fdd6fa61a7b4e2b72 (diff)
macOS: Remove flags
In particular, UF_IMMUTABLE (uchg) needs to be cleared to allow the
path to be garbage-collected or optimised.

See https://github.com/NixOS/nixpkgs/issues/25819.
+       the file from being garbage-collected.
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/local-store.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index aa985ee53d97..74c74e672e25 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -400,6 +400,16 @@ static void canonicalisePathMetaData_(const Path & path, uid_t fromUid, InodesSe
 {
     checkInterrupt();
 
+#if __APPLE__
+    /* Remove flags, in particular UF_IMMUTABLE which would prevent
+       the file from being garbage-collected. FIXME: Use
+       setattrlist() to remove other attributes as well. */
+    if (lchflags(path.c_str(), 0)) {
+        if (errno != ENOTSUP)
+            throw SysError(format("clearing flags of path ‘%1%’") % path);
+    }
+#endif
+
     struct stat st;
     if (lstat(path.c_str(), &st))
         throw SysError(format("getting attributes of path ‘%1%’") % path);