Tolerate vanished files

This commit is contained in:
Peter J. Holzer 2023-08-24 07:57:49 +02:00
parent c619e74e15
commit 29491e1639
1 changed files with 9 additions and 3 deletions

12
kitsune
View File

@ -90,9 +90,15 @@ def watch(args):
for ln in lines: for ln in lines:
print(f"{f.path:{filename_length}}", format_ts(f.last_ts), dead, ln) print(f"{f.path:{filename_length}}", format_ts(f.last_ts), dead, ln)
else: else:
stf = os.stat(f.path) try:
if stf.st_ctime_ns != f.st_ctime_ns: stf = os.stat(f.path)
f.reopen() if stf.st_ctime_ns != f.st_ctime_ns:
f.reopen()
except FileNotFoundError:
# ignore,
# or maybe remove from watched_files?
# or just mark as deleted?
pass
time.sleep(0.1) time.sleep(0.1)
seek_to_end = False seek_to_end = False