deletePath(): Succeed if path doesn't exist

Also makes it robust against concurrent deletions.
This commit is contained in:
Eelco Dolstra 2016-02-24 17:44:12 +01:00
parent 28e7e29abd
commit 152b1d6bf9
5 changed files with 23 additions and 23 deletions

View file

@ -1365,7 +1365,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name,
if (repair || !isValidPath(dstPath)) {
if (pathExists(dstPath)) deletePath(dstPath);
deletePath(dstPath);
if (recursive) {
StringSource source(dump);
@ -1434,7 +1434,7 @@ Path LocalStore::addTextToStore(const string & name, const string & s,
if (repair || !isValidPath(dstPath)) {
if (pathExists(dstPath)) deletePath(dstPath);
deletePath(dstPath);
writeFile(dstPath, s);
@ -1659,7 +1659,7 @@ Path LocalStore::importPath(bool requireSignature, Source & source)
if (!isValidPath(dstPath)) {
if (pathExists(dstPath)) deletePath(dstPath);
deletePath(dstPath);
if (rename(unpacked.c_str(), dstPath.c_str()) == -1)
throw SysError(format("cannot move %1% to %2%")