fix mojibake upload targets (am train, cant sleep)

This commit is contained in:
ed 2019-07-10 01:15:35 +00:00
parent 0c01156027
commit 051c782c28
4 changed files with 30 additions and 10 deletions

View file

@ -392,7 +392,7 @@ class HttpCli(object):
files.append([sz, sha512_hex])
except Pebkac:
if not nullwrite:
if fn != os.devnull:
os.rename(fsenc(fn), fsenc(fn + ".PARTIAL"))
raise
@ -443,7 +443,7 @@ class HttpCli(object):
),
pre=msg,
)
self.reply(html.encode("utf-8"))
self.reply(html.encode("utf-8", "replace"))
self.parser.drop()
return True
@ -673,7 +673,7 @@ class HttpCli(object):
dirs.extend(files)
html = self.conn.tpl_browser.render(
vdir=self.vpath,
vdir=quotep(self.vpath),
vpnodes=vpnodes,
files=dirs,
can_upload=self.writable,

View file

@ -78,7 +78,11 @@ class SvcHub(object):
self.next_day = calendar.timegm(dt.utctimetuple())
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):
vmin = sys.version_info[1]

View file

@ -506,6 +506,7 @@ function up2k_init(have_crypto) {
var t = st.todo.hash.shift();
st.busy.hash.push(t);
t.t1 = new Date().getTime();
var nchunk = 0;
var chunksize = get_chunksize(t.size);
@ -599,11 +600,11 @@ function up2k_init(have_crypto) {
return segm_next();
}
t.t1 = new Date().getTime();
t.t2 = new Date().getTime();
if (t.n == 0) {
// TODO remove
var spd = (t.size / ((t.t1 - t.t0) / 1000.)) / (1024 * 1024.);
alert('{0} ms, {1} MB/s\n'.format(t.t1 - t.t0, spd.toFixed(3)) + t.hash.join('\n'));
var spd = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
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';
@ -663,8 +664,8 @@ function up2k_init(have_crypto) {
st.busy.handshake.splice(st.busy.handshake.indexOf(t), 1);
if (done) {
var spd1 = (t.size / ((t.t1 - t.t0) / 1000.)) / (1024 * 1024.);
var spd2 = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.);
var spd1 = (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(
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);
t.postlist.splice(t.postlist.indexOf(npart), 1);
if (t.postlist.length == 0) {
t.t2 = new Date().getTime();
t.t3 = new Date().getTime();
o('f{0}t'.format(t.n)).innerHTML = 'verifying';
st.todo.handshake.push(t);
}

View file

@ -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&nbsp;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
@ -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
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