mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-06 00:03:46 +02:00
Windows: workaround for eject() not being called on the device thread
This commit is contained in:
parent
9a110fb0d5
commit
d278180bde
2 changed files with 20 additions and 7 deletions
|
|
@ -314,6 +314,9 @@ def eject(self):
|
|||
'''
|
||||
Un-mount / eject the device from the OS. This does not check if there
|
||||
are pending GUI jobs that need to communicate with the device.
|
||||
|
||||
NOTE: That this method may not be called on the same thread as the rest
|
||||
of the device methods.
|
||||
'''
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs):
|
|||
self._main_id = self._carda_id = self._cardb_id = None
|
||||
self.start_thread = None
|
||||
self._filesystem_cache = None
|
||||
self.eject_dev_on_next_scan = False
|
||||
|
||||
def startup(self):
|
||||
self.start_thread = threading.current_thread()
|
||||
|
|
@ -75,6 +76,10 @@ def shutdown(self):
|
|||
@same_thread
|
||||
def detect_managed_devices(self, devices_on_system, force_refresh=False):
|
||||
if self.wpd is None: return None
|
||||
if self.eject_dev_on_next_scan:
|
||||
self.eject_dev_on_next_scan = False
|
||||
if self.currently_connected_pnp_id is not None:
|
||||
self.do_eject()
|
||||
|
||||
devices_on_system = frozenset(devices_on_system)
|
||||
if (force_refresh or
|
||||
|
|
@ -213,19 +218,24 @@ def filesystem_cache(self):
|
|||
return self._filesystem_cache
|
||||
|
||||
@same_thread
|
||||
def post_yank_cleanup(self):
|
||||
self.currently_connected_pnp_id = self.current_friendly_name = None
|
||||
self._main_id = self._carda_id = self._cardb_id = None
|
||||
self.dev = self._filesystem_cache = None
|
||||
|
||||
@same_thread
|
||||
def eject(self):
|
||||
def do_eject(self):
|
||||
if self.currently_connected_pnp_id is None: return
|
||||
self.ejected_devices.add(self.currently_connected_pnp_id)
|
||||
self.currently_connected_pnp_id = self.current_friendly_name = None
|
||||
self._main_id = self._carda_id = self._cardb_id = None
|
||||
self.dev = self._filesystem_cache = None
|
||||
|
||||
|
||||
@same_thread
|
||||
def post_yank_cleanup(self):
|
||||
self.currently_connected_pnp_id = self.current_friendly_name = None
|
||||
self._main_id = self._carda_id = self._cardb_id = None
|
||||
self.dev = self._filesystem_cache = None
|
||||
|
||||
def eject(self):
|
||||
if self.currently_connected_pnp_id is None: return
|
||||
self.eject_dev_on_next_scan = True
|
||||
|
||||
@same_thread
|
||||
def open(self, connected_device, library_uuid):
|
||||
self.dev = self._filesystem_cache = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue