feat: remove unnecessary test -n

This commit is contained in:
ttionya
2021-02-28 17:38:59 +08:00
parent 76077b6b5b
commit 8f4d8620b6
2 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ if [[ "$1" == "mail" ]]; then
MAIL_SMTP_ENABLE="TRUE" MAIL_SMTP_ENABLE="TRUE"
MAIL_DEBUG="TRUE" MAIL_DEBUG="TRUE"
if [[ -n "$2" ]]; then if [[ "$2" ]]; then
MAIL_TO="$2" MAIL_TO="$2"
fi fi
+11 -11
View File
@@ -19,7 +19,7 @@ function restore_zip() {
local FIND_FILE_CONFIG local FIND_FILE_CONFIG
local FIND_FILE_ATTACHMENTS local FIND_FILE_ATTACHMENTS
if [[ -n "${ZIP_PASSWORD}" ]]; then if [[ "${ZIP_PASSWORD}" ]]; then
7z e -aoa -p"${ZIP_PASSWORD}" -o"${RESTORE_EXTRACT_DIR}" "${RESTORE_FILE_ZIP}" 7z e -aoa -p"${ZIP_PASSWORD}" -o"${RESTORE_EXTRACT_DIR}" "${RESTORE_FILE_ZIP}"
else else
7z e -aoa -o"${RESTORE_EXTRACT_DIR}" "${RESTORE_FILE_ZIP}" 7z e -aoa -o"${RESTORE_EXTRACT_DIR}" "${RESTORE_FILE_ZIP}"
@@ -35,21 +35,21 @@ function restore_zip() {
# get restore db file # get restore db file
RESTORE_FILE_DB="" RESTORE_FILE_DB=""
FIND_FILE_DB="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/db.*.sqlite3)" )" FIND_FILE_DB="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/db.*.sqlite3)" )"
if [[ -n "${FIND_FILE_DB}" ]]; then if [[ "${FIND_FILE_DB}" ]]; then
RESTORE_FILE_DB="extract/${FIND_FILE_DB}" RESTORE_FILE_DB="extract/${FIND_FILE_DB}"
fi fi
# get restore config file # get restore config file
RESTORE_FILE_CONFIG="" RESTORE_FILE_CONFIG=""
FIND_FILE_CONFIG="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/config.*.json)" )" FIND_FILE_CONFIG="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/config.*.json)" )"
if [[ -n "${FIND_FILE_CONFIG}" ]]; then if [[ "${FIND_FILE_CONFIG}" ]]; then
RESTORE_FILE_CONFIG="extract/${FIND_FILE_CONFIG}" RESTORE_FILE_CONFIG="extract/${FIND_FILE_CONFIG}"
fi fi
# get restore attachments file # get restore attachments file
RESTORE_FILE_ATTACHMENTS="" RESTORE_FILE_ATTACHMENTS=""
FIND_FILE_ATTACHMENTS="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/attachments.*.tar)" )" FIND_FILE_ATTACHMENTS="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/attachments.*.tar)" )"
if [[ -n "${FIND_FILE_ATTACHMENTS}" ]]; then if [[ "${FIND_FILE_ATTACHMENTS}" ]]; then
RESTORE_FILE_ATTACHMENTS="extract/${FIND_FILE_ATTACHMENTS}" RESTORE_FILE_ATTACHMENTS="extract/${FIND_FILE_ATTACHMENTS}"
fi fi
@@ -102,7 +102,7 @@ function check_restore_file_exist() {
} }
function restore_file() { function restore_file() {
if [[ -n "${RESTORE_FILE_ZIP}" ]]; then if [[ "${RESTORE_FILE_ZIP}" ]]; then
check_restore_file_exist "${RESTORE_FILE_ZIP}" "--zip-file" check_restore_file_exist "${RESTORE_FILE_ZIP}" "--zip-file"
RESTORE_FILE_ZIP="${RESTORE_DIR}/${RESTORE_FILE_ZIP}" RESTORE_FILE_ZIP="${RESTORE_DIR}/${RESTORE_FILE_ZIP}"
@@ -111,31 +111,31 @@ function restore_file() {
restore_zip restore_zip
clear_extract_dir clear_extract_dir
else else
if [[ -n "${RESTORE_FILE_DB}" ]]; then if [[ "${RESTORE_FILE_DB}" ]]; then
check_restore_file_exist "${RESTORE_FILE_DB}" "--db-file" check_restore_file_exist "${RESTORE_FILE_DB}" "--db-file"
RESTORE_FILE_DB="${RESTORE_DIR}/${RESTORE_FILE_DB}" RESTORE_FILE_DB="${RESTORE_DIR}/${RESTORE_FILE_DB}"
fi fi
if [[ -n "${RESTORE_FILE_CONFIG}" ]]; then if [[ "${RESTORE_FILE_CONFIG}" ]]; then
check_restore_file_exist "${RESTORE_FILE_CONFIG}" "--config-file" check_restore_file_exist "${RESTORE_FILE_CONFIG}" "--config-file"
RESTORE_FILE_CONFIG="${RESTORE_DIR}/${RESTORE_FILE_CONFIG}" RESTORE_FILE_CONFIG="${RESTORE_DIR}/${RESTORE_FILE_CONFIG}"
fi fi
if [[ -n "${RESTORE_FILE_ATTACHMENTS}" ]]; then if [[ "${RESTORE_FILE_ATTACHMENTS}" ]]; then
check_restore_file_exist "${RESTORE_FILE_ATTACHMENTS}" "--attachments-file" check_restore_file_exist "${RESTORE_FILE_ATTACHMENTS}" "--attachments-file"
RESTORE_FILE_ATTACHMENTS="${RESTORE_DIR}/${RESTORE_FILE_ATTACHMENTS}" RESTORE_FILE_ATTACHMENTS="${RESTORE_DIR}/${RESTORE_FILE_ATTACHMENTS}"
fi fi
if [[ -n "${RESTORE_FILE_DB}" ]]; then if [[ "${RESTORE_FILE_DB}" ]]; then
restore_db restore_db
fi fi
if [[ -n "${RESTORE_FILE_CONFIG}" ]]; then if [[ "${RESTORE_FILE_CONFIG}" ]]; then
restore_config restore_config
fi fi
if [[ -n "${RESTORE_FILE_ATTACHMENTS}" ]]; then if [[ "${RESTORE_FILE_ATTACHMENTS}" ]]; then
restore_attachments restore_attachments
fi fi
fi fi