mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
up2k: fix filesystem toctou
previously and currently, as an upload completes, its "done" flag is not set until all the data has been flushed to disk however, the list of missing chunks becomes empty before the flush, and that list was incorrectly used to determine completion state in some dedup-related logic as a result, duplicate uploads could initially fail, and would succeed after the client automatically retried a handful of times
This commit is contained in:
parent
b2770a2087
commit
114b71b751
|
@ -2966,7 +2966,7 @@ class Up2k(object):
|
||||||
path = djoin(rj["ptop"], rj["prel"], fn)
|
path = djoin(rj["ptop"], rj["prel"], fn)
|
||||||
try:
|
try:
|
||||||
st = bos.stat(path)
|
st = bos.stat(path)
|
||||||
if st.st_size > 0 or not rj["need"]:
|
if st.st_size > 0 or "done" in rj:
|
||||||
# upload completed or both present
|
# upload completed or both present
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
|
@ -2980,7 +2980,7 @@ class Up2k(object):
|
||||||
inc_ap = djoin(cj["ptop"], cj["prel"], cj["name"])
|
inc_ap = djoin(cj["ptop"], cj["prel"], cj["name"])
|
||||||
orig_ap = djoin(rj["ptop"], rj["prel"], rj["name"])
|
orig_ap = djoin(rj["ptop"], rj["prel"], rj["name"])
|
||||||
|
|
||||||
if self.args.nw or n4g or not st:
|
if self.args.nw or n4g or not st or "done" not in rj:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif st.st_size != rj["size"]:
|
elif st.st_size != rj["size"]:
|
||||||
|
@ -3012,7 +3012,7 @@ class Up2k(object):
|
||||||
dst = djoin(cj["ptop"], cj["prel"], cj["name"])
|
dst = djoin(cj["ptop"], cj["prel"], cj["name"])
|
||||||
vsrc = djoin(job["vtop"], job["prel"], job["name"])
|
vsrc = djoin(job["vtop"], job["prel"], job["name"])
|
||||||
vsrc = vsrc.replace("\\", "/") # just for prints anyways
|
vsrc = vsrc.replace("\\", "/") # just for prints anyways
|
||||||
if job["need"]:
|
if "done" not in job:
|
||||||
self.log("unfinished:\n {0}\n {1}".format(src, dst))
|
self.log("unfinished:\n {0}\n {1}".format(src, dst))
|
||||||
err = "partial upload exists at a different location; please resume uploading here instead:\n"
|
err = "partial upload exists at a different location; please resume uploading here instead:\n"
|
||||||
err += "/" + quotep(vsrc) + " "
|
err += "/" + quotep(vsrc) + " "
|
||||||
|
|
Loading…
Reference in a new issue