From feecb3e0b8375c54c6c318adf3c700fda1010ea6 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 18 Apr 2024 16:43:38 +0000 Subject: [PATCH] up2k: fix put-hasher dying + a harmless race * hasher thread could die if a client would rapidly upload and delete files (so very unlikely) * two unprotected calls to register_vpath which was almost-definitely safe because the volumes already existed in the registry --- copyparty/up2k.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 015e9e7b..e9b13197 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -811,7 +811,9 @@ class Up2k(object): self.volstate[vol.vpath] = "online (mtp soon)" for vol in need_vac: - reg = self.register_vpath(vol.realpath, vol.flags) + with self.mutex, self.reg_mutex: + reg = self.register_vpath(vol.realpath, vol.flags) + assert reg cur, _ = reg with self.mutex: @@ -825,7 +827,9 @@ class Up2k(object): if vol.flags["dbd"] == "acid": continue - reg = self.register_vpath(vol.realpath, vol.flags) + with self.mutex, self.reg_mutex: + reg = self.register_vpath(vol.realpath, vol.flags) + try: assert reg cur, db_path = reg @@ -4251,7 +4255,7 @@ class Up2k(object): raise Exception("invalid hash task") try: - if not self._hash_t(task): + if not self._hash_t(task) and self.stop: return except Exception as ex: self.log("failed to hash %s: %s" % (task, ex), 1)