1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 23:08:07 +00:00

Invert logic to reduce nesting

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-05-01 21:12:22 +02:00
parent 008e88b84b
commit 0cfecd31d3
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD

View File

@ -149,32 +149,34 @@ database_table_from_file() {
# Migrate pre-v5.0 list files to database-based Pi-hole versions # Migrate pre-v5.0 list files to database-based Pi-hole versions
migrate_to_database() { migrate_to_database() {
# Create database file if not present # Create database file only if not present
if [ ! -e "${gravityDBfile}" ]; then if [ -e "${gravityDBfile}" ]; then
echo -e " ${INFO} Creating new gravity database" return 0
generate_gravity_database fi
# Migrate list files to new database echo -e " ${INFO} Creating new gravity database"
if [[ -e "${adListFile}" ]]; then generate_gravity_database
# Store adlists domains in database
echo -e " ${INFO} Migrating content of ${adListFile} into new database" # Migrate list files to new database
database_table_from_file "adlists" "${adListFile}" if [[ -e "${adListFile}" ]]; then
fi # Store adlists domains in database
if [[ -e "${blacklistFile}" ]]; then echo -e " ${INFO} Migrating content of ${adListFile} into new database"
# Store blacklisted domains in database database_table_from_file "adlists" "${adListFile}"
echo -e " ${INFO} Migrating content of ${blacklistFile} into new database" fi
database_table_from_file "blacklist" "${blacklistFile}" if [[ -e "${blacklistFile}" ]]; then
fi # Store blacklisted domains in database
if [[ -e "${whitelistFile}" ]]; then echo -e " ${INFO} Migrating content of ${blacklistFile} into new database"
# Store whitelisted domains in database database_table_from_file "blacklist" "${blacklistFile}"
echo -e " ${INFO} Migrating content of ${whitelistFile} into new database" fi
database_table_from_file "whitelist" "${whitelistFile}" if [[ -e "${whitelistFile}" ]]; then
fi # Store whitelisted domains in database
if [[ -e "${regexFile}" ]]; then echo -e " ${INFO} Migrating content of ${whitelistFile} into new database"
# Store regex domains in database database_table_from_file "whitelist" "${whitelistFile}"
echo -e " ${INFO} Migrating content of ${regexFile} into new database" fi
database_table_from_file "regex" "${regexFile}" if [[ -e "${regexFile}" ]]; then
fi # Store regex domains in database
echo -e " ${INFO} Migrating content of ${regexFile} into new database"
database_table_from_file "regex" "${regexFile}"
fi fi
} }