Merge pull request #3893 from pi-hole/tweak/dontdelete

Exit installer if directory already exists when trying to clone one of our repos into it
This commit is contained in:
Adam Warner 2020-12-02 20:51:16 +00:00 committed by GitHub
commit d59eab9a6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -528,8 +528,10 @@ make_repo() {
printf " %b %s..." "${INFO}" "${str}" printf " %b %s..." "${INFO}" "${str}"
# If the directory exists, # If the directory exists,
if [[ -d "${directory}" ]]; then if [[ -d "${directory}" ]]; then
# delete everything in it so git can clone into it # Return with a 1 to exit the installer. We don't want to overwrite what could already be here in case it is not ours
rm -rf "${directory}" str="Unable to clone ${remoteRepo} into ${directory} : Directory already exists"
printf "%b %b%s\\n" "${OVER}" "${CROSS}" "${str}"
return 1
fi fi
# Clone the repo and return the return code from this command # Clone the repo and return the return code from this command
git clone -q --depth 20 "${remoteRepo}" "${directory}" &> /dev/null || return $? git clone -q --depth 20 "${remoteRepo}" "${directory}" &> /dev/null || return $?