From e2d038d4aaa8f0ce171ff5050b5a709813283a6b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 20 Jul 2017 20:59:57 +0200 Subject: bin/common-functions: accelerate delete_old_metadata --- bin/common-functions | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'bin/common-functions') diff --git a/bin/common-functions b/bin/common-functions index 2037853..08e73f2 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -226,12 +226,12 @@ delete_old_metadata() { cut -d' ' -f1,2,3 "${work_dir}/build-list" | \ sed 'p' - current_metadata_file="$(mktemp)" - trap 'rm -f "${current_metadata_file}"' EXIT + tmp_dir="$(mktemp -d)" + trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT echo "${current_metadata}" | \ sort -k1,1 > \ - "${current_metadata_file}" + "${tmp_dir}/current-metadata" # the newest of the following should stay: ( @@ -248,8 +248,17 @@ delete_old_metadata() { done ) | \ sort -u | \ - join -j 1 -o 2.2,2.3,2.1 - "${current_metadata_file}" | \ - sort -k3,3 | \ + join -j 1 -o 2.2,2.3,2.1 - "${tmp_dir}/current-metadata" | \ + sort -k3,3 > \ + "${tmp_dir}/find-newest-revisions" + + uniq -uf2 < \ + "${tmp_dir}/find-newest-revisions" | \ + awk '{print $3 " " $1 " " $2}' | \ + sed 'p' + + uniq -Df2 < \ + "${tmp_dir}/find-newest-revisions" | \ uniq --group=append -f2 | \ ( revs='' -- cgit v1.2.3-70-g09d2