Compare commits
2 Commits
tweak/nets
...
fix/empty_
Author | SHA1 | Date | |
---|---|---|---|
|
304b2d05b1 | ||
|
1c28ad6f00 |
28
gravity.sh
28
gravity.sh
@@ -85,19 +85,27 @@ generate_gravity_database() {
|
|||||||
|
|
||||||
# Copy data from old to new database file and swap them
|
# Copy data from old to new database file and swap them
|
||||||
gravity_swap_databases() {
|
gravity_swap_databases() {
|
||||||
local str copyGravity
|
local str copyGravity enabled_adlists
|
||||||
str="Building tree"
|
|
||||||
echo -ne " ${INFO} ${str}..."
|
|
||||||
|
|
||||||
# The index is intentionally not UNIQUE as poor quality adlists may contain domains more than once
|
# Only build an index if there are enabled adlists
|
||||||
output=$( { sqlite3 "${gravityTEMPfile}" "CREATE INDEX idx_gravity ON gravity (domain, adlist_id);"; } 2>&1 )
|
enabled_adlists="$(sqlite3 "${gravityTEMPfile}" "Select Count(id) from adlist where enabled=1;")"
|
||||||
status="$?"
|
if [[ enabled_adlists -ge 1 ]]; then
|
||||||
|
str="Building tree"
|
||||||
|
echo -ne " ${INFO} ${str}..."
|
||||||
|
|
||||||
if [[ "${status}" -ne 0 ]]; then
|
# The index is intentionally not UNIQUE as poor quality adlists may contain domains more than once
|
||||||
echo -e "\\n ${CROSS} Unable to build gravity tree in ${gravityTEMPfile}\\n ${output}"
|
output=$( { sqlite3 "${gravityTEMPfile}" "CREATE INDEX idx_gravity ON gravity (domain, adlist_id);"; } 2>&1 )
|
||||||
return 1
|
status="$?"
|
||||||
|
|
||||||
|
if [[ "${status}" -ne 0 ]]; then
|
||||||
|
echo -e "\\n ${CROSS} Unable to build gravity tree in ${gravityTEMPfile}\\n ${output}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
|
else
|
||||||
|
str="No enabled adlists. Skipping building tree"
|
||||||
|
echo -ne " ${INFO} ${str}...\\n"
|
||||||
fi
|
fi
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
|
||||||
|
|
||||||
str="Swapping databases"
|
str="Swapping databases"
|
||||||
echo -ne " ${INFO} ${str}..."
|
echo -ne " ${INFO} ${str}..."
|
||||||
|
Reference in New Issue
Block a user