From 2cd059908ce89a95d7661839dde685c653b1bda5 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sat, 19 Mar 2022 00:22:41 +0100 Subject: [PATCH] Mark output from deleted files --- kitsune | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kitsune b/kitsune index e4eacca..a383a64 100755 --- a/kitsune +++ b/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