Mark output from deleted files
This commit is contained in:
parent
9ab32e5b6b
commit
2cd059908c
4
kitsune
4
kitsune
|
@ -64,6 +64,7 @@ def watch(args):
|
|||
stf = os.stat(f.path)
|
||||
if stf.st_ino != st.st_ino:
|
||||
f.reopen()
|
||||
st = os.stat(f.fileno)
|
||||
except FileNotFoundError:
|
||||
# ignore,
|
||||
# or maybe remove from watched_files?
|
||||
|
@ -74,13 +75,14 @@ def watch(args):
|
|||
# We are beyond the end of the file, so it has probably
|
||||
# been truncated and rewritten - read from beginning
|
||||
f.fd.seek(0, 0)
|
||||
dead = "✝" if st.st_nlink == 0 else " "
|
||||
f.last_ts = st.st_mtime_ns
|
||||
new_content = f.fd.read()
|
||||
lines = new_content.split("\n")
|
||||
if lines[-1] == "":
|
||||
lines.pop()
|
||||
for ln in lines:
|
||||
print(f"{f.path:{filename_length}}", format_ts(f.last_ts), ln)
|
||||
print(f"{f.path:{filename_length}}", format_ts(f.last_ts), dead, ln)
|
||||
time.sleep(0.1)
|
||||
seek_to_end = False
|
||||
|
||||
|
|
Loading…
Reference in New Issue