Compare commits

...

3 Commits

Author SHA1 Message Date
ed
e34634f5af v1.2.5 2022-04-15 19:42:40 +02:00
ed
cba9e5b669 add hardlinks (symlink alternative) for up2k dedup 2022-04-15 19:13:53 +02:00
ed
1f3c46a6b0 forgot some css files 2022-04-15 17:11:46 +02:00
14 changed files with 166 additions and 124 deletions

View File

@@ -426,7 +426,9 @@ def run_argparse(argv, formatter):
ap2.add_argument("--unpost", metavar="SEC", type=int, default=3600*12, help="grace period where uploads can be deleted by the uploader, even without delete permissions; 0=disabled")
ap2.add_argument("--no-fpool", action="store_true", help="disable file-handle pooling -- instead, repeatedly close and reopen files during upload")
ap2.add_argument("--use-fpool", action="store_true", help="force file-handle pooling, even if copyparty thinks you're better off without")
ap2.add_argument("--no-symlink", action="store_true", help="duplicate file contents instead")
ap2.add_argument("--hardlink", action="store_true", help="prefer hardlinks instead of symlinks when possible (same filesystem)")
ap2.add_argument("--never-symlink", action="store_true", help="do not fallback to symlinks when a hardlink cannot be made")
ap2.add_argument("--no-dedup", action="store_true", help="disable symlink/hardlink creation; copy file contents instead")
ap2.add_argument("--reg-cap", metavar="N", type=int, default=9000, help="max number of uploads to keep in memory when running without -e2d")
ap2 = ap.add_argument_group('network options')

View File

@@ -1,8 +1,8 @@
# coding: utf-8
VERSION = (1, 2, 4)
VERSION = (1, 2, 5)
CODENAME = "ftp btw"
BUILD_DT = (2022, 4, 14)
BUILD_DT = (2022, 4, 15)
S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)

View File

@@ -74,6 +74,9 @@ class SvcHub(object):
ch = "abcdefghijklmnopqrstuvwx"[int(args.theme / 2)]
args.theme = "{0}{1} {0} {1}".format(ch, bri)
if not args.hardlink and args.never_symlink:
args.no_dedup = True
# initiate all services to manage
self.asrv = AuthSrv(self.args, self.log)
if args.ls:

View File

@@ -1240,6 +1240,11 @@ class Up2k(object):
wark = self._get_wark(cj)
now = time.time()
job = None
try:
dev = bos.stat(os.path.join(cj["ptop"], cj["prel"])).st_dev
except:
dev = 0
with self.mutex:
cur = self.cur.get(cj["ptop"])
reg = self.registry[cj["ptop"]]
@@ -1251,37 +1256,42 @@ class Up2k(object):
q = r"select * from up where substr(w,1,16) = ? and w = ?"
argv = (wark[:16], wark)
alts = []
cur = cur.execute(q, argv)
for _, dtime, dsize, dp_dir, dp_fn, ip, at in cur:
if dp_dir.startswith("//") or dp_fn.startswith("//"):
dp_dir, dp_fn = s3dec(dp_dir, dp_fn)
if job and (dp_dir != cj["prel"] or dp_fn != cj["name"]):
dp_abs = "/".join([cj["ptop"], dp_dir, dp_fn])
try:
st = bos.stat(dp_abs)
if stat.S_ISLNK(st.st_mode):
# broken symlink
raise Exception()
except:
continue
dp_abs = "/".join([cj["ptop"], dp_dir, dp_fn])
# relying on this to fail on broken symlinks
try:
sz = bos.path.getsize(dp_abs)
except:
sz = 0
if sz:
# self.log("--- " + wark + " " + dp_abs + " found file", 4)
job = {
"name": dp_fn,
"prel": dp_dir,
"vtop": cj["vtop"],
"ptop": cj["ptop"],
"size": dsize,
"lmod": dtime,
"addr": ip,
"at": at,
"hash": [],
"need": [],
"busy": {},
}
j = {
"name": dp_fn,
"prel": dp_dir,
"vtop": cj["vtop"],
"ptop": cj["ptop"],
"size": dsize,
"lmod": dtime,
"addr": ip,
"at": at,
"hash": [],
"need": [],
"busy": {},
}
score = (
(3 if st.st_dev == dev else 0)
+ (2 if dp_dir == cj["prel"] else 0)
+ (1 if dp_fn == cj["name"] else 0)
)
alts.append([score, -len(alts), j])
job = sorted(alts, reverse=True)[0][2] if alts else None
if job and wark in reg:
# self.log("pop " + wark + " " + job["name"] + " handle_json db", 4)
del reg[wark]
@@ -1422,14 +1432,14 @@ class Up2k(object):
linked = False
try:
if self.args.no_symlink:
if self.args.no_dedup:
raise Exception("disabled in config")
lsrc = src
ldst = dst
fs1 = bos.stat(os.path.dirname(src)).st_dev
fs2 = bos.stat(os.path.dirname(dst)).st_dev
if fs1 == 0:
if fs1 == 0 or fs2 == 0:
# py2 on winxp or other unsupported combination
raise OSError()
elif fs1 == fs2:
@@ -1450,10 +1460,21 @@ class Up2k(object):
lsrc = nsrc[nc:]
hops = len(ndst[nc:]) - 1
lsrc = "../" * hops + "/".join(lsrc)
os.symlink(fsenc(lsrc), fsenc(ldst))
linked = True
try:
if self.args.hardlink:
os.link(fsenc(src), fsenc(dst))
linked = True
except Exception as ex:
self.log("cannot hardlink: " + repr(ex))
if self.args.never_symlink:
raise Exception("symlink-fallback disabled in cfg")
if not linked:
os.symlink(fsenc(lsrc), fsenc(ldst))
linked = True
except Exception as ex:
self.log("cannot symlink; creating copy: " + repr(ex))
self.log("cannot link; creating copy: " + repr(ex))
shutil.copy2(fsenc(src), fsenc(dst))
if lmod and (not linked or SYMTIME):

