Skip to content

Commit

Permalink
fix unlikely race (e2tsr):
Browse files Browse the repository at this point in the history
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
  • Loading branch information
9001 committed Jul 14, 2023
1 parent 22fc4bb commit 77f1e51
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions copyparty/up2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def deferred_init(self) -> None:
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
Expand Down Expand Up @@ -594,7 +595,8 @@ def init_indexes(

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:
Expand Down

0 comments on commit 77f1e51

Please sign in to comment.