Skip to content

Commit

Permalink
up2k-snap-load: assert .PARTIAL for unfinished
Browse files Browse the repository at this point in the history
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
  • Loading branch information
9001 committed Jan 11, 2025
1 parent 0c0d6b2 commit 467acb4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions copyparty/up2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ def register_vpath(
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:
Expand All @@ -1131,25 +1132,31 @@ def register_vpath(
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"]

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:
job["need"] = []
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"] = {}
Expand Down

0 comments on commit 467acb4

Please sign in to comment.