View File

@@ -794,6 +794,7 @@ input.eq_gain {
}
.tgl.btn.on:hover {
background: #fe8;
color: #400;
}
#detree {
padding: .3em .5em;
@@ -1275,6 +1276,12 @@ html.y .tgl.btn.on {
html.y .tgl.btn.on:hover {
background: #5c0;
}
html.by .tgl.btn.on {
background: #04a;
}
html.by .tgl.btn.on:hover {
background: #05c;
}
html.y #srv_info {
color: #c83;
background: #eaeaea;
@@ -1462,6 +1469,9 @@ html.y #treepar {
html.y #tree {
scrollbar-color: #490 #ddd;
}
html.by #tree {
scrollbar-color: #049 #ddd;
}
html.y #tree::-webkit-scrollbar-track,
html.y #tree::-webkit-scrollbar {
background: #ddd;
@@ -1469,6 +1479,9 @@ html.y #tree::-webkit-scrollbar {
html.y #tree::-webkit-scrollbar-thumb {
background: #490;
}
html.by #tree::-webkit-scrollbar-thumb {
background: #049;
}
@@ -1821,10 +1834,13 @@ html.y #bbox-overlay figcaption a {
padding: .5em;
}
#u2err.msg {
color: #999;
color: #aaa;
padding: .5em;
font-size: .9em;
}
html.y #u2err.msg {
color: #555;
}
html.y #u2err.err {
color: #f07;
}

View File

