From a9f0449be9a12ffd6842671eee49fde40b3196f3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 13 Feb 2018 10:48:25 +0100 Subject: bin/get-package-updates: cleanup db in trap on exit --- bin/get-package-updates | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/get-package-updates b/bin/get-package-updates index 465f896..abd380e 100755 --- a/bin/get-package-updates +++ b/bin/get-package-updates @@ -135,8 +135,20 @@ delete_package() { } # create tmp_dir and trap +clean_up() { + rm -rf --one-file-system "${tmp_dir}" + # shellcheck disable=SC2016 + { + printf 'DELETE FROM `binary_packages`' + printf ' WHERE `binary_packages`.`repository`=(' + printf 'SELECT `repositories`.`id` FROM `repositories`' + printf ' WHERE `repositories`.`name`="to-be-decided"' + printf ');\n' + } | \ + ${mysql_command} +} tmp_dir=$(mktemp -d 'tmp.get-package-updates.XXXXXXXXXX' --tmpdir) -trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT +trap 'clean_up' EXIT # Update git repositories (official packages, community packages and the repository of package customizations). -- cgit v1.2.3-70-g09d2