On Thu, Jul 18, 2019 at 01:34:46PM +0300, gwn wrote:
> So that the hook can implement advanced features that acts on the
> newly synced mail content.

Here are my comments to make this patch go into the mainline.

> Also please note that this patch is not backwards compatible as it
> causes "newmail_hook" lambdas with no arguments trigger
> exceptions.

Please, update the documentation accordingly in offlineimap.conf.

> ---
>  offlineimap/folder/Base.py | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
> index 5f287fa..f1376b7 100644
> --- a/offlineimap/folder/Base.py
> +++ b/offlineimap/folder/Base.py
> @@ -947,8 +947,18 @@ class BaseFolder(object):
>  
>          # Execute new mail hook if we have new mail.
>          if self.have_newmail:
> +            dstfolder_fullname = dstfolder.getfullname()
> +
> +            newmail_filenames = [
> +                os.path.join(
> +                    dstfolder_fullname,
> +                    dstfolder.messagelist[uid]['filename']
> +                )
> +                    for uid in copylist
> +            ]
> +

I think we should compute the list only when we need it, after the
'newmail_hook != None' check.


>              if self.newmail_hook != None:

BTW, this check should be merged with the 'have_newmail' check.

> -                self.newmail_hook()
> +                self.newmail_hook(newmail_filenames)
>  
>      def __syncmessagesto_delete(self, dstfolder, statusfolder):
>          """Pass 2: Remove locally deleted messages on dst.

Thanks!

-- 
Nicolas Sebrecht

_______________________________________________
OfflineIMAP-project mailing list: [email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/offlineimap-project

OfflineIMAP homepages:
- https://github.com/OfflineIMAP
- http://offlineimap.org

Reply via email to