MTP driver: Ignore the zinio folder by default

This commit is contained in:
Kovid Goyal 2013-07-12 17:11:13 +05:30
parent 14441ff052
commit 598a604853

View File

@ -83,7 +83,7 @@ class MTP_DEVICE(BASE):
return name in { return name in {
'alarms', 'android', 'dcim', 'movies', 'music', 'notifications', 'alarms', 'android', 'dcim', 'movies', 'music', 'notifications',
'pictures', 'ringtones', 'samsung', 'sony', 'htc', 'bluetooth', 'pictures', 'ringtones', 'samsung', 'sony', 'htc', 'bluetooth',
'games', 'lost.dir', 'video', 'whatsapp', 'image'} 'games', 'lost.dir', 'video', 'whatsapp', 'image', 'com.zinio.mobile.android.reader'}
def configure_for_kindle_app(self): def configure_for_kindle_app(self):
proxy = self.prefs proxy = self.prefs
@ -159,16 +159,17 @@ class MTP_DEVICE(BASE):
def get_driveinfo(self): def get_driveinfo(self):
if not self.driveinfo: if not self.driveinfo:
self.driveinfo = {} self.driveinfo = {}
for sid, location_code in ( (self._main_id, 'main'), (self._carda_id, for sid, location_code in ((self._main_id, 'main'), (self._carda_id,
'A'), (self._cardb_id, 'B')): 'A'), (self._cardb_id, 'B')):
if sid is None: continue if sid is None:
continue
self._update_drive_info(self.filesystem_cache.storage(sid), location_code) self._update_drive_info(self.filesystem_cache.storage(sid), location_code)
return self.driveinfo return self.driveinfo
def get_device_information(self, end_session=True): def get_device_information(self, end_session=True):
self.report_progress(1.0, _('Get device information...')) self.report_progress(1.0, _('Get device information...'))
dinfo = self.get_basic_device_information() dinfo = self.get_basic_device_information()
return tuple( list(dinfo) + [self.driveinfo] ) return tuple(list(dinfo) + [self.driveinfo])
def card_prefix(self, end_session=True): def card_prefix(self, end_session=True):
return (self._carda_id, self._cardb_id) return (self._carda_id, self._cardb_id)
@ -190,7 +191,7 @@ class MTP_DEVICE(BASE):
from calibre.devices.mtp.books import JSONCodec from calibre.devices.mtp.books import JSONCodec
from calibre.devices.mtp.books import BookList, Book from calibre.devices.mtp.books import BookList, Book
self.report_progress(0, _('Listing files, this can take a while')) self.report_progress(0, _('Listing files, this can take a while'))
self.get_driveinfo() # Ensure driveinfo is loaded self.get_driveinfo() # Ensure driveinfo is loaded
sid = {'carda':self._carda_id, 'cardb':self._cardb_id}.get(oncard, sid = {'carda':self._carda_id, 'cardb':self._cardb_id}.get(oncard,
self._main_id) self._main_id)
if sid is None: if sid is None:
@ -230,7 +231,7 @@ class MTP_DEVICE(BASE):
cached_metadata.path = mtp_file.mtp_id_path cached_metadata.path = mtp_file.mtp_id_path
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
book = cached_metadata book = cached_metadata
else: else:
book = Book(sid, '/'.join(relpath)) book = Book(sid, '/'.join(relpath))
@ -352,8 +353,8 @@ class MTP_DEVICE(BASE):
def prefix_for_location(self, on_card): def prefix_for_location(self, on_card):
if self.location_paths is None: if self.location_paths is None:
self.location_paths = {} self.location_paths = {}
for sid, loc in ( (self._main_id, None), (self._carda_id, 'carda'), for sid, loc in ((self._main_id, None), (self._carda_id, 'carda'),
(self._cardb_id, 'cardb') ): (self._cardb_id, 'cardb')):
if sid is not None: if sid is not None:
storage = self.filesystem_cache.storage(sid) storage = self.filesystem_cache.storage(sid)
prefixes = self.get_pref('send_to') prefixes = self.get_pref('send_to')
@ -470,7 +471,8 @@ class MTP_DEVICE(BASE):
def remove_books_from_metadata(self, paths, booklists): def remove_books_from_metadata(self, paths, booklists):
self.report_progress(0, _('Removing books from metadata')) self.report_progress(0, _('Removing books from metadata'))
class NextPath(Exception): pass class NextPath(Exception):
pass
for i, path in enumerate(paths): for i, path in enumerate(paths):
try: try:
@ -549,3 +551,4 @@ if __name__ == '__main__':
dev.shutdown() dev.shutdown()