file_manager: refactor attribute names
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
7330c2c123
commit
1e97571aa8
@ -1514,9 +1514,9 @@ class INotifyHandler:
|
|||||||
self.watched_nodes: Dict[int, InotifyNode] = {}
|
self.watched_nodes: Dict[int, InotifyNode] = {}
|
||||||
self.pending_moves: Dict[
|
self.pending_moves: Dict[
|
||||||
int, Tuple[InotifyNode, str, asyncio.Handle]] = {}
|
int, Tuple[InotifyNode, str, asyncio.Handle]] = {}
|
||||||
self.create_gcode_notifications: Dict[str, Any] = {}
|
self.processed_gcode_events: Dict[str, Any] = {}
|
||||||
self.initialized: bool = False
|
self.initialized: bool = False
|
||||||
self.pending_gcode_notifications: List[Coroutine] = []
|
self.pending_coroutines: List[Coroutine] = []
|
||||||
self._gc_notify_task: Optional[asyncio.Task] = None
|
self._gc_notify_task: Optional[asyncio.Task] = None
|
||||||
|
|
||||||
def add_root_watch(self, root: str, root_path: str) -> None:
|
def add_root_watch(self, root: str, root_path: str) -> None:
|
||||||
@ -1856,15 +1856,15 @@ class INotifyHandler:
|
|||||||
self.notify_filelist_changed("create_file", "gcodes", file_path)
|
self.notify_filelist_changed("create_file", "gcodes", file_path)
|
||||||
|
|
||||||
def queue_gcode_notificaton(self, coro: Coroutine) -> None:
|
def queue_gcode_notificaton(self, coro: Coroutine) -> None:
|
||||||
self.pending_gcode_notifications.append(coro)
|
self.pending_coroutines.append(coro)
|
||||||
if self._gc_notify_task is None:
|
if self._gc_notify_task is None:
|
||||||
self._gc_notify_task = self.event_loop.create_task(
|
self._gc_notify_task = self.event_loop.create_task(
|
||||||
self._process_gcode_notifications()
|
self._process_gcode_notifications()
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _process_gcode_notifications(self) -> None:
|
async def _process_gcode_notifications(self) -> None:
|
||||||
while self.pending_gcode_notifications:
|
while self.pending_coroutines:
|
||||||
coro = self.pending_gcode_notifications.pop(0)
|
coro = self.pending_coroutines.pop(0)
|
||||||
await coro
|
await coro
|
||||||
self._gc_notify_task = None
|
self._gc_notify_task = None
|
||||||
|
|
||||||
@ -1899,14 +1899,14 @@ class INotifyHandler:
|
|||||||
ext in VALID_GCODE_EXTS and
|
ext in VALID_GCODE_EXTS and
|
||||||
action == "create_file"
|
action == "create_file"
|
||||||
):
|
):
|
||||||
prev_info = self.create_gcode_notifications.get(rel_path, {})
|
prev_info = self.processed_gcode_events.get(rel_path, {})
|
||||||
if file_info == prev_info:
|
if file_info == prev_info:
|
||||||
logging.debug("Ignoring duplicate 'create_file' "
|
logging.debug("Ignoring duplicate 'create_file' "
|
||||||
f"notification: {rel_path}")
|
f"notification: {rel_path}")
|
||||||
return
|
return
|
||||||
self.create_gcode_notifications[rel_path] = dict(file_info)
|
self.processed_gcode_events[rel_path] = dict(file_info)
|
||||||
elif rel_path in self.create_gcode_notifications:
|
elif rel_path in self.processed_gcode_events:
|
||||||
del self.create_gcode_notifications[rel_path]
|
del self.processed_gcode_events[rel_path]
|
||||||
file_info['path'] = rel_path
|
file_info['path'] = rel_path
|
||||||
file_info['root'] = root
|
file_info['root'] = root
|
||||||
result = {'action': action, 'item': file_info}
|
result = {'action': action, 'item': file_info}
|
||||||
@ -1937,8 +1937,8 @@ class INotifyHandler:
|
|||||||
self.server.send_event("file_manager:filelist_changed", result)
|
self.server.send_event("file_manager:filelist_changed", result)
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
while self.pending_gcode_notifications:
|
while self.pending_coroutines:
|
||||||
coro = self.pending_gcode_notifications.pop(0)
|
coro = self.pending_coroutines.pop(0)
|
||||||
coro.close()
|
coro.close()
|
||||||
if self._gc_notify_task is not None:
|
if self._gc_notify_task is not None:
|
||||||
self._gc_notify_task.cancel()
|
self._gc_notify_task.cancel()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user