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
This commit is contained in:
ed 2025-01-11 11:49:53 +00:00
parent 0c0d6b2bfc
commit 467acb47bf

View file

@ -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"] = []
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"] = {}