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:
authorErich Eckner <git@eckner.net>2018-03-27 09:32:44 +0200
committerErich Eckner <git@eckner.net>2018-03-27 09:32:44 +0200
commit6a9286eedc3bb7034c4174d418a0bdd8cff69f69 (patch)
tree904c5e5414bbf0ec2935ed3aaa64dd0a47a9c377 /lib/mysql-functions
parent9e7bb62bb58ca3a50e35fa8b814ce16b6973ab18 (diff)
lib/mysql-functions: mysql_cleanup: remove obsolete file_providers and files, too
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
}