Compare commits

...

6 Commits

Author SHA1 Message Date
ed
e0d975e36a v0.10.19 2021-05-14 00:00:15 +02:00
ed
cfeb15259f not careful enough 2021-05-13 23:29:15 +02:00
ed
3b3f8fc8fb careful rice 2021-05-13 23:00:51 +02:00
ed
88bd2c084c misc 2021-05-13 22:58:36 +02:00
ed
bd367389b0 broke windows 2021-05-13 22:58:23 +02:00
ed
58ba71a76f option to hide incomplete uploads 2021-05-13 22:56:52 +02:00
9 changed files with 34 additions and 17 deletions

2
.vscode/launch.py vendored
View File

@@ -12,7 +12,7 @@ sys.path.insert(0, os.getcwd())
import jstyleson import jstyleson
from copyparty.__main__ import main as copyparty from copyparty.__main__ import main as copyparty
with open(".vscode/launch.json", "r") as f: with open(".vscode/launch.json", "r", encoding="utf-8") as f:
tj = f.read() tj = f.read()
oj = jstyleson.loads(tj) oj = jstyleson.loads(tj)

View File

@@ -307,7 +307,7 @@ copyparty can invoke external programs to collect additional metadata for files
# browser support # browser support
![copyparty-ie4-fs8](https://user-images.githubusercontent.com/241032/116009043-a1909d80-a617-11eb-9140-037ad6604899.png) ![copyparty-ie4-fs8](https://user-images.githubusercontent.com/241032/118192791-fb31fe00-b446-11eb-9647-898ea8efc1f7.png)
`ie` = internet-explorer, `ff` = firefox, `c` = chrome, `iOS` = iPhone/iPad, `Andr` = Android `ie` = internet-explorer, `ff` = firefox, `c` = chrome, `iOS` = iPhone/iPad, `Andr` = Android

View File

@@ -244,6 +244,7 @@ def run_argparse(argv, formatter):
ap.add_argument("-nw", action="store_true", help="disable writes (benchmark)") 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("-nih", action="store_true", help="no info hostname")
ap.add_argument("-nid", action="store_true", help="no info disk-usage") 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-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-sendfile", action="store_true", help="disable sendfile (for debugging)")
ap.add_argument("--no-scandir", action="store_true", help="disable scandir (for debugging)") ap.add_argument("--no-scandir", action="store_true", help="disable scandir (for debugging)")

View File

@@ -1,8 +1,8 @@
# coding: utf-8 # coding: utf-8
VERSION = (0, 10, 18) VERSION = (0, 10, 19)
CODENAME = "zip it" CODENAME = "zip it"
BUILD_DT = (2021, 5, 13) BUILD_DT = (2021, 5, 14)
S_VERSION = ".".join(map(str, VERSION)) S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)

View File

@@ -789,12 +789,16 @@ class HttpCli(object):
except Pebkac: except Pebkac:
if fname != os.devnull: if fname != os.devnull:
fp = os.path.join(fdir, fname) fp = os.path.join(fdir, fname)
fp2 = fp
if self.args.dotpart:
fp2 = os.path.join(fdir, "." + fname)
suffix = ".PARTIAL" suffix = ".PARTIAL"
try: try:
os.rename(fsenc(fp), fsenc(fp + suffix)) os.rename(fsenc(fp), fsenc(fp2 + suffix))
except: except:
fp = fp[: -len(suffix)] fp2 = fp2[: -len(suffix) - 1]
os.rename(fsenc(fp), fsenc(fp + suffix)) os.rename(fsenc(fp), fsenc(fp2 + suffix))
raise raise

View File

@@ -1198,6 +1198,9 @@ class Up2k(object):
# raise Exception("aaa") # raise Exception("aaa")
tnam = job["name"] + ".PARTIAL" tnam = job["name"] + ".PARTIAL"
if self.args.dotpart:
tnam = "." + tnam
suffix = ".{:.6f}-{}".format(job["t0"], job["addr"]) suffix = ".{:.6f}-{}".format(job["t0"], job["addr"])
with ren_open(tnam, "wb", fdir=pdir, suffix=suffix) as f: with ren_open(tnam, "wb", fdir=pdir, suffix=suffix) as f:
f, job["tnam"] = f["orz"] f, job["tnam"] = f["orz"]

