Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4bb4e3a73 | ||
|
|
d25612d038 | ||
|
|
116b2351b0 | ||
|
|
69b83dfdc4 | ||
|
|
3b1839c2ce | ||
|
|
13742ebdf8 | ||
|
|
634657bea1 |
@@ -142,6 +142,7 @@ roughly sorted by priority
|
||||
* terminate client on bad data
|
||||
* drop onto folders
|
||||
* `os.copy_file_range` for up2k cloning
|
||||
* up2k partials ui
|
||||
* support pillow-simd
|
||||
* cache sha512 chunks on client
|
||||
* comment field
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# coding: utf-8
|
||||
|
||||
VERSION = (0, 7, 0)
|
||||
VERSION = (0, 7, 1)
|
||||
CODENAME = "keeping track"
|
||||
BUILD_DT = (2021, 1, 10)
|
||||
BUILD_DT = (2021, 1, 23)
|
||||
|
||||
S_VERSION = ".".join(map(str, VERSION))
|
||||
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
|
||||
|
||||
@@ -291,7 +291,16 @@ class Up2k(object):
|
||||
|
||||
if job or wark in reg:
|
||||
job = job or reg[wark]
|
||||
if job["prel"] != cj["prel"] or job["name"] != cj["name"]:
|
||||
if job["prel"] == cj["prel"] and job["name"] == cj["name"]:
|
||||
# ensure the files haven't been deleted manually
|
||||
names = [job[x] for x in ["name", "tnam"] if x in job]
|
||||
for fn in names:
|
||||
path = os.path.join(job["ptop"], job["prel"], fn)
|
||||
if not os.path.exists(path):
|
||||
job = None
|
||||
break
|
||||
else:
|
||||
# file contents match, but not the path
|
||||
src = os.path.join(job["ptop"], job["prel"], job["name"])
|
||||
dst = os.path.join(cj["ptop"], cj["prel"], cj["name"])
|
||||
vsrc = os.path.join(job["vtop"], job["prel"], job["name"])
|
||||
@@ -335,6 +344,7 @@ class Up2k(object):
|
||||
"name",
|
||||
"size",
|
||||
"lmod",
|
||||
"poke",
|
||||
]:
|
||||
job[k] = cj[k]
|
||||
|
||||
@@ -458,9 +468,8 @@ class Up2k(object):
|
||||
db.execute("delete from up where rp = ?", (rp,))
|
||||
|
||||
def db_add(self, db, wark, rp, ts, sz):
|
||||
db.execute(
|
||||
"insert into up values (?,?,?,?)", (wark, ts, sz, rp,),
|
||||
)
|
||||
v = (wark, ts, sz, rp)
|
||||
db.execute("insert into up values (?,?,?,?)", v)
|
||||
|
||||
def _get_wark(self, cj):
|
||||
if len(cj["name"]) > 1024 or len(cj["hash"]) > 512 * 1024: # 16TiB
|
||||
@@ -563,10 +572,15 @@ class Up2k(object):
|
||||
for job in rm:
|
||||
del reg[job["wark"]]
|
||||
try:
|
||||
# remove the placeholder zero-byte file (keep the PARTIAL)
|
||||
# remove the filename reservation
|
||||
path = os.path.join(job["ptop"], job["prel"], job["name"])
|
||||
if os.path.getsize(path) == 0:
|
||||
os.unlink(path)
|
||||
|
||||
if len(job["hash"]) == len(job["need"]):
|
||||
# PARTIAL is empty, delete that too
|
||||
path = os.path.join(job["ptop"], job["prel"], job["tnam"])
|
||||
os.unlink(path)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@@ -262,6 +262,7 @@ function up2k_init(have_crypto) {
|
||||
|
||||
more_one_file();
|
||||
var bad_files = [];
|
||||
var good_files = [];
|
||||
for (var a = 0; a < files.length; a++) {
|
||||
var fobj = files[a];
|
||||
if (is_itemlist) {
|
||||
@@ -275,9 +276,32 @@ function up2k_init(have_crypto) {
|
||||
throw 1;
|
||||
}
|
||||
catch (ex) {
|
||||
bad_files.push([a, fobj.name]);
|
||||
bad_files.push(fobj.name);
|
||||
continue;
|
||||
}
|
||||
good_files.push(fobj);
|
||||
}
|
||||
|
||||
if (bad_files.length > 0) {
|
||||
var msg = 'These {0} files (of {1} total) were skipped because they are empty:\n'.format(bad_files.length, files.length);
|
||||
for (var a = 0; a < bad_files.length; a++)
|
||||
msg += '-- ' + bad_files[a] + '\n';
|
||||
|
||||
if (files.length - bad_files.length <= 1 && /(android)/i.test(navigator.userAgent))
|
||||
msg += '\nFirefox-Android has a bug which prevents selecting multiple files. Try selecting one file at a time. For more info, see firefox bug 1456557';
|
||||
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
var msg = ['upload these ' + good_files.length + ' files?'];
|
||||
for (var a = 0; a < good_files.length; a++)
|
||||
msg.push(good_files[a].name);
|
||||
|
||||
if (!confirm(msg.join('\n')))
|
||||
return;
|
||||
|
||||
for (var a = 0; a < good_files.length; a++) {
|
||||
var fobj = good_files[a];
|
||||
var now = new Date().getTime();
|
||||
var lmod = fobj.lastModified || now;
|
||||
var entry = {
|
||||
@@ -307,17 +331,6 @@ function up2k_init(have_crypto) {
|
||||
st.files.push(entry);
|
||||
st.todo.hash.push(entry);
|
||||
}
|
||||
|
||||
if (bad_files.length > 0) {
|
||||
var msg = 'These {0} files (of {1} total) were skipped because they are empty:\n'.format(bad_files.length, files.length);
|
||||
for (var a = 0; a < bad_files.length; a++)
|
||||
msg += '-- ' + bad_files[a][1] + '\n';
|
||||
|
||||
if (files.length - bad_files.length <= 1 && /(android)/i.test(navigator.userAgent))
|
||||
msg += '\nFirefox-Android has a bug which prevents selecting multiple files. Try selecting one file at a time. For more info, see firefox bug 1456557';
|
||||
|
||||
alert(msg);
|
||||
}
|
||||
}
|
||||
ebi('u2btn').addEventListener('drop', gotfile, false);
|
||||
|
||||
@@ -336,16 +349,17 @@ function up2k_init(have_crypto) {
|
||||
//
|
||||
|
||||
function handshakes_permitted() {
|
||||
return multitask || (
|
||||
st.todo.upload.length == 0 &&
|
||||
st.busy.upload.length == 0);
|
||||
var lim = multitask ? 1 : 0;
|
||||
return lim >=
|
||||
st.todo.upload.length +
|
||||
st.busy.upload.length;
|
||||
}
|
||||
|
||||
function hashing_permitted() {
|
||||
return multitask || (
|
||||
handshakes_permitted() &&
|
||||
st.todo.handshake.length == 0 &&
|
||||
st.busy.handshake.length == 0);
|
||||
var lim = multitask ? 1 : 0;
|
||||
return handshakes_permitted() && lim >=
|
||||
st.todo.handshake.length +
|
||||
st.busy.handshake.length;
|
||||
}
|
||||
|
||||
var tasker = (function () {
|
||||
|
||||
@@ -3,6 +3,14 @@ echo not a script
|
||||
exit 1
|
||||
|
||||
|
||||
##
|
||||
## delete all partial uploads
|
||||
## (supports linux/macos, probably windows+msys2)
|
||||
|
||||
gzip -d < .hist/up2k.snap | jq -r '.[].tnam' | while IFS= read -r f; do rm -f -- "$f"; done
|
||||
gzip -d < .hist/up2k.snap | jq -r '.[].name' | while IFS= read -r f; do wc -c -- "$f" | grep -qiE '^[^0-9a-z]*0' & rm -f -- "$f"; done
|
||||
|
||||
|
||||
##
|
||||
## create a test payload
|
||||
|
||||
|
||||
@@ -18,13 +18,16 @@ echo
|
||||
# (the fancy markdown editor)
|
||||
|
||||
|
||||
command -v gtar >/dev/null &&
|
||||
command -v gfind >/dev/null && {
|
||||
tar() { gtar "$@"; }
|
||||
# port install gnutar findutils gsed coreutils
|
||||
gtar=$(command -v gtar || command -v gnutar) || true
|
||||
[ ! -z "$gtar" ] && command -v gfind >/dev/null && {
|
||||
tar() { $gtar "$@"; }
|
||||
sed() { gsed "$@"; }
|
||||
find() { gfind "$@"; }
|
||||
sort() { gsort "$@"; }
|
||||
unexpand() { gunexpand "$@"; }
|
||||
command -v grealpath >/dev/null &&
|
||||
realpath() { grealpath "$@"; }
|
||||
}
|
||||
|
||||
[ -e copyparty/__main__.py ] || cd ..
|
||||
|
||||
Reference in New Issue
Block a user