On 5/26/19 12:17 PM, Alain Kohli wrote:
Thanks for the great explanation, that helped a lot! I'll try to work on that issue if I find some time. In the meantime it would be neat to try to clean up the old messages right before the backup. How can you distinguish messages that have been moderated already? I couldn't really find that in the database or the models.
You could run the following in mailman shell
$ /path/to/mailman shell Welcome to the GNU Mailman shell
lm = getUtility(IListManager) ms = getUtility(IMessageStore) for mlist in lm.mailing_lists: ... requestdb = IListRequests(mlist) ... for rq in requestdb.held_requests: ... key, msgdata = requestdb.get_request(rq.id) ... if msgdata['_request_type'] != 'held_message': ... continue ... msg = ms.get_message_by_id(key) ... print(msg['Message-ID-Hash']) ... U6QVO2GXMEQ5ZDQR2XCLDOH2FXPKJTWX 32HA6GKYE5FOVORLER7YAC3264BHG264 JM4NP3JRXBKKAL7UMM5XEXX644DQBAFJ L7FX6XKOOBP3YFFXUHA6EEJCQXX5BCHX DOJX55MRY6OYPZ4XFFTAQDD4I5MWJ3AD
What that prints is the names of all the files in the var/messages/ hierarchy which are currently held messages. Presumably the others are ones already handled.
You could modify the above to write the list to a file and then wrap the whole thing in a shell script which would make the list and then do something like
for f in find var/messages -type f
;do
n=cut -d / -f5 <<<$f
for keep in cat list
;do
k=0
if [ $n == $keep ] ;then
k=1
break
fi
done
if [ $k -eq 0 ]; then
rm $f
fi
done
in the above, list is the list of names to keep bade by the first script and -f5 in the cut command assumes the list from find is lines of the form var/messages/TJ/YF/TJYF5FETCRLOQZJ2H6Y4PMZP6M7GNLES. i.e. two subdirectories between messages/ and the file.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan