From 3b2ad49924dbb6142f9fc0ed8d465b37dbf6afef Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 11 Nov 2016 04:21:16 +0300 Subject: don't delete obsolete files which are not symlinks --- update.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/update.sh b/update.sh index a1467fc..ea2519f 100755 --- a/update.sh +++ b/update.sh @@ -287,18 +287,20 @@ delete_obsolete_entries() { if [ ! -e "$shared_path" ]; then dump " missing source file: $shared_path" >&2 - if [ -z "${dry_run+x}" ]; then - rm -f -- "$symlink_path" - else + if [ ! -L "$symlink_path" ]; then + dump " not a symlink, so won't delete: $symlink_path" + elif [ -n "${dry_run+x}" ]; then dump ' won'"'"'t delete an obsolete symlink, because it'"'"'s a dry run' - fi + else + rm -f -- "$symlink_path" - unset -v 'database[$entry]' + local symlink_dir + symlink_dir="$( dirname -- "$symlink_path" )" - local symlink_dir - symlink_dir="$( dirname -- "$symlink_path" )" + delete_obsolete_dirs "$symlink_var_dir" "$symlink_dir" || true + fi - delete_obsolete_dirs "$symlink_var_dir" "$symlink_dir" || true + unset -v 'database[$entry]' continue fi -- cgit v1.2.3