about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-03-26T21·18+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-03-26T21·18+0200
commit446b827baedde7ba3ca44f9ef51940e28e13fb87 (patch)
treea1b84536a112dc1114eb0d80772811e916a54e83
parent480dda0e42e69be47434be5bce95be950bdb59b5 (diff)
Mac OS X fix
-rw-r--r--src/libstore/gc.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index 56cb97d8770c..a21ccc9d299c 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -532,6 +532,9 @@ bool LocalStore::tryToDelete(GCState & state, const Path & path)
                 state.bytesInvalidated += queryPathInfo(path).narSize;
                 invalidatePathChecked(path);
                 makeMutable(path.c_str());
+                // Mac OS X cannot rename directories if they are read-only.
+                if (chmod(path.c_str(), st.st_mode | S_IWUSR) == -1)
+                    throw SysError(format("making `%1%' writable") % path);
                 Path tmp = (format("%1%-gc-%2%") % path % getpid()).str();
                 if (rename(path.c_str(), tmp.c_str()))
                     throw SysError(format("unable to rename `%1%' to `%2%'") % path % tmp);