On 5/26/19 3:07 PM, Mark Sapiro wrote:
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 incat list
;do k=0 if [ $n == $keep ] ;then k=1 break fi done if [ $k -eq 0 ]; then rm $f fi done
Actually, I thought about it a bit more, and I decided that arcane shell script was a bit obscure and it would be easier to just do it in Python. Plus, you can properly delete the message that way.
A complete script for mailman shell
is like
import os msg_ids = {} 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) msg_ids[(msg['Message-ID-Hash'])] = True
for root, dirs, files in os.walk('path/to/var/messages'): for file in files: if not msg_ids.get(file, False): msg = ms.get_message_by_hash(file) ms.delete_message(msg['Message-ID'])
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan