Author: poeml Date: 2009-02-24 17:15:02 -0700 (Tue, 24 Feb 2009) New Revision: 6567 Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py Log: mb tool: - fix mb vacuum, the database cleanup tool, to work with PostgreSQL MySQL idiosyncrasies removed, (although I didn't test it with MySQL to see whether it still works with that database) Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py =================================================================== --- trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py 2009-02-24 21:35:59 UTC (rev 6566) +++ trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py 2009-02-25 00:15:02 UTC (rev 6567) _at_@ -3,10 +3,10 @@ """show statistics about stale files in the database""" # file_server table - query = 'select count(*) from file_server as fs left outer join server as s on fs.serverid = s.id where isnull(s.id)' + query = 'SELECT COUNT(*) FROM file_server fs LEFT OUTER JOIN server s ON fs.serverid = s.id WHERE s.id IS NULL' n_file_stale = conn.FileServer._connection.queryAll(query)[0] - query = 'select count(*) from file_server as fs left outer join server as s on fs.serverid = s.id where isnull(s.id) or s.enabled = 0' + query = 'SELECT COUNT(*) FROM file_server fs LEFT OUTER JOIN server s ON fs.serverid = s.id WHERE s.id IS NULL OR NOT s.enabled' n_file_disabled_stale = conn.FileServer._connection.queryAll(query)[0] _at_@ -14,7 +14,7 @@ # file table n_file_total = conn.File.select().count() - query = 'select count(*) from file as f left outer join file_server as fs on f.id = fs.fileid where isnull(fs.fileid)' + query = 'SELECT COUNT(*) FROM file f LEFT OUTER JOIN file_server fs ON f.id = fs.fileid WHERE fs.fileid IS NULL' n_file_stale = conn.File._connection.queryAll(query)[0] _at_@ -29,11 +29,12 @@ def vacuum(conn): """delete stale file entries from the database""" - print 'Deleting...' - query = 'delete fs from file_server fs left outer join server s on fs.serverid = s.id where isnull(s.id) or s.enabled = 0' - result = conn.FileServer._connection.queryAll(query) + print 'Deleting stales from file_server...' + query = 'DELETE FROM file_server WHERE serverid IN (SELECT id FROM server WHERE NOT enabled)' + conn.FileServer._connection.query(query) - query = 'delete f from file as f left outer join file_server as fs on f.id = fs.fileid where isnull(fs.fileid)' - result = conn.File._connection.queryAll(query) + print 'Deleting stales from file...' + query = 'DELETE FROM file WHERE id IN (SELECT f.id FROM file f LEFT OUTER JOIN file_server fs ON f.id = fs.fileid WHERE fs.fileid IS NULL)' + conn.File._connection.query(query) print 'Done.' _______________________________________________ Opensuse-svn mailing list Opensuse-svn_at_forge.novell.com http://forge.novell.com/mailman/listinfo/opensuse-svn _______________________________________________ mirrorbrain-commits mailing list Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Wed Feb 25 2009 - 00:15:30 GMT
This archive was generated by hypermail 2.3.0 : Thu Mar 25 2010 - 19:18:16 GMT