Compare commits
No commits in common. "c0d998342d4d6f0faac0ad8bfe4fef74cd7c0476" and "e203b41209f8654c3788fb882a942035738c317e" have entirely different histories.
c0d998342d
...
e203b41209
5 changed files with 152 additions and 166 deletions
|
@ -19,8 +19,7 @@ loop() {
|
||||||
#Find the pictures in the avatar folders and delete them
|
#Find the pictures in the avatar folders and delete them
|
||||||
"${dbengine}" "${db}" -N -B -q -e "select \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${lineb}" | while read -r photo thumb micro; do
|
"${dbengine}" "${db}" -N -B -q -e "select \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${lineb}" | while read -r photo thumb micro; do
|
||||||
#If stored in avatar folder
|
#If stored in avatar folder
|
||||||
if grep -v -q "${url}/avatar" <(echo "${photo}"); then
|
if ! grep -v -q "${url}/avatar" <(echo "${photo}"); then
|
||||||
#if [[ -z "${isavatar}" ]]
|
|
||||||
phototrimmed=$(echo "${photo}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
phototrimmed=$(echo "${photo}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
||||||
rm -rfv "${phototrimmed}"
|
rm -rfv "${phototrimmed}"
|
||||||
thumbtrimmed=$(echo "${thumb}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
thumbtrimmed=$(echo "${thumb}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
||||||
|
@ -29,17 +28,16 @@ loop() {
|
||||||
rm -rfv "${microtrimmed}"
|
rm -rfv "${microtrimmed}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "post-thread: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread (select \`uri-id\` from \`post-thread\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete h.* from \`post-thread\` h inner join \`tmp_post_thread\` t where h.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`post-thread\` where \`author-id\` = ${lineb} or \`causer-id\` = ${lineb} or \`owner-id\` = ${lineb}"
|
||||||
printf "post-thread-user: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread_user (select \`uri-id\` from \`post-thread-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete r.* from \`post-thread-user\` r inner join \`tmp_post_thread_user\` t where r.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`post-thread-user\` where \`author-id\` = ${lineb} or \`causer-id\` = ${lineb} or \`owner-id\` = ${lineb}"
|
||||||
printf "post-user: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_user (select \`id\` from \`post-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete u.* from \`post-user\` u inner join \`tmp_post_user\` t where u.\`id\` = t.\`id\`; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`post-user\` where \`author-id\` = ${lineb} or \`causer-id\` = ${lineb} or \`owner-id\` = ${lineb}"
|
||||||
printf "post-tag: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${lineb}"
|
||||||
printf "post-content: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`;"
|
||||||
printf "post: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}"
|
||||||
printf "photo: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-id\` = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-id\` = ${lineb}"
|
||||||
printf "contact: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${lineb}"
|
||||||
printf "apcontact: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${lineb}"
|
||||||
printf "diaspora-contact: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${lineb}"
|
||||||
printf "\r\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check if our dependencies are installed
|
#Check if our dependencies are installed
|
||||||
|
|
|
@ -16,18 +16,18 @@ avatarfolder=/var/www/friendica/avatar
|
||||||
avatarfolderescaped=${avatarfolder////\\/}
|
avatarfolderescaped=${avatarfolder////\\/}
|
||||||
loop_1() {
|
loop_1() {
|
||||||
site=$(echo "${sites}" | sed -e "s/http[s]*:\/\///g")
|
site=$(echo "${sites}" | sed -e "s/http[s]*:\/\///g")
|
||||||
# if [[ "${protocol}" == "apub" ]]; then
|
if [[ "${protocol}" == "apub" ]]; then
|
||||||
# #For ActivityPub sites, we test the well-known Webfinger
|
#For ActivityPub sites, we test the well-known Webfinger
|
||||||
# #We also need a valid (known) user for the Webfinger test
|
#We also need a valid (known) user for the Webfinger test
|
||||||
# user=$("${dbengine}" "${db}" -N -B -q -e "select \`addr\` from contact where baseurl = \"http://${site}\" or url = \"http://${site}\" or baseurl = \"https://${site}\" or url = \"https://${site}\" limit 1")
|
user=$("${dbengine}" "${db}" -N -B -q -e "select \`addr\` from contact where baseurl = \"http://${site}\" or url = \"http://${site}\" or baseurl = \"https://${site}\" or url = \"https://${site}\" limit 1")
|
||||||
# site_test="https://${site}/.well-known/webfinger?resource=acct:${user}"
|
site_test="https://${site}/.well-known/webfinger?resource=acct:${user}"
|
||||||
# #If the return message is in "application/jrd+json" format, the site is still up
|
#If the return message is in "application/jrd+json" format, the site is still up
|
||||||
# #If the message contains a reference to Cloudflare, we don't add it to the list either, just in case
|
#If the message contains a reference to Cloudflare, we don't add it to the list either, just in case
|
||||||
# if ! grep -q -e "application/jrd+json" -e "HTTP.*200" -e "cloudflare" <(curl -s -L -I -m 30 -X HEAD "${site_test}"); then
|
if ! grep -q -e "application/jrd+json" -e "HTTP.*200" -e "cloudflare" <(curl -s -L -I -m 30 -X HEAD "${site_test}"); then
|
||||||
# echo "${site}" >>"${tmpfile}"
|
echo "${site}" >>"${tmpfile}"
|
||||||
# echo "Added ${site}"
|
echo "Added ${site}"
|
||||||
# fi
|
fi
|
||||||
# fi
|
fi
|
||||||
#This is mostly for RSS feeds, we only check whether the site itself is up
|
#This is mostly for RSS feeds, we only check whether the site itself is up
|
||||||
#Skip check if the message contains a reference to Cloudflare
|
#Skip check if the message contains a reference to Cloudflare
|
||||||
if [[ "${protocol}" != "bsky" ]]; then
|
if [[ "${protocol}" != "bsky" ]]; then
|
||||||
|
@ -58,14 +58,26 @@ loop_3() {
|
||||||
rm -rfv "${microtrimmed}"
|
rm -rfv "${microtrimmed}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "post-thread: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread (select \`uri-id\` from \`post-thread\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete h.* from \`post-thread\` h inner join \`tmp_post_thread\` t where h.\`uri-id\` = t.\`uri-id\`; select row_count();") printf "post-thread-user: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread_user (select \`uri-id\` from \`post-thread-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete r.* from \`post-thread-user\` r inner join \`tmp_post_thread_user\` t where r.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
printf "post-thread:"
|
||||||
printf "post-user: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_user (select \`id\` from \`post-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete u.* from \`post-user\` u inner join \`tmp_post_user\` t where u.\`id\` = t.\`id\`; select row_count();") printf "post-tag: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread (select \`uri-id\` from \`post-thread\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete h.* from \`post-thread\` h inner join \`tmp_post_thread\` t where h.\`uri-id\` = t.\`uri-id\`; select row_count();"
|
||||||
printf "post-content: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();") printf "post: %s " $("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
printf "post-thread-user:"
|
||||||
printf "photo: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-id\` = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread_user (select \`uri-id\` from \`post-thread-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete r.* from \`post-thread-user\` r inner join \`tmp_post_thread_user\` t where r.\`uri-id\` = t.\`uri-id\`; select row_count();"
|
||||||
printf "contact: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${lineb}; select row_count();")
|
printf "post-user":
|
||||||
printf "apcontact: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${lineb}; select row_count();")
|
"${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_user (select \`id\` from \`post-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete u.* from \`post-user\` u inner join \`tmp_post_user\` t where u.\`id\` = t.\`id\`; select row_count();"
|
||||||
printf "diaspora-contact: %s " $("${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${lineb}; select row_count();")
|
printf "post-tag:"
|
||||||
printf "\r\n"
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${lineb}; select row_count();"
|
||||||
|
printf "post-content:"
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();"
|
||||||
|
printf "post:"
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();"
|
||||||
|
printf "photo:"
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-id\` = ${lineb}; select row_count();"
|
||||||
|
printf "contact:"
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${lineb}; select row_count();"
|
||||||
|
printf "apcontact:"
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${lineb}; select row_count();"
|
||||||
|
printf "diaspora-contact:"
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${lineb}; select row_count();"
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check if our dependencies are installed
|
#Check if our dependencies are installed
|
||||||
|
|
|
@ -31,8 +31,8 @@ loop_1() {
|
||||||
tmppic="/tmp/temp_$(date +%s).webp"
|
tmppic="/tmp/temp_$(date +%s).webp"
|
||||||
nice -n 10 cwebp -mt -af -quiet "${p}" -o "${tmppic}" #&> /dev/null
|
nice -n 10 cwebp -mt -af -quiet "${p}" -o "${tmppic}" #&> /dev/null
|
||||||
if [[ -f "${tmppic}" ]]; then
|
if [[ -f "${tmppic}" ]]; then
|
||||||
size_new=$(stat -c%s "${tmppic}" 2>/dev/null || echo 0)
|
size_new=$(stat -c%s "${tmppic}" || echo 0)
|
||||||
size_original=$(stat -c%s "${p}" 2>/dev/null || echo 0)
|
size_original=$(stat -c%s "${p}" || echo 0)
|
||||||
if [[ "${size_original}" -gt "${size_new}" ]]; then
|
if [[ "${size_original}" -gt "${size_new}" ]]; then
|
||||||
mv "${tmppic}" "${p}" #&> /dev/null
|
mv "${tmppic}" "${p}" #&> /dev/null
|
||||||
else
|
else
|
||||||
|
|
|
@ -35,11 +35,6 @@ lastid=${4:-"0"}
|
||||||
if [[ ! "${lastid}" =~ ^[0-9]+$ || $((10#${lastid})) -le 0 ]]; then
|
if [[ ! "${lastid}" =~ ^[0-9]+$ || $((10#${lastid})) -le 0 ]]; then
|
||||||
lastid=0
|
lastid=0
|
||||||
fi
|
fi
|
||||||
#Command-line parameter number 5: whether to enable the lockfile and the item counter, or disable it for a performance boost (0=off). Defaults to 1=on.
|
|
||||||
lockfile_enabled=${5:-"1"}
|
|
||||||
if [[ "${lockfile_enabled}" != "0" && "${lockfile_enabled}" != "1" ]]; then
|
|
||||||
lockfile_enabled=1
|
|
||||||
fi
|
|
||||||
nfolder="/tmp/friendica-remove-invalid-photos"
|
nfolder="/tmp/friendica-remove-invalid-photos"
|
||||||
nfile="${nfolder}/n$(date +%s).csv"
|
nfile="${nfolder}/n$(date +%s).csv"
|
||||||
nlock="${nfolder}/n$(date +%s).lock"
|
nlock="${nfolder}/n$(date +%s).lock"
|
||||||
|
@ -73,12 +68,8 @@ if [[ "${intensive_optimizations}" -gt 0 ]]; then
|
||||||
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 \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%' or (\`photo\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = ''))")
|
dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%' or (\`photo\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = ''))")
|
||||||
#dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%')")
|
|
||||||
#dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where \`id\` > ${lastid} and ((\`photo\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = ''))")
|
|
||||||
else
|
else
|
||||||
dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`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\`))")
|
dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`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\`))")
|
||||||
#dbcount=$("${dbengine}" "${db}" -B -N -q -e "select count(\`id\`) from \`contact\` where \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%') 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 \`id\` > ${lastid} and ((\`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() {
|
||||||
|
@ -89,7 +80,6 @@ loop() {
|
||||||
nl=0
|
nl=0
|
||||||
error_found=0
|
error_found=0
|
||||||
#Lockfile-protected read
|
#Lockfile-protected read
|
||||||
if [[ ${lockfile_enabled} -eq 1 ]]; then
|
|
||||||
r=0
|
r=0
|
||||||
if [[ "${time_counter}" -eq 1 ]]; then
|
if [[ "${time_counter}" -eq 1 ]]; then
|
||||||
t_r=$(($(date +%s%N) / 1000000))
|
t_r=$(($(date +%s%N) / 1000000))
|
||||||
|
@ -136,7 +126,6 @@ loop() {
|
||||||
if [[ "${time_counter}" -eq 1 ]]; then
|
if [[ "${time_counter}" -eq 1 ]]; then
|
||||||
result_string=$(printf "%s R%dms" "${result_string}" $(($(($(date +%s%N) / 1000000)) - t_r)))
|
result_string=$(printf "%s R%dms" "${result_string}" $(($(($(date +%s%N) / 1000000)) - t_r)))
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
if [[ -n "${id}" ]]; then
|
if [[ -n "${id}" ]]; then
|
||||||
while read -r avatar photo thumb micro; do
|
while read -r avatar photo thumb micro; do
|
||||||
if [[ -n "${photo}" && -n "${thumb}" && -n "${micro}" ]]; then
|
if [[ -n "${photo}" && -n "${thumb}" && -n "${micro}" ]]; then
|
||||||
|
@ -249,7 +238,6 @@ loop() {
|
||||||
lastid="${id}"
|
lastid="${id}"
|
||||||
done < <("${dbengine}" "${db}" -B -N -q -e "select \`avatar\`, \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${id}")
|
done < <("${dbengine}" "${db}" -B -N -q -e "select \`avatar\`, \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${id}")
|
||||||
fi
|
fi
|
||||||
if [[ ${lockfile_enabled} -eq 1 ]]; then
|
|
||||||
w=0
|
w=0
|
||||||
if [[ "${time_counter}" -eq 1 ]]; then
|
if [[ "${time_counter}" -eq 1 ]]; then
|
||||||
t_w=$(($(date +%s%N) / 1000000))
|
t_w=$(($(date +%s%N) / 1000000))
|
||||||
|
@ -290,16 +278,9 @@ loop() {
|
||||||
done
|
done
|
||||||
if [[ "${time_counter}" -eq 1 ]]; then
|
if [[ "${time_counter}" -eq 1 ]]; then
|
||||||
result_string=$(printf "%s W%dms" "${result_string}" $(($(($(date +%s%N) / 1000000)) - t_w)))
|
result_string=$(printf "%s W%dms" "${result_string}" $(($(($(date +%s%N) / 1000000)) - t_w)))
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ "${time_counter}" -eq 1 ]]; then
|
|
||||||
result_string=$(printf "%s T%dms" "${result_string}" $(($(($(date +%s%N) / 1000000)) - t_id)))
|
result_string=$(printf "%s T%dms" "${result_string}" $(($(($(date +%s%N) / 1000000)) - t_id)))
|
||||||
fi
|
fi
|
||||||
final_string=""
|
final_string=$(printf "E%8d F%8d/%8d T%8d/%8d %s" "${n}" "${nt}" "${dbcount}" "${lastid}" "${maxid}" "${result_string}")
|
||||||
if [[ ${lockfile_enabled} -eq 1 ]]; then
|
|
||||||
final_string=$(printf "E%8d F%8d/%8d " "${n}" "${nt}" "${dbcount}")
|
|
||||||
fi
|
|
||||||
final_string=$(printf "%sT%8d/%8d %s" "${final_string}" "${lastid}" "${maxid}" "${result_string}")
|
|
||||||
final_string_length="${#final_string}"
|
final_string_length="${#final_string}"
|
||||||
#Previous line clearance
|
#Previous line clearance
|
||||||
#Measure length of string, blank only the excess
|
#Measure length of string, blank only the excess
|
||||||
|
@ -326,12 +307,8 @@ echo "${n} ${nt}" >"${nfile}"
|
||||||
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\` = '' and not \`avatar\` = '') or (\`avatar\` = '' and not \`photo\` = '')) 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}")
|
||||||
#c=$("${dbengine}" "${db}" -B -N -q -e "select \`id\` from \`contact\` where \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%') order by id limit ${limit}")
|
|
||||||
#c=$("${dbengine}" "${db}" -B -N -q -e "select \`id\` from \`contact\` where \`id\` > ${lastid} and ((\`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\` = '' 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}")
|
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}")
|
||||||
#c=$("${dbengine}" "${db}" -B -N -q -e "select \`id\` from \`contact\` where \`id\` > ${lastid} and (\`photo\` like 'https:\/\/${url}/avatar/%') 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\` = '' 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
|
||||||
|
@ -347,7 +324,6 @@ while read -r id; do
|
||||||
done
|
done
|
||||||
done < <(echo "${c}")
|
done < <(echo "${c}")
|
||||||
wait
|
wait
|
||||||
if [[ ${lockfile_enabled} -eq 1 ]]; then
|
|
||||||
#Read data before next iteration
|
#Read data before next iteration
|
||||||
rl=0
|
rl=0
|
||||||
(
|
(
|
||||||
|
@ -383,7 +359,7 @@ if [[ ${lockfile_enabled} -eq 1 ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
#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