def uidvalidity_cb(self, account_id, folder_name, select_info): assert folder_name == self.folder_name assert account_id == self.account_id selected_uidvalidity = select_info['UIDVALIDITY'] is_valid = (self.uidvalidity is None or selected_uidvalidity <= self.uidvalidity) if not is_valid: raise UidInvalid('folder: {}, remote uidvalidity: {}, ' 'cached uidvalidity: {}'.format( folder_name.encode('utf-8'), selected_uidvalidity, self.uidvalidity)) return select_info
def uidvalidity_cb(account_id, folder_name, select_info): assert folder_name is not None and select_info is not None, \ "must start IMAP session before verifying UIDVALIDITY" with mailsync_session_scope() as db_session: saved_folder_info = common.get_folder_info(account_id, db_session, folder_name) saved_uidvalidity = or_none(saved_folder_info, lambda i: i.uidvalidity) selected_uidvalidity = select_info['UIDVALIDITY'] if saved_folder_info: is_valid = common.uidvalidity_valid(account_id, selected_uidvalidity, folder_name, saved_uidvalidity) if not is_valid: raise UidInvalid('folder: {}, remote uidvalidity: {}, ' 'cached uidvalidity: {}'.format( folder_name.encode('utf-8'), selected_uidvalidity, saved_uidvalidity)) return select_info
def fn(folder_name, select_info): assert folder_name is not None and select_info is not None, \ "must start IMAP session before verifying UIDVALIDITY" with session_scope(ignore_soft_deletes=False) as db_session: saved_folder_info = account.get_folder_info( account_id, db_session, folder_name) saved_uidvalidity = or_none(saved_folder_info, lambda i: i.uidvalidity) selected_uidvalidity = select_info['UIDVALIDITY'] if saved_folder_info: is_valid = account.uidvalidity_valid(account_id, selected_uidvalidity, folder_name, saved_uidvalidity) if not is_valid: raise UidInvalid('folder: {}, remote uidvalidity: {}, ' 'cached uidvalidity: {}'.format( folder_name, selected_uidvalidity, saved_uidvalidity)) return select_info