From 7a02d954186d6ba1ea41d9917d63f9fab84736b3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 21 Nov 2003 16:05:19 +0000 Subject: * Remove lock files after building. --- src/libstore/pathlocks.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/libstore/pathlocks.cc') diff --git a/src/libstore/pathlocks.cc b/src/libstore/pathlocks.cc index 3ecbbbcbafd5..c057edce118b 100644 --- a/src/libstore/pathlocks.cc +++ b/src/libstore/pathlocks.cc @@ -43,6 +43,7 @@ static StringSet lockedPaths; /* !!! not thread-safe */ PathLocks::PathLocks(const PathSet & _paths) + : deletePaths(false) { /* Note that `fds' is built incrementally so that the destructor will only release those locks that we have already acquired. */ @@ -85,6 +86,17 @@ PathLocks::~PathLocks() for (list::iterator i = fds.begin(); i != fds.end(); i++) close(*i); - for (Paths::iterator i = paths.begin(); i != paths.end(); i++) + for (Paths::iterator i = paths.begin(); i != paths.end(); i++) { + if (deletePaths) + /* This is not safe in general! */ + if (unlink(i->c_str()) != 0) + throw SysError(format("removing lock file `%1%'") % *i); lockedPaths.erase(*i); + } +} + + +void PathLocks::setDeletion(bool deletePaths) +{ + this->deletePaths = deletePaths; } -- cgit 1.4.1