up2k: discard empty PARTIALs

This commit is contained in:
ed 2021-01-23 18:10:11 +01:00
parent 46e70d50b7
commit 634657bea1

View file

@ -335,6 +335,7 @@ class Up2k(object):
"name", "name",
"size", "size",
"lmod", "lmod",
"poke",
]: ]:
job[k] = cj[k] job[k] = cj[k]
@ -458,9 +459,8 @@ class Up2k(object):
db.execute("delete from up where rp = ?", (rp,)) db.execute("delete from up where rp = ?", (rp,))
def db_add(self, db, wark, rp, ts, sz): def db_add(self, db, wark, rp, ts, sz):
db.execute( v = (wark, ts, sz, rp)
"insert into up values (?,?,?,?)", (wark, ts, sz, rp,), db.execute("insert into up values (?,?,?,?)", v)
)
def _get_wark(self, cj): def _get_wark(self, cj):
if len(cj["name"]) > 1024 or len(cj["hash"]) > 512 * 1024: # 16TiB if len(cj["name"]) > 1024 or len(cj["hash"]) > 512 * 1024: # 16TiB
@ -563,10 +563,15 @@ class Up2k(object):
for job in rm: for job in rm:
del reg[job["wark"]] del reg[job["wark"]]
try: try:
# remove the placeholder zero-byte file (keep the PARTIAL) # remove the filename reservation
path = os.path.join(job["ptop"], job["prel"], job["name"]) path = os.path.join(job["ptop"], job["prel"], job["name"])
if os.path.getsize(path) == 0: if os.path.getsize(path) == 0:
os.unlink(path) os.unlink(path)
if len(job["hash"]) == len(job["need"]):
# PARTIAL is empty, delete that too
path = os.path.join(job["ptop"], job["prel"], job["tnam"])
os.unlink(path)
except: except:
pass pass