Hi! I've been pondering about doveadm-search-query(7) and trying to formulate a search query for some time now and it seems there is no way to search for messages, which have been marked DELETED before a certain time. I want to use this to expunge all DELETED messages which have been in that state for 24h or longer. For example a cronjob runs at midnight to expunge those messages but a user deletes one just 10 minutes before that, this message should not be deleted until the day after. This is my first time diving deeper into IMAP search queries so I have the nagging feeling I am missing something important here. Gr??e, Sven. -- Sigmentation fault. Core dumped.
On Mon, Sep 03, 2012 at 01:31:18PM +0200, Sven Hartge wrote:> Hi![..]> I want to use this to expunge all DELETED messages which have been in > that state for 24h or longer.http://wiki2.dovecot.org/Tools/Doveadm/Expunge HTH Dennis [..]
Dennis Guhl <dg at dguhl.org> wrote:> On Mon, Sep 03, 2012 at 01:31:18PM +0200, Sven Hartge wrote: >> Hi!>> I want to use this to expunge all DELETED messages which have been in >> that state for 24h or longer.> http://wiki2.dovecot.org/Tools/Doveadm/ExpungeYes, I know about doveadm expunge. I am searching for a search_query which only matches messages with the flag \Deleted whose flag has been set 24h or longer ago. Doing something like doveadm expunge -A mailbox \* DELETED is not the solution, since it will expunge all deleted mails without looking at the time when they have been deleted. Using savedbefore does not work either, since a message may have been saved 2 years ago but only recently deleted. Gr??e, Sven. -- Sigmentation fault. Core dumped.
On 3.9.2012, at 14.31, Sven Hartge wrote:> I want to use this to expunge all DELETED messages which have been in > that state for 24h or longer.Dovecot doesn't keep track of that information, so you can't.
On Tue, 4 Sep 2012, Sven Hartge wrote:> I am searching for a search_query which only matches messages with the > flag \Deleted whose flag has been set 24h or longer ago. > > Doing something like > > doveadm expunge -A mailbox \* DELETED > > is not the solution, since it will expunge all deleted mails without > looking at the time when they have been deleted. > > Using savedbefore does not work either, since a message may have been > saved 2 years ago but only recently deleted.You could work out a cron job that does a "doveadm search ...", then diff it with one generated 24 hours ago, extract the common GID/UUIDs, then do a second pass to delete them. Not elegant, but it would probably work. (I just read the man page, and there doesn't seem to be an option to pipe the search like "doveadm search ... | doveadm expunge ...". You'll have to expunge one message at a time. Ugh.) Or maybe the advice "don't worry, be happy" applies here. I find that too many "mistake mitigation" features is counterproductive as users habitually relying on them, rather than being careful. Extending your grace period to a week will lessen the probability of this race condition. Joseph Tam <jtam.home at gmail.com>