diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index a625c53a..90ec5fb7 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -496,7 +496,12 @@ class HttpCli(object): self.log("clone {} done".format(cstart[0])) x = self.conn.hsrv.broker.put(True, "up2k.confirm_chunk", ptop, wark, chash) - num_left, path = x.get() + x = x.get() + try: + num_left, path = x + except: + self.loud_reply(x, status=500) + return False if not WINDOWS and num_left == 0: times = (int(time.time()), int(lastmod)) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 75706188..1f09f240 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -421,7 +421,7 @@ class Up2k(object): raise Pebkac(400, "unknown wark") if chash not in job["need"]: - raise Pebkac(200, "already got that but thanks??") + raise Pebkac(400, "already got that but thanks??") nchunk = [n for n, v in enumerate(job["hash"]) if v == chash] if not nchunk: @@ -438,12 +438,19 @@ class Up2k(object): def confirm_chunk(self, ptop, wark, chash): with self.mutex: - job = self.registry[ptop][wark] - pdir = os.path.join(job["ptop"], job["prel"]) - src = os.path.join(pdir, job["tnam"]) - dst = os.path.join(pdir, job["name"]) + try: + job = self.registry[ptop][wark] + pdir = os.path.join(job["ptop"], job["prel"]) + src = os.path.join(pdir, job["tnam"]) + dst = os.path.join(pdir, job["name"]) + except Exception as ex: + return "confirm_chunk, wark, " + repr(ex) + + try: + job["need"].remove(chash) + except Exception as ex: + return "confirm_chunk, chash, " + repr(ex) - job["need"].remove(chash) ret = len(job["need"]) if ret > 0: return ret, src