@@ -4650,7 +4650,7 @@ var settheme = (function () {
light = i % 2 == 1;
var c = ax.charAt(Math.floor(i / 2)),
l = light ? 'y' : 'z';
theme = c + l + ' ' + c + ' ' + l + ' ' + (light ? 'light ' : 'dark ');
theme = c + l + ' ' + c + ' ' + l;
swrite('theme', theme);
freshen();
}

View File

@@ -219,48 +219,48 @@ blink {
html.dark,
html.dark body {
html.z,
html.z body {
background: #222;
color: #ccc;
}
html.dark #toc a {
html.z #toc a {
color: #ccc;
border-left: .4em solid #444;
border-bottom: .1em solid #333;
}
html.dark #toc a.act {
html.z #toc a.act {
color: #fff;
border-left: .4em solid #3ad;
}
html.dark #toc li {
html.z #toc li {
border-width: 0;
}
html.dark #mn a:not(:last-child)::after {
html.z #mn a:not(:last-child)::after {
border-color: rgba(255,255,255,0.3);
}
html.dark #mn a {
html.z #mn a {
color: #ccc;
}
html.dark #mn {
html.z #mn {
border-bottom: 1px solid #333;
}
html.dark #mn,
html.dark #mh {
html.z #mn,
html.z #mh {
background: #222;
}
html.dark #mh a {
html.z #mh a {
color: #ccc;
background: none;
}
html.dark #mh a:hover {
html.z #mh a:hover {
background: #333;
color: #fff;
}
html.dark #toolsbox {
html.z #toolsbox {
background: #222;
}
html.dark #toolsbox.open {
html.z #toolsbox.open {
box-shadow: 0 .2em .2em #069;
border-radius: 0 0 .4em .4em;
}
@@ -308,23 +308,23 @@ blink {
html.dark #toc {
html.z #toc {
background: #282828;
border-top: 1px solid #2c2c2c;
box-shadow: 0 0 1em #181818;
}
html.dark #toc,
html.dark #mw {
html.z #toc,
html.z #mw {
scrollbar-color: #b80 #282828;
}
html.dark #toc::-webkit-scrollbar-track {
html.z #toc::-webkit-scrollbar-track {
background: #282828;
}
html.dark #toc::-webkit-scrollbar {
html.z #toc::-webkit-scrollbar {
background: #282828;
width: .8em;
}
html.dark #toc::-webkit-scrollbar-thumb {
html.z #toc::-webkit-scrollbar-thumb {
background: #b80;
}
}
@@ -432,16 +432,16 @@ blink {
html.dark .mdo a {
html.z .mdo a {
color: #000;
}
html.dark .mdo pre,
html.dark .mdo code {
html.z .mdo pre,
html.z .mdo code {
color: #240;
}
html.dark .mdo p>em,
html.dark .mdo li>em,
html.dark .mdo td>em {
html.z .mdo p>em,
html.z .mdo li>em,
html.z .mdo td>em {
color: #940;
}
}

View File

@@ -140,7 +140,7 @@ var md_opt = {
btn = document.getElementById("lightswitch"),
f = function (e) {
if (e) { e.preventDefault(); drk = !drk; }
document.documentElement.setAttribute("class", drk? "dark":"light");
document.documentElement.setAttribute("class", drk? "z":"y");
btn.innerHTML = "go " + (drk ? "light":"dark");
l.light = drk? 0:1;
};

View File

@@ -61,7 +61,7 @@
position: relative;
scrollbar-color: #eb0 #f7f7f7;
}
html.dark #mt {
html.z #mt {
color: #eee;
background: #222;
border: 1px solid #777;
@@ -77,7 +77,7 @@ html.dark #mt {
background: #f97;
border-radius: .15em;
}
html.dark #save.force-save {
html.z #save.force-save {
color: #fca;
background: #720;
}
@@ -102,7 +102,7 @@ html.dark #save.force-save {
#helpclose {
display: block;
}
html.dark #helpbox {
html.z #helpbox {
box-shadow: 0 .5em 2em #444;
background: #222;
border: 1px solid #079;

View File

