khal icon indicating copy to clipboard operation
khal copied to clipboard

Cache DB is only updated when directory timestamp changes

Open Lodifice opened this issue 4 years ago • 5 comments

This assumes that my calendar is a directory of .ics files. Can someone please explain why the cache db is only updated when the timestamp of the directory changes, but not, when the timestamp of a file within that directory (i.e. an event) changes? I'm assuming it's for performance reasons because these directories can get quite large. I think this behaviour should be documented in a clear way, as I spent quite some time trying to figure out what was going on when my (manual) change of an .ics file wasn't recognized by khal.

Lodifice avatar Nov 04 '21 14:11 Lodifice

We shoul pick up this kind of change. Sounds like a bug.

WhyNotHugo avatar Nov 04 '21 21:11 WhyNotHugo

If I've understood the code correctly, then in khalendar/vdir.py the function get_etag_from_file is called with a directory as an argument. So a fix could be to check if the opened file is a directory and, if that's the case, walk through it and collect the highest mtime.

Lodifice avatar Nov 05 '21 07:11 Lodifice

Totally agree, this should be documented and perhaps a command to force a refresh would be nice as well.

geier avatar Jan 07 '22 23:01 geier

So you propose to leave the current behaviour as it is, document it properly, and add a command to force a refresh? The first two points sound fine to me. However, I do not quite understand how far the "forced refresh" would go. From my point of view, it's only necessary to recurse into directories and compare the timestamps of individual files. One could, on the other side, also do the update disregarding the timestamps completely.

Lodifice avatar Jan 17 '22 11:01 Lodifice

Depending on how many files are in the vdirs, reading the timestamps of all files takes noticeable time. IIRC that is the reason for the current behaviour (also back then a lot of people still had rotating hard discs, so perhaps that is also less relevant today).

geier avatar Jun 26 '22 21:06 geier