diff options
author | Juhani Krekelä | 2024-10-11 22:33:32 +0300 |
---|---|---|
committer | Wolfgang Müller | 2024-10-26 19:25:03 +0200 |
commit | 9860a2185b8b4300fb33fe9f59140d591bdc2884 (patch) | |
tree | fd743d918dace18f21ca38ad56baf988ff76e0d8 | |
parent | 90121061eb9cb42f07b15027e2a920841cfe4dfe (diff) | |
download | later-9860a2185b8b4300fb33fe9f59140d591bdc2884.tar.gz |
Don't rely on WatchLaterEntry formatting to track cache liveness
Currently an entry in the cache is marked as live implicitly whenever it
is requested, which only happens when formatting a WatchLaterEntry.
Instead, explicitly mark the entry as live at the same time as the
WatchLaterEntry object is created in entries().
-rwxr-xr-x | later | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -77,9 +77,10 @@ class TitleMap: except Exception as err: sys.exit(f"later: cannot read title cache: {err}") - def get(self, key): + def mark_seen(self, key): self.seen.add(key) + def get(self, key): if key in self.map: return self.map[key] @@ -133,7 +134,7 @@ class TitleMap: sys.exit(f"later: cannot write title cache: {err}") -def entries(): +def entries(title_map): def get_mtime(entry): return entry.stat().st_mtime @@ -154,6 +155,7 @@ def entries(): if name == "redirect entry": continue + title_map.mark_seen(name) yield WatchLaterEntry(name=name, path=entry.path, mtime=mtime) @@ -170,7 +172,7 @@ args = parser.parse_args() title_map = TitleMap(title_map_file, update=args.update_titles) -for entry in entries(): +for entry in entries(title_map): print(entry.format(title_map)) title_map.maybe_commit() |