diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-06-01 20:19:12 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-06-01 20:19:12 +0000 |
commit | d02ef648ee5d5b775788213d1963ae3836a07e14 (patch) | |
tree | 33218d642857b7fd21bf581c6a0e5da4fc16fb31 /tcwg-cleanup-stale-workspaces.sh | |
parent | a03dc654e077577cea796e3b9d86db210ccfc662 (diff) |
tcwg-cleanup-stale-workspaces.sh: Make a bit more robust to races
... with other builds.
Change-Id: I2f606839dfbbe4b15c5cb1bec1a4ad7f1747de77
Diffstat (limited to 'tcwg-cleanup-stale-workspaces.sh')
-rwxr-xr-x | tcwg-cleanup-stale-workspaces.sh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tcwg-cleanup-stale-workspaces.sh b/tcwg-cleanup-stale-workspaces.sh index d64ed5bc..b601958a 100755 --- a/tcwg-cleanup-stale-workspaces.sh +++ b/tcwg-cleanup-stale-workspaces.sh @@ -51,7 +51,12 @@ IFS=$SAVEIFS rm_dirs=() for dir in "${dirs[@]}"; do if [ x"$(find "$dir" -mtime -$days | wc -l)" = x"0" ]; then - rm_dirs=("${rm_dirs[@]}" "$dir") + if ! $dry_run; then + # Move directory out of the way as quickly as possible to minimize + # chance of parallel build starting in this directory. + mv "$dir" "$dir.bak" + fi + rm_dirs=("${rm_dirs[@]}" "$dir.bak") fi done |