diff --git a/copyparty/__main__.py b/copyparty/__main__.py index ee5acc67..c0300bc9 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -244,6 +244,7 @@ def run_argparse(argv, formatter): ap.add_argument("-nw", action="store_true", help="disable writes (benchmark)") ap.add_argument("-nih", action="store_true", help="no info hostname") ap.add_argument("-nid", action="store_true", help="no info disk-usage") + ap.add_argument("--dotpart", action="store_true", help="dotfile incomplete uploads") ap.add_argument("--no-zip", action="store_true", help="disable download as zip/tar") ap.add_argument("--no-sendfile", action="store_true", help="disable sendfile (for debugging)") ap.add_argument("--no-scandir", action="store_true", help="disable scandir (for debugging)") diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 673a2eb2..06b59184 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -789,12 +789,16 @@ class HttpCli(object): except Pebkac: if fname != os.devnull: fp = os.path.join(fdir, fname) + fp2 = fp + if self.args.dotpart: + fp2 = os.path.join(fdir, "." + fname) + suffix = ".PARTIAL" try: - os.rename(fsenc(fp), fsenc(fp + suffix)) + os.rename(fsenc(fp), fsenc(fp2 + suffix)) except: - fp = fp[: -len(suffix)] - os.rename(fsenc(fp), fsenc(fp + suffix)) + fp2 = fp2[: -len(suffix) - 1] + os.rename(fsenc(fp), fsenc(fp2 + suffix)) raise diff --git a/copyparty/up2k.py b/copyparty/up2k.py index c323a223..b49b42d3 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -1198,6 +1198,9 @@ class Up2k(object): # raise Exception("aaa") tnam = job["name"] + ".PARTIAL" + if self.args.dotpart: + tnam = "." + tnam + suffix = ".{:.6f}-{}".format(job["t0"], job["addr"]) with ren_open(tnam, "wb", fdir=pdir, suffix=suffix) as f: f, job["tnam"] = f["orz"]