Correct locking on inotify watching, always use updates.
This commit is contained in:
parent
12c954394a
commit
97c694a654
|
@ -1,6 +1,7 @@
|
|||
import asyncio
|
||||
import shutil
|
||||
import stat
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from os import stat_result
|
||||
|
@ -147,11 +148,12 @@ def watcher_thread(loop):
|
|||
rootpath = config.config.path
|
||||
i = inotify.adapters.InotifyTree(rootpath.as_posix())
|
||||
# Initialize the tree from filesystem
|
||||
old, new = state.root, walk()
|
||||
if old != new:
|
||||
with state.lock:
|
||||
new = walk()
|
||||
with state.lock:
|
||||
old = state.root
|
||||
if old != new:
|
||||
state.root = new
|
||||
broadcast(format_root(new), loop)
|
||||
broadcast(format_update(old, new), loop)
|
||||
|
||||
# The watching is not entirely reliable, so do a full refresh every minute
|
||||
refreshdl = time.monotonic() + 60.0
|
||||
|
@ -330,7 +332,7 @@ async def abroadcast(msg):
|
|||
|
||||
async def start(app, loop):
|
||||
config.load_config()
|
||||
use_inotify = False # sys.platform == "linux"
|
||||
use_inotify = sys.platform == "linux"
|
||||
app.ctx.watcher = threading.Thread(
|
||||
target=watcher_thread if use_inotify else watcher_thread_poll,
|
||||
args=[loop],
|
||||
|
|
Loading…
Reference in New Issue
Block a user