mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 00:05:21 +01:00
Fix: Always clean up INotify (#9359)
This commit is contained in:
parent
169aa8c8bd
commit
f4413e0a08
1 changed files with 50 additions and 50 deletions
|
|
@ -294,9 +294,9 @@ class Command(BaseCommand):
|
||||||
inotify = INotify()
|
inotify = INotify()
|
||||||
inotify_flags = flags.CLOSE_WRITE | flags.MOVED_TO | flags.MODIFY
|
inotify_flags = flags.CLOSE_WRITE | flags.MOVED_TO | flags.MODIFY
|
||||||
if recursive:
|
if recursive:
|
||||||
descriptor = inotify.add_watch_recursive(directory, inotify_flags)
|
inotify.add_watch_recursive(directory, inotify_flags)
|
||||||
else:
|
else:
|
||||||
descriptor = inotify.add_watch(directory, inotify_flags)
|
inotify.add_watch(directory, inotify_flags)
|
||||||
|
|
||||||
inotify_debounce_secs: Final[float] = settings.CONSUMER_INOTIFY_DELAY
|
inotify_debounce_secs: Final[float] = settings.CONSUMER_INOTIFY_DELAY
|
||||||
inotify_debounce_ms: Final[int] = inotify_debounce_secs * 1000
|
inotify_debounce_ms: Final[int] = inotify_debounce_secs * 1000
|
||||||
|
|
@ -305,6 +305,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
notified_files = {}
|
notified_files = {}
|
||||||
|
|
||||||
|
try:
|
||||||
while not finished:
|
while not finished:
|
||||||
try:
|
try:
|
||||||
for event in inotify.read(timeout=timeout_ms):
|
for event in inotify.read(timeout=timeout_ms):
|
||||||
|
|
@ -354,6 +355,5 @@ class Command(BaseCommand):
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.info("Received SIGINT, stopping inotify")
|
logger.info("Received SIGINT, stopping inotify")
|
||||||
finished = True
|
finished = True
|
||||||
|
finally:
|
||||||
inotify.rm_watch(descriptor)
|
|
||||||
inotify.close()
|
inotify.close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue