aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/store.cc')
-rw-r--r--src/libstore/store.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 9c68c3392..25e2d6e36 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -76,11 +76,25 @@ static void upgradeStore07();
static void upgradeStore09();
-void openDB()
+void openDB(bool reserveSpace)
{
if (readOnlyMode) return;
try {
+ Path reservedPath = nixDBPath + "/reserved";
+ off_t reservedSize = 1024 * 1024;
+ if (reserveSpace) {
+ struct stat st;
+ if (stat(reservedPath.c_str(), &st) == -1 ||
+ st.st_size != reservedSize)
+ writeFile(reservedPath, string(1024 * 1024, 'X'));
+ }
+ else
+ deletePath(reservedPath);
+ } catch (SysError & e) { /* don't care about errors */
+ }
+
+ try {
nixDB.open(nixDBPath);
} catch (DbNoPermission & e) {
printMsg(lvlTalkative, "cannot access Nix database; continuing anyway");