[PATCH] avoid removing of data when user removed a maildir

Nicolas Sebrecht nicolas.s-dev at laposte.net
Mon Jun 20 22:25:41 BST 2016


On Mon, Jun 20, 2016 at 10:41:37PM +0200, Łukasz Żarnowiecki wrote:
> On Fri, Jun 17, 2016 at 08:05:46PM +0200, Nicolas Sebrecht wrote:

> > When a maildir is removed it must be considered new for the sync. However, the
> > local cache of the folder remains. This means the sync of the folder removes all
> > the missing emails.
> 
> I actually did that several times and I did not loose any emails.

I couldn't find any other protection in the code for this case. I might
be wrong, though.

> > WARNING: I did NOT tested this specific use case. I'm confident the changes
> > should work correctly. At least, this did not hurt my usual syncs.
> 
> I will try to verfiy that tomorrow.  Hope it will work as always ;)
> 
> > +    def purge(self):
> > +        """Remove any pre-existing database."""
> > +
> > +        try:
> > +            os.unlink(self.filename)
> > +        except OSError:
> > +            pass
> 
> Maybe it would be better to log that stuff with ui.debug?  You know,
> just in case.

You're right. I'll send another re-roll.

> > +    def purge(self):
> > +        """Remove any pre-existing database."""
> > +
> > +        try:
> > +            os.unlink(self.filename)
> > +        except OSError:
> > +            pass
> 
> Code duplication, is there any way to put that in some common place?

I've duplicated code because the "purge" is only usefull for the local
status (both plain text and sqlite). I intend to mark plain text support
deprecated after the v7.0.0 stable so we can later remove all the code
related to this. I expect the time about this code duplication should be
short enough to be sensible.

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list