Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tools/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def msgbody(self, msg):

return body

def compute_updates(self, lid, private, msg):
def compute_updates(self, lid, private, msg, default_invalid_date_to_now=True):
"""Determine what needs to be sent to the archiver.

:param lid: The list id
Expand Down Expand Up @@ -287,11 +287,10 @@ def compute_updates(self, lid, private, msg):
pass
if not mdate and msg_metadata.get('archived-at'):
mdate = email.utils.parsedate_tz(msg_metadata.get('archived-at'))
elif not mdate:
elif not mdate and default_invalid_date_to_now:
print("Date (%s) seems totally wrong, setting to _now_ instead." % mdate)
mdate = time.gmtime() # Get a standard 9-tuple
mdate = mdate + (0, ) # Fake a TZ (10th element)
mdatestring = time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(email.utils.mktime_tz(mdate)))
body = self.msgbody(msg)
try:
if 'content-type' in msg_metadata and msg_metadata['content-type'].find("flowed") != -1:
Expand All @@ -313,7 +312,8 @@ def compute_updates(self, lid, private, msg):

attachments, contents = self.msgfiles(msg)
irt = ""
if body is not None or attachments:
if (mdate is not None) and (body is not None or attachments):
mdatestring = time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(email.utils.mktime_tz(mdate)))
pmid = mid
try:
# Use full message as bytes for mid?
Expand Down
2 changes: 1 addition & 1 deletion tools/import-mbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def mailgen(list):
bad += 1
continue

json, contents = archie.compute_updates(list_override, private, message)
json, contents = archie.compute_updates(list_override, private, message, default_invalid_date_to_now=False)

# Not sure this can ever happen
if json and not (json['list'] and json['list_raw']):
Expand Down