MTP driver: Ignore folders whose names end with .sdr on Kindle devices

This commit is contained in:
Kovid Goyal 2023-09-01 09:21:26 +05:30
parent 32814c3607
commit 58de08aed0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 2 deletions

View File

@ -68,4 +68,4 @@ class DeviceDefaults:
ans['calibre_file_paths'] = {'metadata':'NOOK/metadata.calibre', 'driveinfo':'NOOK/driveinfo.calibre'} ans['calibre_file_paths'] = {'metadata':'NOOK/metadata.calibre', 'driveinfo':'NOOK/driveinfo.calibre'}
return ans return ans
return {} return {}, vid, pid

View File

@ -56,6 +56,7 @@ class MTP_DEVICE(BASE):
self._prefs = None self._prefs = None
self.device_defaults = DeviceDefaults() self.device_defaults = DeviceDefaults()
self.current_device_defaults = {} self.current_device_defaults = {}
self.current_vid = self.current_pid = -1
self.calibre_file_paths = {'metadata':self.METADATA_CACHE, 'driveinfo':self.DRIVEINFO} self.calibre_file_paths = {'metadata':self.METADATA_CACHE, 'driveinfo':self.DRIVEINFO}
self.highlight_ignored_folders = False self.highlight_ignored_folders = False
@ -88,6 +89,8 @@ class MTP_DEVICE(BASE):
if storage_id in ignored_folders: if storage_id in ignored_folders:
# Use the users ignored folders settings # Use the users ignored folders settings
return '/'.join(lpath) in {icu_lower(x) for x in ignored_folders[storage_id]} return '/'.join(lpath) in {icu_lower(x) for x in ignored_folders[storage_id]}
if self.current_vid == 0x1949 and lpath and lpath[-1].endswith('.sdr'):
return True
# Implement the default ignore policy # Implement the default ignore policy
@ -136,7 +139,7 @@ class MTP_DEVICE(BASE):
isoformat(utcnow())) isoformat(utcnow()))
self.prefs['history'] = h self.prefs['history'] = h
self.current_device_defaults = self.device_defaults(device, self) self.current_device_defaults, self.current_vid, self.current_pid = self.device_defaults(device, self)
self.calibre_file_paths = self.current_device_defaults.get( self.calibre_file_paths = self.current_device_defaults.get(
'calibre_file_paths', {'metadata':self.METADATA_CACHE, 'driveinfo':self.DRIVEINFO}) 'calibre_file_paths', {'metadata':self.METADATA_CACHE, 'driveinfo':self.DRIVEINFO})