Run database check before daemonizing, at the cost of database hygiene.

This commit is contained in:
David Baker 2015-04-27 11:46:00 +01:00
parent f8152f2708
commit b02e1006b9
3 changed files with 18 additions and 27 deletions

View file

@ -421,3 +421,13 @@ def prepare_sqlite3_database(db_conn):
" VALUES (?,?)",
(row[0], False)
)
def are_all_users_on_domain(txn, domain):
sql = "SELECT COUNT(*) FROM users WHERE name NOT LIKE ?"
pat = "%:" + domain
cursor = txn.execute(sql, (pat,))
num_not_matching = cursor.fetchall()[0][0]
if num_not_matching == 0:
return True
return False