From 467acb47bfe9cb331485099d2676ce35b7babe80 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 11 Jan 2025 11:49:53 +0000 Subject: [PATCH] up2k-snap-load: assert .PARTIAL for unfinished when loading up2k snaps, entries are forgotten if the relevant file has been deleted since last run when the entry is an unfinished upload, the file that should be asserted is the .PARTIAL, and not the placeholder / final filename (which, unintentionally, was the case until now) if .PARTIAL is missing but the placeholder still exists, the only safe alternative is to forget/disown the file, since its state is obviously wrong and unknown --- copyparty/up2k.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 2e3a8e1a..ca1c77b9 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -1119,6 +1119,7 @@ class Up2k(object): reg = {} drp = None emptylist = [] + dotpart = "." if self.args.dotpart else "" snap = os.path.join(histpath, "up2k.snap") if bos.path.exists(snap): with gzip.GzipFile(snap, "rb") as f: @@ -1131,6 +1132,8 @@ class Up2k(object): except: pass + reg = reg2 # diff-golf + if reg2 and "dwrk" not in reg2[next(iter(reg2))]: for job in reg2.values(): job["dwrk"] = job["wark"] @@ -1138,7 +1141,8 @@ class Up2k(object): rm = [] for k, job in reg2.items(): job["ptop"] = ptop - if "done" in job: + is_done = "done" in job + if is_done: job["need"] = job["hash"] = emptylist else: if "need" not in job: @@ -1146,10 +1150,13 @@ class Up2k(object): if "hash" not in job: job["hash"] = [] - fp = djoin(ptop, job["prel"], job["name"]) + if is_done: + fp = djoin(ptop, job["prel"], job["name"]) + else: + fp = djoin(ptop, job["prel"], dotpart + job["name"] + ".PARTIAL") + if bos.path.exists(fp): - reg[k] = job - if "done" in job: + if is_done: continue job["poke"] = time.time() job["busy"] = {}