From 4ef06e6443c425428e8b11a8d1fc1c71efbaf1f3 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 16 Feb 2023 21:23:16 -0700 Subject: [PATCH] sync-ebooks: Don't rename repository if target directory already exists --- scripts/sync-ebooks | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/sync-ebooks b/scripts/sync-ebooks index 48b619a3..0932a141 100755 --- a/scripts/sync-ebooks +++ b/scripts/sync-ebooks @@ -255,9 +255,15 @@ printf "%s\n" "${repoUrls}" | while IFS= read -r repoUrl; do # if for some reason the repository name isn't the same as the identifier (they are identical # 99% of the time), rename the directory to be the identifier name; not sure why this is done, either if [ "${repoName}" != "${properName}" ]; then - if [ "${verbosity}" -gt 0 ]; then - printf "Moving %s to %s\n" "${repoName}" "${properName}" + if [ -d "${properName}" ]; then + if [ "${verbosity}" -gt 0 ]; then + printf "Not moving %s to %s: directory exists\n" "${repoName}" "${properName}" + fi + else + if [ "${verbosity}" -gt 0 ]; then + printf "Moving %s to %s\n" "${repoName}" "${properName}" + fi + mv "${repoName}" "${properName}" fi - mv "${repoName}" "${properName}" fi done