mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 04:30:12 +01:00
util: add check if purging is enabled
Change-Id: I90cc2062513abec1ec947fc0adb4c3da9d125784 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
f69e3cdc42
commit
1e5858179e
@ -35,6 +35,18 @@ def read_options(filename="", opts={}):
|
||||
opts['server_id'] = "%02x" % config.getint('piler', 'server_id')
|
||||
|
||||
|
||||
def is_purge_enabled(opts={}):
|
||||
cursor = opts['db'].cursor()
|
||||
|
||||
cursor.execute("SELECT `value` FROM `option` WHERE `key`='enable_purge'")
|
||||
|
||||
row = cursor.fetchone()
|
||||
if row and row[0] == '1':
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def purge_m_files(ids=[], opts={}):
|
||||
if len(ids) > 0:
|
||||
remove_m_files(ids, opts)
|
||||
@ -187,6 +199,10 @@ def main():
|
||||
opts['db'] = dbapi.connect("localhost", opts['username'],
|
||||
opts['password'], opts['database'])
|
||||
|
||||
if is_purge_enabled(opts) is False:
|
||||
syslog.syslog("Purging emails is disabled")
|
||||
sys.exit(1)
|
||||
|
||||
cursor = opts['db'].cursor()
|
||||
cursor.execute(SQL_PURGE_SELECT_QUERY)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user