Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/mysql-functions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mysql-functions')
-rwxr-xr-xlib/mysql-functions17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/mysql-functions b/lib/mysql-functions
index 129a20f..8e8217b 100755
--- a/lib/mysql-functions
+++ b/lib/mysql-functions
@@ -875,6 +875,23 @@ mysql_cleanup() {
fi
printf ' WHERE `build_slaves`.`currently_building` IS NOT NULL'
printf ' AND TIMEDIFF(NOW(),`build_slaves`.`last_connection`) > "1:00:00";\n'
+ # remove obsolete file_providers
+ printf '%s FROM `file_providers`' \
+ "${operator}"
+ printf ' WHERE NOT EXISTS ('
+ printf 'SELECT * FROM `binary_packages`'
+ printf ' WHERE `binary_packages`.`id`=`file_providers`.`package`'
+ printf ') OR NOT EXISTS ('
+ printf 'SELECT * FROM `files`'
+ printf ' WHERE `files`.`id`=`file_providers`.`file`'
+ printf ');\n'
+ # remove obsolete files
+ printf '%s FROM `files`' \
+ "${operator}"
+ printf ' WHERE NOT EXISTS ('
+ printf 'SELECT * FROM `file_providers`'
+ printf ' WHERE `files`.`id`=`file_providers`.`file`'
+ printf ');\n'
} | \
mysql_run_query
}