if isinstance(guid, dict):
guid = guid.values()[0]
if guid in self.seen:
- if self.seen[guid] == id_:
+ if self.seen[guid]['id'] == id_:
_LOG.debug('already seen {}'.format(id_))
return # already seen
sender = self._get_entry_email(parsed=parsed, entry=entry)
_LOG.debug('new message: {}'.format(message['Subject']))
if send:
self._send(sender=sender, message=message)
- self.seen[guid] = id_
+ if guid not in self.seen:
+ self.seen[guid] = {}
+ self.seen[guid]['id'] = id_
self.etag = parsed.get('etag', None)
self.modified = parsed.get('modified', None)
>>> tmpdir.cleanup()
"""
- datafile_version = 1
+ datafile_version = 2
datafile_encoding = 'utf-8'
def __init__(self, configfiles=None, datafile=None, config=None):
def _upgrade_state_data(self, data):
version = data.get('version', 'unknown')
+ if version == 1:
+ for feed in data['feeds']:
+ seen = feed['seen']
+ for guid,id_ in seen.items():
+ seen[guid] = {'id': id_}
+ return data
raise NotImplementedError(
'cannot convert data file from version {} to {}'.format(
version, self.datafile_version))