This commit is contained in:
Kovid Goyal 2012-09-01 15:22:49 +05:30
parent d278180bde
commit 7b2a947a86
2 changed files with 4 additions and 1 deletions

View File

@ -129,6 +129,7 @@ class MTP_DEVICE(BASE):
cached_metadata = bl[idx] cached_metadata = bl[idx]
del relpath_cache[relpath] del relpath_cache[relpath]
if cached_metadata.size == mtp_file.size: if cached_metadata.size == mtp_file.size:
cached_metadata.datetime = mtp_file.last_modified.timetuple()
debug('Using cached metadata for', debug('Using cached metadata for',
'/'.join(mtp_file.full_path)) '/'.join(mtp_file.full_path))
continue # No need to update metadata continue # No need to update metadata
@ -148,6 +149,7 @@ class MTP_DEVICE(BASE):
'/'.join(mtp_file.full_path)) '/'.join(mtp_file.full_path))
traceback.print_exc() traceback.print_exc()
book.size = mtp_file.size book.size = mtp_file.size
book.datetime = mtp_file.last_modified.timetuple()
# Remove books in the cache that no longer exist # Remove books in the cache that no longer exist
for idx in sorted(relpath_cache.itervalues(), reverse=True): for idx in sorted(relpath_cache.itervalues(), reverse=True):

View File

@ -14,7 +14,7 @@ from future_builtins import map
from datetime import datetime from datetime import datetime
from calibre import human_readable, prints, force_unicode from calibre import human_readable, prints, force_unicode
from calibre.utils.date import local_tz from calibre.utils.date import local_tz, as_utc
from calibre.utils.icu import sort_key, lower from calibre.utils.icu import sort_key, lower
from calibre.ebooks import BOOK_EXTENSIONS from calibre.ebooks import BOOK_EXTENSIONS
@ -40,6 +40,7 @@ class FileOrFolder(object):
self.last_modified = datetime.fromtimestamp(md, local_tz) self.last_modified = datetime.fromtimestamp(md, local_tz)
except: except:
self.last_modified = datetime.fromtimestamp(0, local_tz) self.last_modified = datetime.fromtimestamp(0, local_tz)
self.last_modified = as_utc(self.last_modified)
if self.storage_id not in self.all_storage_ids: if self.storage_id not in self.all_storage_ids:
raise ValueError('Storage id %s not valid for %s, valid values: %s'%(self.storage_id, raise ValueError('Storage id %s not valid for %s, valid values: %s'%(self.storage_id,