From 77f1e5144455eb946db7368792ea11c934f0f6da Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 14 Jul 2023 15:20:25 +0000 Subject: [PATCH] fix unlikely race (e2tsr): if someone with admin rights refreshes the homepage exactly as the directory indexer decides to `_drop_caches`, the indexer thread would die and the up2k instance would become inoperable... luckily the probability of hitting this by chance is absolutely minimal, and the worst case scenario is having to restart copyparty if this happens immediately after startup; there is no risk of database damage --- copyparty/up2k.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index b6aaa69b..f4b3e53f 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -200,7 +200,8 @@ class Up2k(object): if self.stop: # up-mt consistency not guaranteed if init is interrupted; # drop caches for a full scan on next boot - self._drop_caches() + with self.mutex: + self._drop_caches() if self.pp: self.pp.end = True @@ -594,7 +595,8 @@ class Up2k(object): if self.args.re_dhash or [zv for zv in vols if "e2tsr" in zv.flags]: self.args.re_dhash = False - self._drop_caches() + with self.mutex: + self._drop_caches() for vol in vols: if self.stop: