From 5e82027ef7636fbc2b48591251315c82767060e1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 12 Jul 2011 16:07:14 -0600 Subject: [PATCH] Fix a bug that caused the same news download sent via a USB connection to the device on two different days resulting in a duplicate on the device --- src/calibre/devices/usbms/device.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index bdbf5f44cf..c4f2ec26ed 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -1077,8 +1077,13 @@ class Device(DeviceConfig, DevicePlugin): settings = self.settings() template = self.save_template() if mdata.tags and _('News') in mdata.tags: - today = time.localtime() - template = "{title}_%d-%d-%d" % (today[0], today[1], today[2]) + try: + p = mdata.pubdate + date = (p.year, p.month, p.day) + except: + today = time.localtime() + date = (today[0], today[1], today[2]) + template = "{title}_%d-%d-%d" % date use_subdirs = self.SUPPORTS_SUB_DIRS and settings.use_subdirs fname = sanitize(fname)