From 3e50149d4d06afebc3e68097b2b2c6ec92da9d34 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 13 Nov 2023 16:28:53 -0800 Subject: [PATCH] Add more quit points for watching thread. --- cista/watching.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cista/watching.py b/cista/watching.py index a42bb0b..bd9e647 100644 --- a/cista/watching.py +++ b/cista/watching.py @@ -129,7 +129,7 @@ def watcher_thread(loop): global rootpath import inotify.adapters - while True: + while not quit: rootpath = config.config.path i = inotify.adapters.InotifyTree(rootpath.as_posix()) # Initialize the tree from filesystem @@ -218,11 +218,15 @@ def _walk(rel: PurePosixPath, isfile: int, st: stat_result) -> list[FileEntry]: try: li = [] for f in path.iterdir(): + if quit: + raise SystemExit("quit") if f.name.startswith("."): continue # No dotfiles s = f.stat() li.append((int(not stat.S_ISDIR(s.st_mode)), f.name, s)) for [isfile, name, s] in humansorted(li): + if quit: + raise SystemExit("quit") subtree = _walk(rel / name, isfile, s) child = subtree[0] entry.mtime = max(entry.mtime, child.mtime)