View File

@@ -593,8 +593,8 @@ def sanitize_fn(fn, ok="", bad=[]):
["?", ""], ["?", ""],
["*", ""], ["*", ""],
] ]
for bad, good in [x for x in remap if x[0] not in ok]: for a, b in [x for x in remap if x[0] not in ok]:
fn = fn.replace(bad, good) fn = fn.replace(a, b)
bad.extend(["con", "prn", "aux", "nul"]) bad.extend(["con", "prn", "aux", "nul"])
for n in range(1, 10): for n in range(1, 10):

View File

@@ -6,6 +6,11 @@
<title>{{ title }}</title> <title>{{ title }}</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=0.8"> <meta name="viewport" content="width=device-width, initial-scale=0.8">
<style>
html{font-family:sans-serif}
td{border:1px solid #999;border-width:1px 1px 0 0;padding:0 5px}
a{display:block}
</style>
</head> </head>
<body> <body>

View File

@@ -17,14 +17,15 @@ __license__ = "MIT"
__url__ = "https://github.com/9001/copyparty/" __url__ = "https://github.com/9001/copyparty/"
def get_spd(nbyte, nsec): def get_spd(nbyte, nfiles, nsec):
if not nsec: if not nsec:
return "0.000 MB 0.000 sec 0.000 MB/s" return "0.000 MB 0 files 0.000 sec 0.000 MB/s 0.000 f/s"
mb = nbyte / (1024 * 1024.0) mb = nbyte / (1024 * 1024.0)
spd = mb / nsec spd = mb / nsec
nspd = nfiles / nsec
return f"{mb:.3f} MB {nsec:.3f} sec {spd:.3f} MB/s" return f"{mb:.3f} MB {nfiles} files {nsec:.3f} sec {spd:.3f} MB/s {nspd:.3f} f/s"
class Inf(object): class Inf(object):
@@ -36,6 +37,7 @@ class Inf(object):
self.mtx_reports = threading.Lock() self.mtx_reports = threading.Lock()
self.n_byte = 0 self.n_byte = 0
self.n_file = 0
self.n_sec = 0 self.n_sec = 0
self.n_done = 0 self.n_done = 0
self.t0 = t0 self.t0 = t0
@@ -63,7 +65,8 @@ class Inf(object):
continue continue
msgs = msgs[-64:] msgs = msgs[-64:]
msgs = [f"{get_spd(self.n_byte, self.n_sec)} {x}" for x in msgs] spd = get_spd(self.n_byte, len(self.reports), self.n_sec)
msgs = [f"{spd} {x}" for x in msgs]
print("\n".join(msgs)) print("\n".join(msgs))
def report(self, fn, n_byte, n_sec): def report(self, fn, n_byte, n_sec):
@@ -131,8 +134,9 @@ def main():
num_threads = 8 num_threads = 8
read_sz = 32 * 1024 read_sz = 32 * 1024
targs = (q, inf, read_sz)
for _ in range(num_threads): for _ in range(num_threads):
thr = threading.Thread(target=worker, args=(q, inf, read_sz,)) thr = threading.Thread(target=worker, args=targs)
thr.daemon = True thr.daemon = True
thr.start() thr.start()
@@ -151,14 +155,14 @@ def main():
log = inf.reports log = inf.reports
log.sort() log.sort()
for nbyte, nsec, fn in log[-64:]: for nbyte, nsec, fn in log[-64:]:
print(f"{get_spd(nbyte, nsec)} {fn}") spd = get_spd(nbyte, len(log), nsec)
print(f"{spd} {fn}")
print() print()
print("\n".join(inf.errors)) print("\n".join(inf.errors))
print(get_spd(inf.n_byte, t2 - t0)) print(get_spd(inf.n_byte, len(log), t2 - t0))
if __name__ == "__main__": if __name__ == "__main__":
main() main()