diff options
Diffstat (limited to 'distixlib/ticket_store.py')
-rw-r--r-- | distixlib/ticket_store.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/distixlib/ticket_store.py b/distixlib/ticket_store.py index 1a8b809..82ebc1e 100644 --- a/distixlib/ticket_store.py +++ b/distixlib/ticket_store.py @@ -16,6 +16,7 @@ # =*= License: GPL-3+ =*= +import email import os import distixlib @@ -197,12 +198,16 @@ class TicketStore(object): return message_filenames - def _file_contains(self, filename, data): # pragma: no cover - st = os.lstat(filename) - if st.st_size != len(data): - return False + def _file_contains(self, filename, data): # pragma: no cover Note + # that the email.Message class may reformat headers, so that + # msg.as_string() doesn't return the pristine original message + # text. Thus we can't just compare file content with data. + # Instead we load the file content into a message, let any + # reformatting happen, and then compare msg.as_string() with + # data. with open(filename) as f: - return f.read() == data + msg = email.message_from_file(f) + return msg.as_string() == data class _TicketCache(object): |