diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2023-06-08 16:01:58 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2023-06-08 16:01:58 +0300 |
commit | b38f588b715030300d1641ef5fca2dba6d16d4e3 (patch) | |
tree | 51881a65eca3a38bfa229ab0a6a6b93c8100838c | |
parent | 60fd5370e70ea31e5bfeac3b1322a7f0cd99994e (diff) | |
download | mailman-master.tar.gz mailman-master.tar.bz2 |
* bin/mailsync: Remove mhonarc database if --reset is requested.
-rwxr-xr-x | bin/mailsync | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/bin/mailsync b/bin/mailsync index bc83a79..97a89b4 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -1,8 +1,8 @@ #! /usr/bin/python -# Copyright (C) 2014-2015 Sergey Poznyakoff +# Copyright (C) 2014-2023 Sergey Poznyakoff # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # @@ -23,14 +23,14 @@ import mailbox import re import MySQLdb from time import strftime, strptime from subprocess import Popen,PIPE,call dbg = 0 -dry_run = 0 -reset_state = 0 +dry_run = False +reset_state = False EX_OK = 0 EX_FAILURE = 1 EX_USAGE = 64 EX_CONFIG = 78 @@ -121,21 +121,26 @@ def mboxtohtml(listid): if reset_state: n = 0 else: n = get_state(listid) t = 0 + reset_map = {} for message in inbox.values()[n:]: frm = message.get_from() s = frm.split(' ', 1) t = strptime(s[1], '%a %b %d %H:%M:%S %Y') period = strftime('%Y-%m', t) periodh = strftime('%B, %Y', t) dirname = absdir(conf['core']['htmlrootdir'] + "/" + listid + "/" + period) if not os.path.exists(dirname): os.makedirs(dirname, 02775) + reset_map[period] = True + elif reset_state and not period in reset_map: + os.remove(dirname + '/.mhonarc.db') + reset_map[period] = True cmd = [ 'mhonarc', '-add', '-rcfile', absdir(conf['core']['etcdir'] + '/main.mrc'), '-outdir', dirname, '-definevar', 'gray_period=' + period, @@ -275,15 +280,15 @@ if __name__ == '__main__': usage() elif o in ("-d", "--debug"): dbg += 1 elif o in ("-c", "--config"): config = a elif o in ("-n", "--dry-run"): - dry_run = 1 + dry_run = True elif o in ("-r", "--reset"): - reset_state = 1 + reset_state = True if dry_run: dbg += 1 if config == '': config = os.path.abspath(os.path.dirname(sys.argv[0]) + '/../etc/mailsync.conf') |