summaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-workspaces.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tcwg-cleanup-stale-workspaces.sh')
-rwxr-xr-xtcwg-cleanup-stale-workspaces.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/tcwg-cleanup-stale-workspaces.sh b/tcwg-cleanup-stale-workspaces.sh
index f2022ef2..9e16b0e4 100755
--- a/tcwg-cleanup-stale-workspaces.sh
+++ b/tcwg-cleanup-stale-workspaces.sh
@@ -56,7 +56,11 @@ for dir in "${dirs[@]}"; do
# chance of parallel build starting in this directory.
# Use a lock to avoid a race condition with a competing
# build.
- flock "$dir" mv "$dir" "$dir.bak"
+ flock "$dir" mv "$dir" "$dir.bak" || true
+ # On the off-chance that "$dir" was removed by another cleanup
+ # process, and above we have just created a lock file named
+ # "$dir" -- delete it.
+ rm -rf "$dir"
fi
rm_dirs=("${rm_dirs[@]}" "$dir.bak")
fi