From d01cf1c9b0d9dacd8f1c55ed36449778f6225b0d Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Sun, 23 May 2021 14:42:06 +1200 Subject: [PATCH] failure to remove rundir should not abort the jobrunner kj::Directory::remove will throw if it fails to remove some files, e.g. in case of insufficient permissions. Catch this and move right along. resolves #156 --- src/laminar.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/laminar.cpp b/src/laminar.cpp index ca1d858..41c6459 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -774,7 +774,14 @@ void Laminar::handleRunFinished(Run * r) { // anyway so hence this (admittedly debatable) optimization. if(!fsHome->exists(d)) break; - fsHome->remove(d); + // must use a try/catch because remove will throw if deletion fails. Using + // tryRemove does not help because it still throws an exception for some + // errors such as EACCES + try { + fsHome->remove(d); + } catch(kj::Exception& e) { + LLOG(ERROR, "Could not remove directory", e.getDescription()); + } } fsHome->symlink(kj::Path{"archive", r->name, "latest"}, std::to_string(r->build), kj::WriteMode::CREATE|kj::WriteMode::MODIFY);