[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Merge loaded org-persist index with index file contents
From: |
Timothy |
Subject: |
Re: [PATCH] Merge loaded org-persist index with index file contents |
Date: |
Sun, 11 Dec 2022 19:26:42 +0800 |
User-agent: |
mu4e 1.8.11; emacs 28.2.50 |
Hi Max,
> Please, avoid mixing of system clock and filesystem timestamps.
>
> (file-attribute-modification-time (file-attributes file))
>
> should be more reliable.
Thanks for the tip, I’ve updated the patch to use this.
> In general, I would prefer to avoid relying on timestamps at all, but I am not
> sure if it is possible to implement in elisp with reasonable efforts. The idea
> is to save into file header a hash of content (or a random number). To check
> if file has not been modified, just header is read at first. If hash does not
> match the value stored in memory then it is necessary to read the whole file.
The current approach is certainly sub-optimal, but it’s also simple and unlikely
to cause any issues in practice.
> Another point that I am unsure is if Emacs ensures file locks. If one emacs
> process writes disk cache file then attempts to read the same file by other
> emacs instances must be postponed.
I’m not sure, but you’d need two Emacs instances to try reading/writing the
index file at near-/exactly/ the same time, which seems vanishingly unlikely.
> Cooperation in respect to disk cache would be an improvement, but it may be
> tricky to implement it reliably.
We could just write more often and run `org-persist--merge-index-with-disk' with
some heuristic during operation (if the file is unmodified since it was last
checked nothing will happen). However, I think that’s probably best left to
another conversation — let’s not allow perfect to be the enemy of good here 🙂.
All the best,
Timothy
--
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/tec>.