@@ -84,24 +84,24 @@ html .editor-toolbar>button.save.force-save {
/* darkmode */
html.dark .mdo,
html.dark .CodeMirror {
html.z .mdo,
html.z .CodeMirror {
border-color: #222;
}
html.dark,
html.dark body,
html.dark .CodeMirror {
html.z,
html.z body,
html.z .CodeMirror {
background: #222;
color: #ccc;
}
html.dark .CodeMirror-cursor {
html.z .CodeMirror-cursor {
border-color: #fff;
}
html.dark .CodeMirror-selected {
html.z .CodeMirror-selected {
box-shadow: 0 0 1px #0cf inset;
}
html.dark .CodeMirror-selected,
html.dark .CodeMirror-selectedtext {
html.z .CodeMirror-selected,
html.z .CodeMirror-selectedtext {
border-radius: .1em;
background: #246;
color: #fff;
@@ -109,37 +109,37 @@ html.dark .CodeMirror-selectedtext {
html.dark #mn a {
html.z #mn a {
color: #ccc;
}
html.dark #mn a:not(:last-child):after {
html.z #mn a:not(:last-child):after {
border-color: rgba(255,255,255,0.3);
}
html.dark .editor-toolbar {
html.z .editor-toolbar {
border-color: #2c2c2c;
background: #1c1c1c;
}
html.dark .editor-toolbar>i.separator {
html.z .editor-toolbar>i.separator {
border-left: 1px solid #444;
border-right: 1px solid #111;
}
html.dark .editor-toolbar>button {
html.z .editor-toolbar>button {
margin-left: -1px; border: 1px solid rgba(255,255,255,0.1);
color: #aaa;
}
html.dark .editor-toolbar>button:hover {
html.z .editor-toolbar>button:hover {
color: #333;
}
html.dark .editor-toolbar>button.active {
html.z .editor-toolbar>button.active {
color: #333;
border-color: #ec1;
background: #c90;
}
html.dark .editor-toolbar::after,
html.dark .editor-toolbar::before {
html.z .editor-toolbar::after,
html.z .editor-toolbar::before {
background: none;
}
@@ -150,6 +150,6 @@ html.dark .editor-toolbar::before {
padding: 1em;
background: #f7f7f7;
}
html.dark .mdo {
html.z .mdo {
background: #1c1c1c;
}

View File

@@ -37,7 +37,7 @@ var lightswitch = (function () {
drk = l.light != 1,
f = function (e) {
if (e) drk = !drk;
document.documentElement.setAttribute("class", drk? "dark":"light");
document.documentElement.setAttribute("class", drk? "z":"y");
l.light = drk? 0:1;
};
f();

View File

@@ -88,27 +88,27 @@ blockquote {
}
html.dark,
html.dark body,
html.dark #wrap {
html.z,
html.z body,
html.z #wrap {
background: #222;
color: #ccc;
}
html.dark h1 {
html.z h1 {
border-color: #777;
}
html.dark a {
html.z a {
color: #fff;
background: #057;
border-color: #37a;
}
html.dark .logout,
html.dark .btns a,
html.dark a.r {
html.z .logout,
html.z .btns a,
html.z a.r {
background: #804;
border-color: #c28;
}
html.dark input {
html.z input {
color: #fff;
background: #626;
border: 1px solid #c2c;
@@ -117,6 +117,6 @@ html.dark input {
padding: .5em .7em;
margin: 0 .5em 0 0;
}
html.dark .num {
html.z .num {
border-color: #777;
}

View File

@@ -97,7 +97,7 @@
<a href="#" id="repl">π</a>
<script>
document.documentElement.setAttribute("class", localStorage.light == 1 ? "light" : "dark");
document.documentElement.setAttribute("class", localStorage.light == 1 ? "y" : "z");
</script>
<script src="/.cpr/util.js?_={{ ts }}"></script>

View File

@@ -157,23 +157,23 @@ html {
#tt em {
color: #f6a;
}
html.light #tt {
html.y #tt {
background: #fff;
border-color: #888 #000 #777 #000;
}
html.light #tt,
html.light #toast {
html.y #tt,
html.y #toast {
box-shadow: 0 .3em 1em rgba(0,0,0,0.4);
}
#modalc code,
html.light #tt code {
html.y #tt code {
background: #060;
color: #fff;
}
html.light #tt em {
html.y #tt em {
color: #d38;
}
html.light #tth {
html.y #tth {
color: #000;
background: #fff;
}
@@ -273,9 +273,9 @@ html.light #tth {
box-shadow: 0 .1em .2em #fc0 inset;
border-radius: .2em;
}
html.light *:focus,
html.light #pctl *:focus,
html.light .btn:focus {
html.y *:focus,
html.y #pctl *:focus,
html.y .btn:focus {
box-shadow: 0 .1em .2em #037 inset;
}
input[type="text"]:focus,
@@ -283,9 +283,9 @@ input:not([type]):focus,
textarea:focus {
box-shadow: 0 .1em .3em #fc0, 0 -.1em .3em #fc0;
}
html.light input[type="text"]:focus,
html.light input:not([type]):focus,
html.light textarea:focus {
html.y input[type="text"]:focus,
html.y input:not([type]):focus,
html.y textarea:focus {
box-shadow: 0 .1em .3em #037, 0 -.1em .3em #037;
}
@@ -414,7 +414,7 @@ html.light textarea:focus {
overflow-wrap: break-word;
word-wrap: break-word; /*ie*/
}
html.light .mdo a,
html.y .mdo a,
.mdo a {
color: #fff;
background: #39b;
@@ -443,48 +443,48 @@ html.light textarea:focus {
html.dark .mdo a {
html.z .mdo a {
background: #057;
}
html.dark .mdo h1 a, html.dark .mdo h4 a,
html.dark .mdo h2 a, html.dark .mdo h5 a,
html.dark .mdo h3 a, html.dark .mdo h6 a {
html.z .mdo h1 a, html.z .mdo h4 a,
html.z .mdo h2 a, html.z .mdo h5 a,
html.z .mdo h3 a, html.z .mdo h6 a {
color: inherit;
background: none;
}
html.dark .mdo pre,
html.dark .mdo code {
html.z .mdo pre,
html.z .mdo code {
color: #8c0;
background: #1a1a1a;
border: .07em solid #333;
}
html.dark .mdo ul,
html.dark .mdo ol {
html.z .mdo ul,
html.z .mdo ol {
border-color: #444;
}
html.dark .mdo strong {
html.z .mdo strong {
color: #fff;
}
html.dark .mdo p>em,
html.dark .mdo li>em,
html.dark .mdo td>em {
html.z .mdo p>em,
html.z .mdo li>em,
html.z .mdo td>em {
color: #f94;
border-color: #666;
}
html.dark .mdo h1 {
html.z .mdo h1 {
background: #383838;
border-top: .4em solid #b80;
border-bottom: .4em solid #4c4c4c;
}
html.dark .mdo h2 {
html.z .mdo h2 {
background: #444;
border-bottom: .22em solid #555;
}
html.dark .mdo td,
html.dark .mdo th {
html.z .mdo td,
html.z .mdo th {
border-color: #444;
}
html.dark .mdo blockquote {
html.z .mdo blockquote {
background: #282828;
border: .07em dashed #444;
}