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
This commit is contained in:
ed 2023-07-14 15:20:25 +00:00
parent 22fc4bb938
commit 77f1e51444

View file

@ -200,7 +200,8 @@ class Up2k(object):
if self.stop: if self.stop:
# up-mt consistency not guaranteed if init is interrupted; # up-mt consistency not guaranteed if init is interrupted;
# drop caches for a full scan on next boot # drop caches for a full scan on next boot
self._drop_caches() with self.mutex:
self._drop_caches()
if self.pp: if self.pp:
self.pp.end = True 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]: if self.args.re_dhash or [zv for zv in vols if "e2tsr" in zv.flags]:
self.args.re_dhash = False self.args.re_dhash = False
self._drop_caches() with self.mutex:
self._drop_caches()
for vol in vols: for vol in vols:
if self.stop: if self.stop: