about summary refs log tree commit diff
path: root/src/libnix/store.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnix/store.cc')
-rw-r--r--src/libnix/store.cc4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/libnix/store.cc b/src/libnix/store.cc
index 2d223313b612..c40d9efbebcf 100644
--- a/src/libnix/store.cc
+++ b/src/libnix/store.cc
@@ -304,14 +304,12 @@ void addTextToStore(const Path & dstPath, const string & s)
 
         /* !!! locking? -> parallel writes are probably idempotent */
 
-        int fd = open(dstPath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666);
+        AutoCloseFD fd = open(dstPath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666);
         if (fd == -1) throw SysError(format("creating store file `%1%'") % dstPath);
 
         if (write(fd, s.c_str(), s.size()) != (ssize_t) s.size())
             throw SysError(format("writing store file `%1%'") % dstPath);
 
-        close(fd); /* !!! close on exception */
-
         Transaction txn(nixDB);
         registerValidPath(txn, dstPath);
         txn.commit();