mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
fix mojibake upload targets (am train, cant sleep)
This commit is contained in:
parent
0c01156027
commit
051c782c28
|
@ -392,7 +392,7 @@ class HttpCli(object):
|
||||||
files.append([sz, sha512_hex])
|
files.append([sz, sha512_hex])
|
||||||
|
|
||||||
except Pebkac:
|
except Pebkac:
|
||||||
if not nullwrite:
|
if fn != os.devnull:
|
||||||
os.rename(fsenc(fn), fsenc(fn + ".PARTIAL"))
|
os.rename(fsenc(fn), fsenc(fn + ".PARTIAL"))
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
@ -443,7 +443,7 @@ class HttpCli(object):
|
||||||
),
|
),
|
||||||
pre=msg,
|
pre=msg,
|
||||||
)
|
)
|
||||||
self.reply(html.encode("utf-8"))
|
self.reply(html.encode("utf-8", "replace"))
|
||||||
self.parser.drop()
|
self.parser.drop()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ class HttpCli(object):
|
||||||
|
|
||||||
dirs.extend(files)
|
dirs.extend(files)
|
||||||
html = self.conn.tpl_browser.render(
|
html = self.conn.tpl_browser.render(
|
||||||
vdir=self.vpath,
|
vdir=quotep(self.vpath),
|
||||||
vpnodes=vpnodes,
|
vpnodes=vpnodes,
|
||||||
files=dirs,
|
files=dirs,
|
||||||
can_upload=self.writable,
|
can_upload=self.writable,
|
||||||
|
|
|
@ -78,7 +78,11 @@ class SvcHub(object):
|
||||||
self.next_day = calendar.timegm(dt.utctimetuple())
|
self.next_day = calendar.timegm(dt.utctimetuple())
|
||||||
|
|
||||||
ts = datetime.utcfromtimestamp(now).strftime("%H:%M:%S.%f")[:-3]
|
ts = datetime.utcfromtimestamp(now).strftime("%H:%M:%S.%f")[:-3]
|
||||||
print("\033[36m{} \033[33m{:21} \033[0m{}".format(ts, src, msg))
|
msg = "\033[36m{} \033[33m{:21} \033[0m{}".format(ts, src, msg)
|
||||||
|
try:
|
||||||
|
print(msg)
|
||||||
|
except UnicodeEncodeError as ex:
|
||||||
|
print(msg.encode("utf-8", "replace").decode())
|
||||||
|
|
||||||
def check_mp_support(self):
|
def check_mp_support(self):
|
||||||
vmin = sys.version_info[1]
|
vmin = sys.version_info[1]
|
||||||
|
|
|
@ -506,6 +506,7 @@ function up2k_init(have_crypto) {
|
||||||
|
|
||||||
var t = st.todo.hash.shift();
|
var t = st.todo.hash.shift();
|
||||||
st.busy.hash.push(t);
|
st.busy.hash.push(t);
|
||||||
|
t.t1 = new Date().getTime();
|
||||||
|
|
||||||
var nchunk = 0;
|
var nchunk = 0;
|
||||||
var chunksize = get_chunksize(t.size);
|
var chunksize = get_chunksize(t.size);
|
||||||
|
@ -599,11 +600,11 @@ function up2k_init(have_crypto) {
|
||||||
return segm_next();
|
return segm_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
t.t1 = new Date().getTime();
|
t.t2 = new Date().getTime();
|
||||||
if (t.n == 0) {
|
if (t.n == 0) {
|
||||||
// TODO remove
|
// TODO remove
|
||||||
var spd = (t.size / ((t.t1 - t.t0) / 1000.)) / (1024 * 1024.);
|
var spd = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
|
||||||
alert('{0} ms, {1} MB/s\n'.format(t.t1 - t.t0, spd.toFixed(3)) + t.hash.join('\n'));
|
alert('{0} ms, {1} MB/s\n'.format(t.t2 - t.t1, spd.toFixed(3)) + t.hash.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
o('f{0}t'.format(t.n)).innerHTML = 'connecting';
|
o('f{0}t'.format(t.n)).innerHTML = 'connecting';
|
||||||
|
@ -663,8 +664,8 @@ function up2k_init(have_crypto) {
|
||||||
st.busy.handshake.splice(st.busy.handshake.indexOf(t), 1);
|
st.busy.handshake.splice(st.busy.handshake.indexOf(t), 1);
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
var spd1 = (t.size / ((t.t1 - t.t0) / 1000.)) / (1024 * 1024.);
|
var spd1 = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
|
||||||
var spd2 = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
|
var spd2 = (t.size / ((t.t3 - t.t2) / 1000.)) / (1024 * 1024.);
|
||||||
o('f{0}p'.format(t.n)).innerHTML = 'hash {0}, up {1} MB/s'.format(
|
o('f{0}p'.format(t.n)).innerHTML = 'hash {0}, up {1} MB/s'.format(
|
||||||
spd1.toFixed(2), spd2.toFixed(2));
|
spd1.toFixed(2), spd2.toFixed(2));
|
||||||
}
|
}
|
||||||
|
@ -724,7 +725,7 @@ function up2k_init(have_crypto) {
|
||||||
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
||||||
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
||||||
if (t.postlist.length == 0) {
|
if (t.postlist.length == 0) {
|
||||||
t.t2 = new Date().getTime();
|
t.t3 = new Date().getTime();
|
||||||
o('f{0}t'.format(t.n)).innerHTML = 'verifying';
|
o('f{0}t'.format(t.n)).innerHTML = 'verifying';
|
||||||
st.todo.handshake.push(t);
|
st.todo.handshake.push(t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,14 @@ mkdir -p "${dirs[@]}"
|
||||||
for dir in "${dirs[@]}"; do for fn in ふが "$(printf \\xed\\x93)" 'qwe,rty;asd fgh+jkl%zxc&vbn <qwe>"rty'"'"'uio&asd fgh'; do echo "$dir" > "$dir/$fn.html"; done; done
|
for dir in "${dirs[@]}"; do for fn in ふが "$(printf \\xed\\x93)" 'qwe,rty;asd fgh+jkl%zxc&vbn <qwe>"rty'"'"'uio&asd fgh'; do echo "$dir" > "$dir/$fn.html"; done; done
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## upload mojibake
|
||||||
|
|
||||||
|
fn=$(printf '\xba\xdc\xab.cab')
|
||||||
|
echo asdf > "$fn"
|
||||||
|
curl --cookie cppwd=wark -sF "act=bput" -F "f=@$fn" http://127.0.0.1:1234/moji/%ED%91/
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## test compression
|
## test compression
|
||||||
|
|
||||||
|
@ -61,3 +69,10 @@ ps ax | awk '/python[23]? -m copyparty|python[ ]-c from multiproc/ {print $1}' |
|
||||||
|
|
||||||
# last line of each function in a file
|
# last line of each function in a file
|
||||||
cat copyparty/httpcli.py | awk '/^[^a-zA-Z0-9]+def / {printf "%s\n%s\n\n", f, pl; f=$2} /[a-zA-Z0-9]/ {pl=$0}'
|
cat copyparty/httpcli.py | awk '/^[^a-zA-Z0-9]+def / {printf "%s\n%s\n\n", f, pl; f=$2} /[a-zA-Z0-9]/ {pl=$0}'
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## meta
|
||||||
|
|
||||||
|
# create a folder with symlinks to big files
|
||||||
|
for d in /usr /var; do find $d -type f -size +30M 2>/dev/null; done | while IFS= read -r x; do ln -s "$x" big/; done
|
||||||
|
|
Loading…
Reference in a new issue