feat: Detect MariaDB vs MySQL automatically; remove some optimizations causing locks; fix some checks
This commit is contained in:
parent
da644bf4c1
commit
b2427c2e75
1 changed files with 63 additions and 55 deletions
|
@ -4,7 +4,14 @@ url=friendica.example.net
|
||||||
user=friendica
|
user=friendica
|
||||||
group=www-data
|
group=www-data
|
||||||
fileperm=660
|
fileperm=660
|
||||||
dbengine=mariadb
|
dbengine=""
|
||||||
|
if [[ -n $(type mariadb) ]]; then
|
||||||
|
dbengine="mariadb"
|
||||||
|
elif [[ -n $(type mysql) ]]; then
|
||||||
|
dbengine="mysql"
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
db=friendica
|
db=friendica
|
||||||
folder=/var/www/friendica
|
folder=/var/www/friendica
|
||||||
timeout=60
|
timeout=60
|
||||||
|
@ -52,16 +59,17 @@ nt=0
|
||||||
#Highest possible ID known
|
#Highest possible ID known
|
||||||
maxid=$("${dbengine}" "${db}" -B -N -q -e "select max(\`id\`) from contact")
|
maxid=$("${dbengine}" "${db}" -B -N -q -e "select max(\`id\`) from contact")
|
||||||
#Limit per batch
|
#Limit per batch
|
||||||
limit=$(((maxid / 1000) + 1))
|
#limit=$(((maxid / 1000) + 1))
|
||||||
|
limit="${maxid}"
|
||||||
dbcount=0
|
dbcount=0
|
||||||
idcount=0
|
idcount=0
|
||||||
if [[ "${intensive_optimizations}" -gt 0 ]]; then
|
if [[ "${intensive_optimizations}" -gt 0 ]]; then
|
||||||
#https:// = 8 characters | /avatar/ = 8 characters
|
#https:// = 8 characters | /avatar/ = 8 characters
|
||||||
indexlength=$(("${#url}" + 16))
|
indexlength=$(("${#url}" + 16))
|
||||||
"${dbengine}" "${db}" -e "alter table contact add index if not exists photo_index (photo(${indexlength}))"
|
"${dbengine}" "${db}" -e "alter table contact add index if not exists photo_index (photo(${indexlength}))"
|
||||||
dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where (\`photo\` like 'https:\/\/${url}/avatar/%' or \`photo\` like '')")
|
dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where (\`photo\` like 'https:\/\/${url}/avatar/%' or (\`photo\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = ''))")
|
||||||
else
|
else
|
||||||
dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where (\`photo\` like 'https:\/\/${url}/avatar/%' or \`photo\` like '') and (\`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`) or \`id\` in (select \`contact-id\` from \`group_member\`))")
|
dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where (\`photo\` like 'https:\/\/${url}/avatar/%' or (\`photo\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = '')) and (\`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`) or \`id\` in (select \`contact-id\` from \`group_member\`))")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
loop() {
|
loop() {
|
||||||
|
@ -295,12 +303,12 @@ loop() {
|
||||||
#Go to the Friendica installation
|
#Go to the Friendica installation
|
||||||
cd "${folder}" || exit
|
cd "${folder}" || exit
|
||||||
echo "${n} ${nt}" >"${nfile}"
|
echo "${n} ${nt}" >"${nfile}"
|
||||||
until [[ "${idcount}" -ge "${dbcount}" || "${nt}" -gt "${dbcount}" || "${lastid}" -gt "${maxid}" ]]; do
|
#until [[ "${idcount}" -ge "${dbcount}" || "${nt}" -gt "${dbcount}" || "${lastid}" -gt "${maxid}" ]]; do
|
||||||
c=""
|
c=""
|
||||||
if [[ "${intensive_optimizations}" -gt 0 ]]; then
|
if [[ "${intensive_optimizations}" -gt 0 ]]; then
|
||||||
c=$("${dbengine}" "${db}" -B -N -q -e "select \`id\` from \`contact\` where \`id\` > ${lastid} and (\`photo\` like \"https:\/\/${url}/avatar/%\" or \`photo\` like \"\") order by id limit ${limit}")
|
c=$("${dbengine}" "${db}" -B -N -q -e "select \`id\` from \`contact\` where \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%' or (\`photo\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = '')) order by id limit ${limit}")
|
||||||
else
|
else
|
||||||
c=$("${dbengine}" "${db}" -B -N -q -e "select \`id\` from \`contact\` where \`id\` > ${lastid} and (\`photo\` like \"https:\/\/${url}/avatar/%\" or \`photo\` like \"\") and (id in (select cid from \`user-contact\`) or id in (select \`uid\` from \`user\`) or \`id\` in (select \`contact-id\` from \`group_member\`)) order by id limit ${limit}")
|
c=$("${dbengine}" "${db}" -B -N -q -e "select \`id\` from \`contact\` where \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%' or (\`photo\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = '')) and (id in (select cid from \`user-contact\`) or id in (select \`uid\` from \`user\`) or \`id\` in (select \`contact-id\` from \`group_member\`)) order by id limit ${limit}")
|
||||||
fi
|
fi
|
||||||
while read -r id; do
|
while read -r id; do
|
||||||
if [[ -n "${id}" && $((10#${id})) -ge "${lastid}" ]]; then
|
if [[ -n "${id}" && $((10#${id})) -ge "${lastid}" ]]; then
|
||||||
|
@ -351,7 +359,7 @@ until [[ "${idcount}" -ge "${dbcount}" || "${nt}" -gt "${dbcount}" || "${lastid}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
#done
|
||||||
if [[ -f "${nfile}" ]]; then
|
if [[ -f "${nfile}" ]]; then
|
||||||
rm -rf "${nfile}"
|
rm -rf "${nfile}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue