diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-06-21T11·08+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-06-21T11·08+0000 |
commit | 3e5e0faf9cf93c01fb621774c0c3c50ce51bdd91 (patch) | |
tree | 764e13cd688ec70d04e5fd808e3028fa58917854 /src | |
parent | bf87cc44b4484df74388b526c89884fea166ab7f (diff) |
* Okay, putting a lock on the temporary directory used by importPath()
doesn't work because the garbage collector doesn't actually look at locks. So r22253 was stupid. Use addTempRoot() instead. Also, locking the temporary directory in exportPath() was silly because it isn't even in the store.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/local-store.cc | 24 | ||||
-rw-r--r-- | src/libstore/local-store.hh | 2 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index c7530f1b1bae..6f3d9efa8625 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1036,8 +1036,6 @@ void LocalStore::exportPath(const Path & path, bool sign, writeInt(1, hashAndWriteSink); Path tmpDir = createTempDir(); - PathLocks tmpDirLock(singleton<PathSet, Path>(tmpDir)); - tmpDirLock.setDeletion(true); AutoDelete delTmp(tmpDir); Path hashFile = tmpDir + "/hash"; writeFile(hashFile, printHash(hash)); @@ -1079,6 +1077,22 @@ struct HashAndReadSource : Source }; +/* Create a temporary directory in the store that won't be + garbage-collected. */ +Path LocalStore::createTempDirInStore() +{ + Path tmpDir; + do { + /* There is a slight possibility that `tmpDir' gets deleted by + the GC between createTempDir() and addTempRoot(), so repeat + until `tmpDir' exists. */ + tmpDir = createTempDir(nixStore); + addTempRoot(tmpDir); + } while (!pathExists(tmpDir)); + return tmpDir; +} + + Path LocalStore::importPath(bool requireSignature, Source & source) { HashAndReadSource hashAndReadSource(source); @@ -1086,10 +1100,8 @@ Path LocalStore::importPath(bool requireSignature, Source & source) /* We don't yet know what store path this archive contains (the store path follows the archive data proper), and besides, we don't know yet whether the signature is valid. */ - Path tmpDir = createTempDir(nixStore); - PathLocks tmpDirLock(singleton<PathSet, Path>(tmpDir)); - tmpDirLock.setDeletion(true); - AutoDelete delTmp(tmpDir); /* !!! could be GC'ed! */ + Path tmpDir = createTempDirInStore(); + AutoDelete delTmp(tmpDir); Path unpacked = tmpDir + "/unpacked"; restorePath(unpacked, hashAndReadSource); diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index c1e0e335f225..3ae964f0544d 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -246,6 +246,8 @@ private: void startSubstituter(const Path & substituter, RunningSubstituter & runningSubstituter); + + Path createTempDirInStore(); }; |