This commit is contained in:
Kovid Goyal 2012-09-01 12:02:19 +05:30
parent bc959778e4
commit 786729fa6f
2 changed files with 13 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import os
from calibre.devices.interface import BookList as BL
from calibre.ebooks.metadata.book.base import Metadata
from calibre.ebooks.metadata.book.json_codec import JsonCodec
from calibre.utils.date import utcnow
class BookList(BL):
@ -26,8 +27,9 @@ class Book(Metadata):
def __init__(self, storage_id, lpath, other=None):
Metadata.__init__(self, _('Unknown'), other=other)
self.storage_id, self.lpath = storage_id, lpath
self.lpath = self.lpath.replace(os.sep, '/')
self.lpath = self.path = self.lpath.replace(os.sep, '/')
self.mtp_relpath = tuple([icu_lower(x) for x in self.lpath.split('/')])
self.datetime = utcnow().timetuple()
def matches_file(self, mtp_file):
return (self.storage_id == mtp_file.storage_id and

View File

@ -183,6 +183,16 @@ class MTP_DEVICE(BASE):
size = stream.tell()
stream.seek(0)
self.put_file(storage, self.METADATA_CACHE, stream, size)
def sync_booklists(self, booklists, end_session=True):
for bl in booklists:
if getattr(bl, 'storage_id', None) is None:
continue
storage = self.filesystem_cache.storage(bl.storage_id)
if storage is None:
continue
self.write_metadata_cache(storage, bl)
# }}}
def create_upload_path(self, path, mdata, fname):