From 7528ff747e340f6398a5cd565f2aaa41bd2ef9c6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 6 Jun 2018 12:13:11 +0200 Subject: buff-di-wuff: save files in dirs by checksum type --- buff-di-wuff | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/buff-di-wuff b/buff-di-wuff index e69510a..7e28b72 100755 --- a/buff-di-wuff +++ b/buff-di-wuff @@ -4,7 +4,10 @@ set -e cache_dir='/srv/arch-mirror/sources.archlinux32' -mkdir -p "${cache_dir}" +mkdir -p \ + "${cache_dir}/sha1sum" \ + "${cache_dir}/sha256sum" \ + "${cache_dir}/sha512sum" grep '^[^#]' "$(dirname "$0")/downloads.list" | \ while read -r url; do @@ -47,15 +50,15 @@ grep '^[^#]' "$(dirname "$0")/downloads.list" | \ sha1sum "${cache_dir}/tmp" | \ cut -d' ' -f1 ) - if [ ! -f "${cache_dir}/${sum512}" ]; then - mv "${cache_dir}/tmp" "${cache_dir}/${sum512}" + if [ ! -f "${cache_dir}/sha512sum/${sum512}" ]; then + mv "${cache_dir}/tmp" "${cache_dir}/sha512sum/${sum512}" else rm "${cache_dir}/tmp" fi - if [ ! -f "${cache_dir}/${sum256}" ]; then - ln "${cache_dir}/${sum512}" "${cache_dir}/${sum256}" + if [ ! -f "${cache_dir}/sha256sum/${sum256}" ]; then + ln "${cache_dir}/sha512sum/${sum512}" "${cache_dir}/sha256sum/${sum256}" fi - if [ ! -f "${cache_dir}/${sum1}" ]; then - ln "${cache_dir}/${sum512}" "${cache_dir}/${sum1}" + if [ ! -f "${cache_dir}/sha1sum/${sum1}" ]; then + ln "${cache_dir}/sha512sum/${sum512}" "${cache_dir}/sha1sum/${sum1}" fi done -- cgit v1.2.3-70-g09d2