From 4953a233e34d9259ddb95fae3b9ea0868e1d26a4 Mon Sep 17 00:00:00 2001 From: Thomi Richards Date: Mon, 15 Jun 2015 09:11:19 +1200 Subject: [PATCH] Fix a bug where messages weren't being moved because the connection was using sequence ids, rather than unique ids. --- gmailfilter/_connection.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gmailfilter/_connection.py b/gmailfilter/_connection.py index 8cef381..af90ce4 100644 --- a/gmailfilter/_connection.py +++ b/gmailfilter/_connection.py @@ -1,5 +1,6 @@ from contextlib import contextmanager import configparser +import functools import logging import os import os.path @@ -270,7 +271,18 @@ def __getattribute__(self, name): 'set_gmail_labels', ) if name in allowed: - return getattr(self._wrapped, name) + # Wrap these functions so they always use the uid, not the sequence + # id. + function = getattr(self._wrapped, name) + def wrapper(client, fn, *args, **kwargs): + old = client.use_uid + client.use_uid = True + try: + return fn(*args, **kwargs) + finally: + client.use_uid = old + return functools.partial(wrapper, self._wrapped, function) + raise AttributeError(name)