try to avoid printing mojibake in logs

unprintable and side-effect-inducing paths and names are hex-escaped,
preserving greppability and making log-parsing slightly more okay
This commit is contained in:
ed 2024-12-18 01:45:54 +01:00
parent 4c4e48bab7
commit 3051b13108
12 changed files with 185 additions and 186 deletions

View file

@ -212,7 +212,7 @@ class Lim(object):
df, du, err = get_df(abspath, True)
if err:
t = "failed to read disk space usage for [%s]: %s"
t = "failed to read disk space usage for %r: %s"
self.log(t % (abspath, err), 3)
self.dfv = 0xAAAAAAAAA # 42.6 GiB
else:
@ -526,7 +526,7 @@ class VFS(object):
"""returns [vfsnode,fs_remainder] if user has the requested permissions"""
if relchk(vpath):
if self.log:
self.log("vfs", "invalid relpath [{}]".format(vpath))
self.log("vfs", "invalid relpath %r @%s" % (vpath, uname))
raise Pebkac(422)
cvpath = undot(vpath)
@ -543,11 +543,11 @@ class VFS(object):
if req and uname not in d and uname != LEELOO_DALLAS:
if vpath != cvpath and vpath != "." and self.log:
ap = vn.canonical(rem)
t = "{} has no {} in [{}] => [{}] => [{}]"
self.log("vfs", t.format(uname, msg, vpath, cvpath, ap), 6)
t = "%s has no %s in %r => %r => %r"
self.log("vfs", t % (uname, msg, vpath, cvpath, ap), 6)
t = 'you don\'t have %s-access in "/%s" or below "/%s"'
raise Pebkac(err, t % (msg, cvpath, vn.vpath))
t = "you don't have %s-access in %r or below %r"
raise Pebkac(err, t % (msg, "/" + cvpath, "/" + vn.vpath))
return vn, rem
@ -693,8 +693,8 @@ class VFS(object):
and fsroot in seen
):
if self.log:
t = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}/{}"
self.log("vfs.walk", t.format(seen[-1], fsroot, self.vpath, rem), 3)
t = "bailing from symlink loop,\n prev: %r\n curr: %r\n from: %r / %r"
self.log("vfs.walk", t % (seen[-1], fsroot, self.vpath, rem), 3)
return
if "xdev" in self.flags or "xvol" in self.flags:
@ -818,8 +818,8 @@ class VFS(object):
if vdev != st.st_dev:
if self.log:
t = "xdev: {}[{}] => {}[{}]"
self.log("vfs", t.format(vdev, self.realpath, st.st_dev, ap), 3)
t = "xdev: %s[%r] => %s[%r]"
self.log("vfs", t % (vdev, self.realpath, st.st_dev, ap), 3)
return None
@ -829,7 +829,7 @@ class VFS(object):
return vn
if self.log:
self.log("vfs", "xvol: [{}]".format(ap), 3)
self.log("vfs", "xvol: %r" % (ap,), 3)
return None
@ -914,7 +914,7 @@ class AuthSrv(object):
self.idp_accs[uname] = gnames
t = "reinitializing due to new user from IdP: [%s:%s]"
t = "reinitializing due to new user from IdP: [%r:%r]"
self.log(t % (uname, gnames), 3)
if not broker:
@ -1568,7 +1568,7 @@ class AuthSrv(object):
continue
if self.args.shr_v:
t = "loading %s share [%s] by [%s] => [%s]"
t = "loading %s share %r by %r => %r"
self.log(t % (s_pr, s_k, s_un, s_vp))
if s_pw:
@ -1765,7 +1765,7 @@ class AuthSrv(object):
use = True
try:
_ = float(zs)
zs = "%sg" % (zs)
zs = "%sg" % (zs,)
except:
pass
lim.dfl = unhumanize(zs)
@ -2538,7 +2538,7 @@ class AuthSrv(object):
return
elif self.args.chpw_v == 2:
t = "chpw: %d changed" % (len(uok))
t = "chpw: %d changed" % (len(uok),)
if urst:
t += ", \033[0munchanged:\033[35m %s" % (", ".join(list(urst)))

View file

@ -42,14 +42,14 @@ class Fstab(object):
self.cache = {}
fs = "ext4"
msg = "failed to determine filesystem at [{}]; assuming {}\n{}"
msg = "failed to determine filesystem at %r; assuming %s\n%s"
if ANYWIN:
fs = "vfat"
try:
path = self._winpath(path)
except:
self.log(msg.format(path, fs, min_ex()), 3)
self.log(msg % (path, fs, min_ex()), 3)
return fs
path = undot(path)
@ -61,11 +61,11 @@ class Fstab(object):
try:
fs = self.get_w32(path) if ANYWIN else self.get_unix(path)
except:
self.log(msg.format(path, fs, min_ex()), 3)
self.log(msg % (path, fs, min_ex()), 3)
fs = fs.lower()
self.cache[path] = fs
self.log("found {} at {}".format(fs, path))
self.log("found %s at %r" % (fs, path))
return fs
def _winpath(self, path: str) -> str:

View file

@ -479,8 +479,8 @@ class HttpCli(object):
if vpath.startswith(self.args.R):
vpath = vpath[len(self.args.R) + 1 :]
else:
t = "incorrect --rp-loc or webserver config; expected vpath starting with [{}] but got [{}]"
self.log(t.format(self.args.R, vpath), 1)
t = "incorrect --rp-loc or webserver config; expected vpath starting with %r but got %r"
self.log(t % (self.args.R, vpath), 1)
self.ouparam = uparam.copy()
@ -518,7 +518,7 @@ class HttpCli(object):
return self.tx_qr()
if relchk(self.vpath) and (self.vpath != "*" or self.mode != "OPTIONS"):
self.log("invalid relpath [{}]".format(self.vpath))
self.log("invalid relpath %r" % ("/" + self.vpath,))
self.cbonk(self.conn.hsrv.gmal, self.req, "bad_vp", "invalid relpaths")
return self.tx_404() and self.keepalive
@ -598,7 +598,7 @@ class HttpCli(object):
self.uname = idp_usr
self.html_head += "<script>var is_idp=1</script>\n"
else:
self.log("unknown username: [%s]" % (idp_usr), 1)
self.log("unknown username: %r" % (idp_usr,), 1)
if self.args.ipu and self.uname == "*":
self.uname = self.conn.ipu_iu[self.conn.ipu_nm.map(self.ip)]
@ -663,7 +663,7 @@ class HttpCli(object):
origin = self.headers.get("origin", "<?>")
proto = "https://" if self.is_https else "http://"
guess = "modifying" if (origin and host) else "stripping"
t = "cors-reject %s because request-header Origin='%s' does not match request-protocol '%s' and host '%s' based on request-header Host='%s' (note: if this request is not malicious, check if your reverse-proxy is accidentally %s request headers, in particular 'Origin', for example by running copyparty with --ihead='*' to show all request headers)"
t = "cors-reject %s because request-header Origin=%r does not match request-protocol %r and host %r based on request-header Host=%r (note: if this request is not malicious, check if your reverse-proxy is accidentally %s request headers, in particular 'Origin', for example by running copyparty with --ihead='*' to show all request headers)"
self.log(t % (self.mode, origin, proto, self.host, host, guess), 3)
raise Pebkac(403, "rejected by cors-check")
@ -709,7 +709,7 @@ class HttpCli(object):
if pex.code != 404 or self.do_log:
self.log(
"http%d: %s\033[0m, %s" % (pex.code, msg, self.vpath),
"http%d: %s\033[0m, %r" % (pex.code, msg, "/" + self.vpath),
6 if em.startswith("client d/c ") else 3,
)
@ -1154,8 +1154,8 @@ class HttpCli(object):
return self.tx_res(res_path)
if res_path != undot(res_path):
t = "malicious user; attempted path traversal [{}] => [{}]"
self.log(t.format(self.vpath, res_path), 1)
t = "malicious user; attempted path traversal %r => %r"
self.log(t % ("/" + self.vpath, res_path), 1)
self.cbonk(self.conn.hsrv.gmal, self.req, "trav", "path traversal")
self.tx_404()
@ -1166,11 +1166,11 @@ class HttpCli(object):
return True
if not self.can_read and not self.can_write and not self.can_get:
t = "@{} has no access to [{}]"
t = "@%s has no access to %r"
if "on403" in self.vn.flags:
t += " (on403)"
self.log(t.format(self.uname, self.vpath))
self.log(t % (self.uname, "/" + self.vpath))
ret = self.on40x(self.vn.flags["on403"], self.vn, self.rem)
if ret == "true":
return True
@ -1189,7 +1189,7 @@ class HttpCli(object):
if self.vpath:
ptn = self.args.nonsus_urls
if not ptn or not ptn.search(self.vpath):
self.log(t.format(self.uname, self.vpath))
self.log(t % (self.uname, "/" + self.vpath))
return self.tx_404(True)
@ -1435,14 +1435,14 @@ class HttpCli(object):
if depth == "infinity":
# allow depth:0 from unmapped root, but require read-axs otherwise
if not self.can_read and (self.vpath or self.asrv.vfs.realpath):
t = "depth:infinity requires read-access in /%s"
t = t % (self.vpath,)
t = "depth:infinity requires read-access in %r"
t = t % ("/" + self.vpath,)
self.log(t, 3)
raise Pebkac(401, t)
if not stat.S_ISDIR(topdir["st"].st_mode):
t = "depth:infinity can only be used on folders; /%s is 0o%o"
t = t % (self.vpath, topdir["st"])
t = "depth:infinity can only be used on folders; %r is 0o%o"
t = t % ("/" + self.vpath, topdir["st"])
self.log(t, 3)
raise Pebkac(400, t)
@ -1468,7 +1468,7 @@ class HttpCli(object):
elif depth == "0" or not stat.S_ISDIR(st.st_mode):
# propfind on a file; return as topdir
if not self.can_read and not self.can_get:
self.log("inaccessible: [%s]" % (self.vpath,))
self.log("inaccessible: %r" % ("/" + self.vpath,))
raise Pebkac(401, "authenticate")
elif depth == "1":
@ -1495,7 +1495,7 @@ class HttpCli(object):
raise Pebkac(412, t.format(depth, t2))
if not self.can_read and not self.can_write and not fgen:
self.log("inaccessible: [%s]" % (self.vpath,))
self.log("inaccessible: %r" % ("/" + self.vpath,))
raise Pebkac(401, "authenticate")
fgen = itertools.chain([topdir], fgen)
@ -1573,7 +1573,7 @@ class HttpCli(object):
raise Pebkac(405, "WebDAV is disabled in server config")
if not self.can_write:
self.log("{} tried to proppatch [{}]".format(self.uname, self.vpath))
self.log("%s tried to proppatch %r" % (self.uname, "/" + self.vpath))
raise Pebkac(401, "authenticate")
from xml.etree import ElementTree as ET
@ -1631,7 +1631,7 @@ class HttpCli(object):
# win7+ deadlocks if we say no; just smile and nod
if not self.can_write and "Microsoft-WebDAV" not in self.ua:
self.log("{} tried to lock [{}]".format(self.uname, self.vpath))
self.log("%s tried to lock %r" % (self.uname, "/" + self.vpath))
raise Pebkac(401, "authenticate")
from xml.etree import ElementTree as ET
@ -1697,7 +1697,7 @@ class HttpCli(object):
raise Pebkac(405, "WebDAV is disabled in server config")
if not self.can_write and "Microsoft-WebDAV" not in self.ua:
self.log("{} tried to lock [{}]".format(self.uname, self.vpath))
self.log("%s tried to lock %r" % (self.uname, "/" + self.vpath))
raise Pebkac(401, "authenticate")
self.send_headers(None, 204)
@ -1851,7 +1851,7 @@ class HttpCli(object):
if "save" in opt:
post_sz, _, _, _, path, _ = self.dump_to_file(False)
self.log("urlform: {} bytes, {}".format(post_sz, path))
self.log("urlform: %d bytes, %r" % (post_sz, path))
elif "print" in opt:
reader, _ = self.get_body_reader()
buf = b""
@ -1862,8 +1862,8 @@ class HttpCli(object):
if buf:
orig = buf.decode("utf-8", "replace")
t = "urlform_raw {} @ {}\n {}\n"
self.log(t.format(len(orig), self.vpath, orig))
t = "urlform_raw %d @ %r\n %r\n"
self.log(t % (len(orig), "/" + self.vpath, orig))
try:
zb = unquote(buf.replace(b"+", b" "))
plain = zb.decode("utf-8", "replace")
@ -1889,8 +1889,8 @@ class HttpCli(object):
plain,
)
t = "urlform_dec {} @ {}\n {}\n"
self.log(t.format(len(plain), self.vpath, plain))
t = "urlform_dec %d @ %r\n %r\n"
self.log(t % (len(plain), "/" + self.vpath, plain))
except Exception as ex:
self.log(repr(ex))
@ -2140,7 +2140,7 @@ class HttpCli(object):
try:
ext = self.conn.hsrv.magician.ext(path)
except Exception as ex:
self.log("filetype detection failed for [{}]: {}".format(path, ex), 6)
self.log("filetype detection failed for %r: %s" % (path, ex), 6)
ext = None
if ext:
@ -2240,8 +2240,8 @@ class HttpCli(object):
def handle_stash(self, is_put: bool) -> bool:
post_sz, sha_hex, sha_b64, remains, path, url = self.dump_to_file(is_put)
spd = self._spd(post_sz)
t = "{} wrote {}/{} bytes to {} # {}"
self.log(t.format(spd, post_sz, remains, path, sha_b64[:28])) # 21
t = "%s wrote %d/%d bytes to %r # %s"
self.log(t % (spd, post_sz, remains, path, sha_b64[:28])) # 21
ac = self.uparam.get(
"want", self.headers.get("accept", "").lower().split(";")[-1]
@ -2271,7 +2271,7 @@ class HttpCli(object):
flags: dict[str, Any],
) -> None:
now = time.time()
t = "bad-chunk: %.3f %s %s %d %s %s %s"
t = "bad-chunk: %.3f %s %s %d %s %s %r"
t = t % (now, bad_sha, good_sha, ofs, self.ip, self.uname, ap)
self.log(t, 5)
@ -2411,7 +2411,7 @@ class HttpCli(object):
body = json.loads(json_buf.decode(enc, "replace"))
try:
zds = {k: v for k, v in body.items()}
zds["hash"] = "%d chunks" % (len(body["hash"]))
zds["hash"] = "%d chunks" % (len(body["hash"]),)
except:
zds = body
t = "POST len=%d type=%s ip=%s user=%s req=%r json=%s"
@ -2455,7 +2455,7 @@ class HttpCli(object):
if not bos.path.isdir(dst):
bos.makedirs(dst)
except OSError as ex:
self.log("makedirs failed [{}]".format(dst))
self.log("makedirs failed %r" % (dst,))
if not bos.path.isdir(dst):
if ex.errno == errno.EACCES:
raise Pebkac(500, "the server OS denied write-access")
@ -2480,7 +2480,7 @@ class HttpCli(object):
# strip common suffix (uploader's folder structure)
vp_req, vp_vfs = vroots(self.vpath, vjoin(dbv.vpath, vrem))
if not ret["purl"].startswith(vp_vfs):
t = "share-mapping failed; req=[%s] dbv=[%s] vrem=[%s] n1=[%s] n2=[%s] purl=[%s]"
t = "share-mapping failed; req=%r dbv=%r vrem=%r n1=%r n2=%r purl=%r"
zt = (self.vpath, dbv.vpath, vrem, vp_req, vp_vfs, ret["purl"])
raise Pebkac(500, t % zt)
ret["purl"] = vp_req + ret["purl"][len(vp_vfs) :]
@ -2529,13 +2529,13 @@ class HttpCli(object):
# search by query params
q = body["q"]
n = body.get("n", self.args.srch_hits)
self.log("qj: {} |{}|".format(q, n))
self.log("qj: %r |%d|" % (q, n))
hits, taglist, trunc = idx.search(self.uname, vols, q, n)
msg = len(hits)
idx.p_end = time.time()
idx.p_dur = idx.p_end - t0
self.log("q#: {} ({:.2f}s)".format(msg, idx.p_dur))
self.log("q#: %r (%.2fs)" % (msg, idx.p_dur))
order = []
for t in self.args.mte:
@ -2646,7 +2646,7 @@ class HttpCli(object):
t = "your client is sending %d bytes which is too much (server expected %d bytes at most)"
raise Pebkac(400, t % (remains, maxsize))
t = "writing %s %s+%d #%d+%d %s"
t = "writing %r %s+%d #%d+%d %s"
chunkno = cstart0[0] // chunksize
zs = " ".join([chashes[0][:15]] + [x[:9] for x in chashes[1:]])
self.log(t % (path, cstart0, remains, chunkno, len(chashes), zs))
@ -2758,7 +2758,7 @@ class HttpCli(object):
cinf = self.headers.get("x-up2k-stat", "")
spd = self._spd(postsize)
self.log("{:70} thank {}".format(spd, cinf))
self.log("%70s thank %r" % (spd, cinf))
self.reply(b"thank")
return True
@ -2840,7 +2840,7 @@ class HttpCli(object):
logpwd = "%" + ub64enc(zb[:12]).decode("ascii")
if pwd != "x":
self.log("invalid password: {}".format(logpwd), 3)
self.log("invalid password: %r" % (logpwd,), 3)
self.cbonk(self.conn.hsrv.gpwd, pwd, "pw", "invalid passwords")
msg = "naw dude"
@ -2876,7 +2876,7 @@ class HttpCli(object):
rem = sanitize_vpath(rem, "/")
fn = vfs.canonical(rem)
if not fn.startswith(vfs.realpath):
self.log("invalid mkdir [%s] [%s]" % (self.gctx, vpath), 1)
self.log("invalid mkdir %r %r" % (self.gctx, vpath), 1)
raise Pebkac(422)
if not nullwrite:
@ -3042,9 +3042,9 @@ class HttpCli(object):
elif bos.path.exists(abspath):
try:
wunlink(self.log, abspath, vfs.flags)
t = "overwriting file with new upload: %s"
t = "overwriting file with new upload: %r"
except:
t = "toctou while deleting for ?replace: %s"
t = "toctou while deleting for ?replace: %r"
self.log(t % (abspath,))
else:
open_args = {}
@ -3127,7 +3127,7 @@ class HttpCli(object):
f, tnam = ren_open(tnam, "wb", self.args.iobuf, **open_args)
try:
tabspath = os.path.join(fdir, tnam)
self.log("writing to {}".format(tabspath))
self.log("writing to %r" % (tabspath,))
sz, sha_hex, sha_b64 = copier(
p_data, f, hasher, max_sz, self.args.s_wr_slp
)
@ -3312,7 +3312,7 @@ class HttpCli(object):
jmsg["files"].append(jpart)
vspd = self._spd(sz_total, False)
self.log("{} {}".format(vspd, msg))
self.log("%s %r" % (vspd, msg))
suf = ""
if not nullwrite and self.args.write_uplog:
@ -3575,7 +3575,7 @@ class HttpCli(object):
if req == zs:
return True
t = "wrong dirkey, want %s, got %s\n vp: %s\n ap: %s"
t = "wrong dirkey, want %s, got %s\n vp: %r\n ap: %r"
self.log(t % (zs, req, self.req, ap), 6)
return False
@ -3603,7 +3603,7 @@ class HttpCli(object):
if req == zs:
return True
t = "wrong filekey, want %s, got %s\n vp: %s\n ap: %s"
t = "wrong filekey, want %s, got %s\n vp: %r\n ap: %r"
self.log(t % (zs, req, self.req, ap), 6)
return False
@ -3665,7 +3665,7 @@ class HttpCli(object):
elif ph == "srv.htime":
sv = datetime.now(UTC).strftime("%Y-%m-%d, %H:%M:%S")
else:
self.log("unknown placeholder in server config: [%s]" % (ph), 3)
self.log("unknown placeholder in server config: [%s]" % (ph,), 3)
continue
sv = self.conn.hsrv.ptn_hsafe.sub("_", sv)
@ -3822,7 +3822,7 @@ class HttpCli(object):
self.pipes.set(req_path, job)
except Exception as ex:
if getattr(ex, "errno", 0) != errno.ENOENT:
self.log("will not pipe [%s]; %s" % (ap_data, ex), 6)
self.log("will not pipe %r; %s" % (ap_data, ex), 6)
ptop = None
#
@ -4112,7 +4112,7 @@ class HttpCli(object):
if lower >= data_end:
if data_end:
t = "pipe: uploader is too slow; aborting download at %.2f MiB"
self.log(t % (data_end / M))
self.log(t % (data_end / M,))
raise Pebkac(416, "uploader is too slow")
raise Pebkac(416, "no data available yet; please retry in a bit")
@ -4256,7 +4256,7 @@ class HttpCli(object):
cdis = "attachment; filename=\"{}.{}\"; filename*=UTF-8''{}.{}"
cdis = cdis.format(afn, ext, ufn, ext)
self.log(cdis)
self.log(repr(cdis))
self.send_headers(None, mime=mime, headers={"Content-Disposition": cdis})
fgen = vn.zipgen(
@ -4920,7 +4920,7 @@ class HttpCli(object):
raise Pebkac(500, "server busy, cannot unpost; please retry in a bit")
filt = self.uparam.get("filter") or ""
lm = "ups [{}]".format(filt)
lm = "ups %r" % (filt,)
self.log(lm)
if self.args.shr and self.vpath.startswith(self.args.shr1):
@ -5731,7 +5731,7 @@ class HttpCli(object):
linf = stats.get(fn) or bos.lstat(fspath)
inf = bos.stat(fspath) if stat.S_ISLNK(linf.st_mode) else linf
except:
self.log("broken symlink: {}".format(repr(fspath)))
self.log("broken symlink: %r" % (fspath,))
continue
is_dir = stat.S_ISDIR(inf.st_mode)
@ -5846,8 +5846,7 @@ class HttpCli(object):
erd_efn = s3enc(idx.mem_cur, rd, fn)
r = icur.execute(q, erd_efn)
except:
t = "tag read error, {}/{}\n{}"
self.log(t.format(rd, fn, min_ex()))
self.log("tag read error, %r / %r\n%s" % (rd, fn, min_ex()))
break
tags = {k: v for k, v in r}
@ -5967,10 +5966,10 @@ class HttpCli(object):
if doc.lower().endswith(".md") and "exp" in vn.flags:
doctxt = self._expand(doctxt, vn.flags.get("exp_md") or [])
else:
self.log("doc 2big: [{}]".format(doc), c=6)
self.log("doc 2big: %r" % (doc,), 6)
doctxt = "( size of textfile exceeds serverside limit )"
else:
self.log("doc 404: [{}]".format(doc), c=6)
self.log("doc 404: %r" % (doc,), 6)
doctxt = "( textfile not found )"
if doctxt is not None:

View file

@ -194,7 +194,7 @@ def au_unpk(
except Exception as ex:
if ret:
t = "failed to decompress audio file [%s]: %r"
t = "failed to decompress audio file %r: %r"
log(t % (abspath, ex))
wunlink(log, ret, vn.flags if vn else VF_CAREFUL)
@ -582,7 +582,7 @@ class MTag(object):
raise Exception()
except Exception as ex:
if self.args.mtag_v:
self.log("mutagen-err [{}] @ [{}]".format(ex, abspath), "90")
self.log("mutagen-err [%s] @ %r" % (ex, abspath), "90")
return self.get_ffprobe(abspath) if self.can_ffprobe else {}
@ -699,8 +699,8 @@ class MTag(object):
ret[tag] = zj[tag]
except:
if self.args.mtag_v:
t = "mtag error: tagname {}, parser {}, file {} => {}"
self.log(t.format(tagname, parser.bin, abspath, min_ex()))
t = "mtag error: tagname %r, parser %r, file %r => %r"
self.log(t % (tagname, parser.bin, abspath, min_ex()), 6)
if ap != abspath:
wunlink(self.log, ap, VF_CAREFUL)

View file

@ -263,7 +263,7 @@ class SMB(object):
time.time(),
"",
):
yeet("blocked by xbu server config: " + vpath)
yeet("blocked by xbu server config: %r" % (vpath,))
ret = bos.open(ap, flags, *a, mode=chmod, **ka)
if wr:

View file

@ -110,7 +110,7 @@ def errdesc(
report = ["copyparty failed to add the following files to the archive:", ""]
for fn, err in errors:
report.extend([" file: {}".format(fn), "error: {}".format(err), ""])
report.extend([" file: %r" % (fn,), "error: %s" % (err,), ""])
btxt = "\r\n".join(report).encode("utf-8", "replace")
btxt = vol_san(list(vfs.all_vols.values()), btxt)

View file

@ -357,7 +357,7 @@ class Tftpd(object):
time.time(),
"",
):
yeet("blocked by xbu server config: " + vpath)
yeet("blocked by xbu server config: %r" % (vpath,))
if not self.args.tftp_nols and bos.path.isdir(ap):
return self._ls(vpath, "", 0, True)

View file

@ -109,13 +109,13 @@ class ThumbCli(object):
fmt = sfmt
elif fmt[:1] == "p" and not is_au and not is_vid:
t = "cannot thumbnail [%s]: png only allowed for waveforms"
self.log(t % (rem), 6)
t = "cannot thumbnail %r: png only allowed for waveforms"
self.log(t % (rem,), 6)
return None
histpath = self.asrv.vfs.histtab.get(ptop)
if not histpath:
self.log("no histpath for [{}]".format(ptop))
self.log("no histpath for %r" % (ptop,))
return None
tpath = thumb_path(histpath, rem, mtime, fmt, self.fmt_ffa)

View file

@ -239,7 +239,7 @@ class ThumbSrv(object):
def get(self, ptop: str, rem: str, mtime: float, fmt: str) -> Optional[str]:
histpath = self.asrv.vfs.histtab.get(ptop)
if not histpath:
self.log("no histpath for [{}]".format(ptop))
self.log("no histpath for %r" % (ptop,))
return None
tpath = thumb_path(histpath, rem, mtime, fmt, self.fmt_ffa)
@ -249,7 +249,7 @@ class ThumbSrv(object):
with self.mutex:
try:
self.busy[tpath].append(cond)
self.log("joined waiting room for %s" % (tpath,))
self.log("joined waiting room for %r" % (tpath,))
except:
thdir = os.path.dirname(tpath)
bos.makedirs(os.path.join(thdir, "w"))
@ -266,11 +266,11 @@ class ThumbSrv(object):
allvols = list(self.asrv.vfs.all_vols.values())
vn = next((x for x in allvols if x.realpath == ptop), None)
if not vn:
self.log("ptop [{}] not in {}".format(ptop, allvols), 3)
self.log("ptop %r not in %s" % (ptop, allvols), 3)
vn = self.asrv.vfs.all_aps[0][1]
self.q.put((abspath, tpath, fmt, vn))
self.log("conv {} :{} \033[0m{}".format(tpath, fmt, abspath), c=6)
self.log("conv %r :%s \033[0m%r" % (tpath, fmt, abspath), 6)
while not self.stopping:
with self.mutex:
@ -375,8 +375,8 @@ class ThumbSrv(object):
fun(ap_unpk, ttpath, fmt, vn)
break
except Exception as ex:
msg = "{} could not create thumbnail of {}\n{}"
msg = msg.format(fun.__name__, abspath, min_ex())
msg = "%s could not create thumbnail of %r\n%s"
msg = msg % (fun.__name__, abspath, min_ex())
c: Union[str, int] = 1 if "<Signals.SIG" in msg else "90"
self.log(msg, c)
if getattr(ex, "returncode", 0) != 321:

View file

@ -136,7 +136,7 @@ class U2idx(object):
ptop = vn.realpath
histpath = self.asrv.vfs.histtab.get(ptop)
if not histpath:
self.log("no histpath for [{}]".format(ptop))
self.log("no histpath for %r" % (ptop,))
return None
db_path = os.path.join(histpath, "up2k.db")
@ -151,7 +151,7 @@ class U2idx(object):
db = sqlite3.connect(uri, timeout=2, uri=True, check_same_thread=False)
cur = db.cursor()
cur.execute('pragma table_info("up")').fetchone()
self.log("ro: {}".format(db_path))
self.log("ro: %r" % (db_path,))
except:
self.log("could not open read-only: {}\n{}".format(uri, min_ex()))
# may not fail until the pragma so unset it
@ -161,7 +161,7 @@ class U2idx(object):
# on windows, this steals the write-lock from up2k.deferred_init --
# seen on win 10.0.17763.2686, py 3.10.4, sqlite 3.37.2
cur = sqlite3.connect(db_path, timeout=2, check_same_thread=False).cursor()
self.log("opened {}".format(db_path))
self.log("opened %r" % (db_path,))
self.cur[ptop] = cur
return cur

View file

@ -794,7 +794,7 @@ class Up2k(object):
if ccd != cd:
continue
self.log("xiu: {}# {}".format(len(wrfs), cmd))
self.log("xiu: %d# %r" % (len(wrfs), cmd))
runihook(self.log, cmd, vol, ups)
def _vis_job_progress(self, job: dict[str, Any]) -> str:
@ -1060,7 +1060,7 @@ class Up2k(object):
"""mutex(main,reg) me"""
histpath = self.vfs.histtab.get(ptop)
if not histpath:
self.log("no histpath for [{}]".format(ptop))
self.log("no histpath for %r" % (ptop,))
return None
db_path = os.path.join(histpath, "up2k.db")
@ -1154,7 +1154,7 @@ class Up2k(object):
job["poke"] = time.time()
job["busy"] = {}
else:
self.log("ign deleted file in snap: [{}]".format(fp))
self.log("ign deleted file in snap: %r" % (fp,))
if not n4g:
rm.append(k)
continue
@ -1386,12 +1386,12 @@ class Up2k(object):
xvol: bool,
) -> tuple[int, int, int]:
if xvol and not rcdir.startswith(top):
self.log("skip xvol: [{}] -> [{}]".format(cdir, rcdir), 6)
self.log("skip xvol: %r -> %r" % (cdir, rcdir), 6)
return 0, 0, 0
if rcdir in seen:
t = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}"
self.log(t.format(seen[-1], rcdir, cdir), 3)
t = "bailing from symlink loop,\n prev: %r\n curr: %r\n from: %r"
self.log(t % (seen[-1], rcdir, cdir), 3)
return 0, 0, 0
# total-files-added, total-num-files, recursive-size
@ -1447,7 +1447,7 @@ class Up2k(object):
and inf.st_dev != dev
and not (ANYWIN and bos.stat(rap).st_dev == dev)
):
self.log("skip xdev {}->{}: {}".format(dev, inf.st_dev, abspath), 6)
self.log("skip xdev %s->%s: %r" % (dev, inf.st_dev, abspath), 6)
continue
if abspath in excl or rap in excl:
unreg.append(rp)
@ -1476,10 +1476,10 @@ class Up2k(object):
tnf += i2
rsz += i3
except:
t = "failed to index subdir [{}]:\n{}"
self.log(t.format(abspath, min_ex()), c=1)
t = "failed to index subdir %r:\n%s"
self.log(t % (abspath, min_ex()), 1)
elif not stat.S_ISREG(inf.st_mode):
self.log("skip type-0%o file [%s]" % (inf.st_mode, abspath))
self.log("skip type-0%o file %r" % (inf.st_mode, abspath))
else:
# self.log("file: {}".format(abspath))
if rp.endswith(".PARTIAL") and time.time() - lmod < 60:
@ -1562,7 +1562,7 @@ class Up2k(object):
db.c.execute("insert into cv values (?,?,?)", (crd, cdn, cv))
db.n += 1
except Exception as ex:
self.log("cover {}/{} failed: {}".format(rd, cv, ex), 6)
self.log("cover %r/%r failed: %s" % (rd, cv, ex), 6)
seen_files = set([x[2] for x in files]) # for dropcheck
for sz, lmod, fn in files:
@ -1584,9 +1584,9 @@ class Up2k(object):
self.pp.n -= 1
dw, dts, dsz, ip, at = in_db[0]
if len(in_db) > 1:
t = "WARN: multiple entries: [{}] => [{}] |{}|\n{}"
t = "WARN: multiple entries: %r => %r |%d|\n%r"
rep_db = "\n".join([repr(x) for x in in_db])
self.log(t.format(top, rp, len(in_db), rep_db))
self.log(t % (top, rp, len(in_db), rep_db))
dts = -1
if fat32 and abs(dts - lmod) == 1:
@ -1595,10 +1595,8 @@ class Up2k(object):
if dts == lmod and dsz == sz and (nohash or dw[0] != "#" or not sz):
continue
t = "reindex [{}] => [{}] mtime({}/{}) size({}/{})".format(
top, rp, dts, lmod, dsz, sz
)
self.log(t)
t = "reindex %r => %r mtime(%s/%s) size(%s/%s)"
self.log(t % (top, rp, dts, lmod, dsz, sz))
self.db_rm(db.c, rd, fn, 0)
tfa += 1
db.n += 1
@ -1614,14 +1612,14 @@ class Up2k(object):
wark = up2k_wark_from_metadata(self.salt, sz, lmod, rd, fn)
else:
if sz > 1024 * 1024:
self.log("file: {}".format(abspath))
self.log("file: %r" % (abspath,))
try:
hashes, _ = self._hashlist_from_file(
abspath, "a{}, ".format(self.pp.n)
)
except Exception as ex:
self.log("hash: {} @ [{}]".format(repr(ex), abspath))
self.log("hash: %r @ %r" % (ex, abspath))
continue
if not hashes:
@ -1667,8 +1665,8 @@ class Up2k(object):
assert erd_erd # type: ignore # !rm
if n:
t = "forgetting {} shadowed autoindexed files in [{}] > [{}]"
self.log(t.format(n, top, sh_rd))
t = "forgetting %d shadowed autoindexed files in %r > %r"
self.log(t % (n, top, sh_rd))
q = "delete from dh where (d = ? or d like ?||'/%')"
db.c.execute(q, erd_erd)
@ -1865,7 +1863,7 @@ class Up2k(object):
stl = bos.lstat(abspath)
st = bos.stat(abspath) if stat.S_ISLNK(stl.st_mode) else stl
except Exception as ex:
self.log("missing file: %s" % (abspath,), 3)
self.log("missing file: %r" % (abspath,), 3)
f404.append((drd, dfn, w))
continue
@ -1876,12 +1874,12 @@ class Up2k(object):
w2 = up2k_wark_from_metadata(self.salt, sz2, mt2, rd, fn)
else:
if sz2 > 1024 * 1024 * 32:
self.log("file: {}".format(abspath))
self.log("file: %r" % (abspath,))
try:
hashes, _ = self._hashlist_from_file(abspath, pf)
except Exception as ex:
self.log("hash: {} @ [{}]".format(repr(ex), abspath))
self.log("hash: %r @ %r" % (ex, abspath))
continue
if not hashes:
@ -1901,9 +1899,8 @@ class Up2k(object):
rewark.append((drd, dfn, w2, sz2, mt2))
t = "hash mismatch: {}\n db: {} ({} byte, {})\n fs: {} ({} byte, {})"
t = t.format(abspath, w, sz, mt, w2, sz2, mt2)
self.log(t, 1)
t = "hash mismatch: %r\n db: %s (%d byte, %d)\n fs: %s (%d byte, %d)"
self.log(t % (abspath, w, sz, mt, w2, sz2, mt2), 1)
if e2vp and (rewark or f404):
self.hub.retcode = 1
@ -2451,7 +2448,7 @@ class Up2k(object):
q.task_done()
def _log_tag_err(self, parser: Any, abspath: str, ex: Any) -> None:
msg = "{} failed to read tags from {}:\n{}".format(parser, abspath, ex)
msg = "%s failed to read tags from %r:\n%s" % (parser, abspath, ex)
self.log(msg.lstrip(), c=1 if "<Signals.SIG" in msg else 3)
def _tagscan_file(
@ -2991,11 +2988,11 @@ class Up2k(object):
job = rj
break
else:
self.log("asserting contents of %s" % (orig_ap,))
self.log("asserting contents of %r" % (orig_ap,))
hashes2, st = self._hashlist_from_file(orig_ap)
wark2 = up2k_wark_from_hashlist(self.salt, st.st_size, hashes2)
if dwark != wark2:
t = "will not dedup (fs index desync): fs=%s, db=%s, file: %s\n%s"
t = "will not dedup (fs index desync): fs=%s, db=%s, file: %r\n%s"
self.log(t % (wark2, dwark, orig_ap, rj))
lost.append(dupe[3:])
continue
@ -3013,8 +3010,8 @@ class Up2k(object):
if lost:
c2 = None
for cur, dp_dir, dp_fn in lost:
t = "forgetting desynced db entry: /{}"
self.log(t.format(vjoin(vjoin(vfs.vpath, dp_dir), dp_fn)))
t = "forgetting desynced db entry: %r"
self.log(t % ("/" + vjoin(vjoin(vfs.vpath, dp_dir), dp_fn)))
self.db_rm(cur, dp_dir, dp_fn, cj["size"])
if c2 and c2 != cur:
c2.connection.commit()
@ -3043,8 +3040,8 @@ class Up2k(object):
except:
# missing; restart
if not self.args.nw and not n4g:
t = "forgetting deleted partial upload at {}"
self.log(t.format(path))
t = "forgetting deleted partial upload at %r"
self.log(t % (path,))
del reg[wark]
break
@ -3055,19 +3052,25 @@ class Up2k(object):
pass
elif st.st_size != rj["size"]:
t = "will not dedup (fs index desync): {}, size fs={} db={}, mtime fs={} db={}, file: {}\n{}"
t = t.format(
wark, st.st_size, rj["size"], st.st_mtime, rj["lmod"], path, rj
t = "will not dedup (fs index desync): %s, size fs=%d db=%d, mtime fs=%d db=%d, file: %r\n%s"
t = t % (
wark,
st.st_size,
rj["size"],
st.st_mtime,
rj["lmod"],
path,
rj,
)
self.log(t)
del reg[wark]
elif inc_ap != orig_ap and not data_ok and "done" in reg[wark]:
self.log("asserting contents of %s" % (orig_ap,))
self.log("asserting contents of %r" % (orig_ap,))
hashes2, _ = self._hashlist_from_file(orig_ap)
wark2 = up2k_wark_from_hashlist(self.salt, st.st_size, hashes2)
if wark != wark2:
t = "will not dedup (fs index desync): fs=%s, idx=%s, file: %s\n%s"
t = "will not dedup (fs index desync): fs=%s, idx=%s, file: %r\n%s"
self.log(t % (wark2, wark, orig_ap, rj))
del reg[wark]
@ -3084,7 +3087,7 @@ class Up2k(object):
vsrc = djoin(job["vtop"], job["prel"], job["name"])
vsrc = vsrc.replace("\\", "/") # just for prints anyways
if "done" not in job:
self.log("unfinished:\n {0}\n {1}".format(src, dst))
self.log("unfinished:\n %r\n %r" % (src, dst))
err = "partial upload exists at a different location; please resume uploading here instead:\n"
err += "/" + quotep(vsrc) + " "
@ -3101,7 +3104,7 @@ class Up2k(object):
raise Pebkac(422, err)
elif "nodupe" in vfs.flags:
self.log("dupe-reject:\n {0}\n {1}".format(src, dst))
self.log("dupe-reject:\n %r\n %r" % (src, dst))
err = "upload rejected, file already exists:\n"
err += "/" + quotep(vsrc) + " "
raise Pebkac(409, err)
@ -3163,7 +3166,7 @@ class Up2k(object):
"",
)
if not hr:
t = "upload blocked by xbu server config: %s" % (dst,)
t = "upload blocked by xbu server config: %r" % (dst,)
self.log(t, 1)
raise Pebkac(403, t)
if hr.get("reloc"):
@ -3304,7 +3307,7 @@ class Up2k(object):
times = (int(time.time()), int(cj["lmod"]))
bos.utime(ap, times, False)
self.log("touched %s from %d to %d" % (ap, job["lmod"], cj["lmod"]))
self.log("touched %r from %d to %d" % (ap, job["lmod"], cj["lmod"]))
except Exception as ex:
self.log("umod failed, %r" % (ex,), 3)
@ -3319,7 +3322,7 @@ class Up2k(object):
fp = djoin(fdir, fname)
if job.get("replace") and bos.path.exists(fp):
self.log("replacing existing file at {}".format(fp))
self.log("replacing existing file at %r" % (fp,))
cur = None
ptop = job["ptop"]
vf = self.flags.get(ptop) or {}
@ -3362,9 +3365,9 @@ class Up2k(object):
raise Exception(t % (src, fsrc, dst))
if verbose:
t = "linking dupe:\n point-to: {0}\n link-loc: {1}"
t = "linking dupe:\n point-to: {0!r}\n link-loc: {1!r}"
if fsrc:
t += "\n data-src: {2}"
t += "\n data-src: {2!r}"
self.log(t.format(src, dst, fsrc))
if self.args.nw:
@ -3434,7 +3437,7 @@ class Up2k(object):
elif fsrc and bos.path.isfile(fsrc):
csrc = fsrc
else:
t = "BUG: no valid sources to link from! orig(%s) fsrc(%s) link(%s)"
t = "BUG: no valid sources to link from! orig(%r) fsrc(%r) link(%r)"
self.log(t, 1)
raise Exception(t % (src, fsrc, dst))
shutil.copy2(fsenc(csrc), fsenc(dst))
@ -3612,15 +3615,12 @@ class Up2k(object):
atomic_move(self.log, src, dst, vflags)
times = (int(time.time()), int(job["lmod"]))
self.log(
"no more chunks, setting times {} ({}) on {}".format(
times, bos.path.getsize(dst), dst
)
)
t = "no more chunks, setting times %s (%d) on %r"
self.log(t % (times, bos.path.getsize(dst), dst))
try:
bos.utime(dst, times)
except:
self.log("failed to utime ({}, {})".format(dst, times))
self.log("failed to utime (%r, %s)" % (dst, times))
zs = "prel name lmod size ptop vtop wark dwrk host user addr"
z2 = [job[x] for x in zs.split()]
@ -3985,7 +3985,7 @@ class Up2k(object):
vpath_dir = vsplit(vpath)[0]
g = [(vn, voldir, vpath_dir, adir, [(fn, 0)], [], {})] # type: ignore
else:
self.log("rm: skip type-0%o file [%s]" % (st.st_mode, atop))
self.log("rm: skip type-0%o file %r" % (st.st_mode, atop))
return 0, [], []
xbd = vn.flags.get("xbd")
@ -4009,7 +4009,7 @@ class Up2k(object):
volpath = ("%s/%s" % (vrem, fn)).strip("/")
vpath = ("%s/%s" % (dbv.vpath, volpath)).strip("/")
self.log("rm %s\n %s" % (vpath, abspath))
self.log("rm %r\n %r" % (vpath, abspath))
if not unpost:
# recursion-only sanchk
_ = dbv.get(volpath, uname, *permsets[0])
@ -4032,8 +4032,8 @@ class Up2k(object):
time.time(),
"",
):
t = "delete blocked by xbd server config: {}"
self.log(t.format(abspath), 1)
t = "delete blocked by xbd server config: %r"
self.log(t % (abspath,), 1)
continue
n_files += 1
@ -4127,7 +4127,7 @@ class Up2k(object):
svpf = "/".join(x for x in [dbv.vpath, vrem, fn[0]] if x)
if not svpf.startswith(svp + "/"): # assert
self.log(min_ex(), 1)
t = "cp: bug at %s, top %s%s"
t = "cp: bug at %r, top %r%s"
raise Pebkac(500, t % (svpf, svp, SEESLOG))
dvpf = dvp + svpf[len(svp) :]
@ -4167,7 +4167,7 @@ class Up2k(object):
except:
pass # broken symlink; keep as-is
elif not stat.S_ISREG(st.st_mode):
self.log("skipping type-0%o file [%s]" % (st.st_mode, sabs))
self.log("skipping type-0%o file %r" % (st.st_mode, sabs))
return ""
else:
is_link = False
@ -4195,7 +4195,7 @@ class Up2k(object):
time.time(),
"",
):
t = "copy blocked by xbr server config: {}".format(svp)
t = "copy blocked by xbr server config: %r" % (svp,)
self.log(t, 1)
raise Pebkac(405, t)
@ -4232,7 +4232,7 @@ class Up2k(object):
)
curs.add(c2)
else:
self.log("not found in src db: [{}]".format(svp))
self.log("not found in src db: %r" % (svp,))
try:
if is_link and st != stl:
@ -4249,7 +4249,7 @@ class Up2k(object):
if ex.errno != errno.EXDEV:
raise
self.log("using plain copy (%s):\n %s\n %s" % (ex.strerror, sabs, dabs))
self.log("using plain copy (%s):\n %r\n %r" % (ex.strerror, sabs, dabs))
b1, b2 = fsenc(sabs), fsenc(dabs)
is_link = os.path.islink(b1) # due to _relink
try:
@ -4349,7 +4349,7 @@ class Up2k(object):
svpf = "/".join(x for x in [dbv.vpath, vrem, fn[0]] if x)
if not svpf.startswith(svp + "/"): # assert
self.log(min_ex(), 1)
t = "mv: bug at %s, top %s%s"
t = "mv: bug at %r, top %r%s"
raise Pebkac(500, t % (svpf, svp, SEESLOG))
dvpf = dvp + svpf[len(svp) :]
@ -4368,7 +4368,7 @@ class Up2k(object):
for ap in reversed(zsl):
if not ap.startswith(sabs):
self.log(min_ex(), 1)
t = "mv_d: bug at %s, top %s%s"
t = "mv_d: bug at %r, top %r%s"
raise Pebkac(500, t % (ap, sabs, SEESLOG))
rem = ap[len(sabs) :].replace(os.sep, "/").lstrip("/")
@ -4439,7 +4439,7 @@ class Up2k(object):
time.time(),
"",
):
t = "move blocked by xbr server config: {}".format(svp)
t = "move blocked by xbr server config: %r" % (svp,)
self.log(t, 1)
raise Pebkac(405, t)
@ -4449,8 +4449,8 @@ class Up2k(object):
if is_dirlink:
dlabs = absreal(sabs)
t = "moving symlink from [{}] to [{}], target [{}]"
self.log(t.format(sabs, dabs, dlabs))
t = "moving symlink from %r to %r, target %r"
self.log(t % (sabs, dabs, dlabs))
mt = bos.path.getmtime(sabs, False)
wunlink(self.log, sabs, svn.flags)
self._symlink(dlabs, dabs, dvn.flags, False, lmod=mt)
@ -4522,7 +4522,7 @@ class Up2k(object):
)
curs.add(c2)
else:
self.log("not found in src db: [{}]".format(svp))
self.log("not found in src db: %r" % (svp,))
try:
if is_xvol and has_dupes:
@ -4543,7 +4543,7 @@ class Up2k(object):
if ex.errno != errno.EXDEV:
raise
self.log("using copy+delete (%s):\n %s\n %s" % (ex.strerror, sabs, dabs))
self.log("using copy+delete (%s):\n %r\n %r" % (ex.strerror, sabs, dabs))
b1, b2 = fsenc(sabs), fsenc(dabs)
is_link = os.path.islink(b1) # due to _relink
try:
@ -4651,7 +4651,7 @@ class Up2k(object):
"""
srd, sfn = vsplit(vrem)
has_dupes = False
self.log("forgetting {}".format(vrem))
self.log("forgetting %r" % (vrem,))
if wark and cur:
self.log("found {} in db".format(wark))
if drop_tags:
@ -4727,7 +4727,7 @@ class Up2k(object):
dvrem = vjoin(rd, fn).strip("/")
if ptop != sptop or srem != dvrem:
dupes.append([ptop, dvrem])
self.log("found {} dupe: [{}] {}".format(wark, ptop, dvrem))
self.log("found %s dupe: %r %r" % (wark, ptop, dvrem))
if not dupes:
return 0
@ -4740,7 +4740,7 @@ class Up2k(object):
d = links if bos.path.islink(ap) else full
d[ap] = (ptop, vp)
except:
self.log("relink: not found: [{}]".format(ap))
self.log("relink: not found: %r" % (ap,))
# self.log("full:\n" + "\n".join(" {:90}: {}".format(*x) for x in full.items()))
# self.log("links:\n" + "\n".join(" {:90}: {}".format(*x) for x in links.items()))
@ -4748,7 +4748,7 @@ class Up2k(object):
# deleting final remaining full copy; swap it with a symlink
slabs = list(sorted(links.keys()))[0]
ptop, rem = links.pop(slabs)
self.log("linkswap [{}] and [{}]".format(sabs, slabs))
self.log("linkswap %r and %r" % (sabs, slabs))
mt = bos.path.getmtime(slabs, False)
flags = self.flags.get(ptop) or {}
atomic_move(self.log, sabs, slabs, flags)
@ -4783,7 +4783,7 @@ class Up2k(object):
zs = absreal(alink)
if ldst != zs:
t = "relink because computed != actual destination:\n %s\n %s"
t = "relink because computed != actual destination:\n %r\n %r"
self.log(t % (ldst, zs), 3)
ldst = zs
faulty = True
@ -4798,7 +4798,7 @@ class Up2k(object):
t = "relink because symlink verification failed: %s; %r"
self.log(t % (ex, ex), 3)
self.log("relinking [%s] to [%s]" % (alink, dabs))
self.log("relinking %r to %r" % (alink, dabs))
flags = self.flags.get(parts[0]) or {}
try:
lmod = bos.path.getmtime(alink, False)
@ -4913,7 +4913,7 @@ class Up2k(object):
"",
)
if not hr:
t = "upload blocked by xbu server config: {}".format(vp_chk)
t = "upload blocked by xbu server config: %r" % (vp_chk,)
self.log(t, 1)
raise Pebkac(403, t)
if hr.get("reloc"):
@ -4963,7 +4963,7 @@ class Up2k(object):
try:
sp.check_call(["fsutil", "sparse", "setflag", abspath])
except:
self.log("could not sparse [{}]".format(abspath), 3)
self.log("could not sparse %r" % (abspath,), 3)
relabel = True
sprs = False
@ -5150,7 +5150,7 @@ class Up2k(object):
self._tag_file(cur, entags, wark, abspath, tags)
cur.connection.commit()
self.log("tagged {} ({}+{})".format(abspath, ntags1, len(tags) - ntags1))
self.log("tagged %r (%d+%d)" % (abspath, ntags1, len(tags) - ntags1))
def _hasher(self) -> None:
with self.hashq_mutex:
@ -5169,7 +5169,7 @@ class Up2k(object):
if not self._hash_t(task) and self.stop:
return
except Exception as ex:
self.log("failed to hash %s: %s" % (task, ex), 1)
self.log("failed to hash %r: %s" % (task, ex), 1)
def _hash_t(
self, task: tuple[str, str, dict[str, Any], str, str, str, float, str, bool]
@ -5181,7 +5181,7 @@ class Up2k(object):
return True
abspath = djoin(ptop, rd, fn)
self.log("hashing " + abspath)
self.log("hashing %r" % (abspath,))
inf = bos.stat(abspath)
if not inf.st_size:
wark = up2k_wark_from_metadata(
@ -5274,7 +5274,7 @@ class Up2k(object):
x = pathmod(self.vfs, "", req_vp, {"vp": fvp, "fn": fn})
if not x:
t = "hook_fx(%s): failed to resolve %s based on %s"
t = "hook_fx(%s): failed to resolve %r based on %r"
self.log(t % (act, fvp, req_vp))
continue

View file

@ -1024,7 +1024,7 @@ class ProgressPrinter(threading.Thread):
now = time.time()
if msg and now - tp > 10:
tp = now
self.log("progress: %s" % (msg,), 6)
self.log("progress: %r" % (msg,), 6)
if no_stdout:
continue
@ -1626,7 +1626,7 @@ class MultipartParser(object):
(only the fallback non-js uploader relies on these filenames)
"""
for ln in read_header(self.sr, 2, 2592000):
self.log(ln)
self.log(repr(ln))
m = self.re_ctype.match(ln)
if m:
@ -1917,11 +1917,11 @@ def gen_filekey_dbg(
if p2 != fspath:
raise Exception()
except:
t = "maybe wrong abspath for filekey;\norig: {}\nreal: {}"
log(t.format(fspath, p2), 1)
t = "maybe wrong abspath for filekey;\norig: %r\nreal: %r"
log(t % (fspath, p2), 1)
t = "fk({}) salt({}) size({}) inode({}) fspath({}) at({})"
log(t.format(ret[:8], salt, fsize, inode, fspath, ctx), 5)
t = "fk(%s) salt(%s) size(%d) inode(%d) fspath(%r) at(%s)"
log(t % (ret[:8], salt, fsize, inode, fspath, ctx), 5)
return ret
@ -2277,7 +2277,7 @@ def log_reloc(
rem: str,
) -> None:
nap, nvp, nfn, (nvn, nrem) = pm
t = "reloc %s:\nold ap [%s]\nnew ap [%s\033[36m/%s\033[0m]\nold vp [%s]\nnew vp [%s\033[36m/%s\033[0m]\nold fn [%s]\nnew fn [%s]\nold vfs [%s]\nnew vfs [%s]\nold rem [%s]\nnew rem [%s]"
t = "reloc %s:\nold ap %r\nnew ap %r\033[36m/%r\033[0m\nold vp %r\nnew vp %r\033[36m/%r\033[0m\nold fn %r\nnew fn %r\nold vfs %r\nnew vfs %r\nold rem %r\nnew rem %r"
log(t % (re, ap, nap, nfn, vp, nvp, nfn, fn, nfn, vn.vpath, nvn.vpath, rem, nrem))
@ -2448,7 +2448,7 @@ def lsof(log: "NamedLogger", abspath: str) -> None:
try:
rc, so, se = runcmd([b"lsof", b"-R", fsenc(abspath)], timeout=45)
zs = (so.strip() + "\n" + se.strip()).strip()
log("lsof {} = {}\n{}".format(abspath, rc, zs), 3)
log("lsof %r = %s\n%s" % (abspath, rc, zs), 3)
except:
log("lsof failed; " + min_ex(), 3)
@ -2484,17 +2484,17 @@ def _fs_mvrm(
for attempt in range(90210):
try:
if ino and os.stat(bsrc).st_ino != ino:
t = "src inode changed; aborting %s %s"
t = "src inode changed; aborting %s %r"
log(t % (act, src), 1)
return False
if (dst and not atomic) and os.path.exists(bdst):
t = "something appeared at dst; aborting rename [%s] ==> [%s]"
t = "something appeared at dst; aborting rename %r ==> %r"
log(t % (src, dst), 1)
return False
osfun(*args)
if attempt:
now = time.time()
t = "%sd in %.2f sec, attempt %d: %s"
t = "%sd in %.2f sec, attempt %d: %r"
log(t % (act, now - t0, attempt + 1, src))
return True
except OSError as ex:
@ -2506,7 +2506,7 @@ def _fs_mvrm(
if not attempt:
if not PY2:
ino = os.stat(bsrc).st_ino
t = "%s failed (err.%d); retrying for %d sec: [%s]"
t = "%s failed (err.%d); retrying for %d sec: %r"
log(t % (act, ex.errno, maxtime + 0.99, src))
time.sleep(chill)
@ -3535,7 +3535,7 @@ def runhook(
log, src, cmd, ap, vp, host, uname, perms, mt, sz, ip, at, txt
)
if log and args.hook_v:
log("hook(%s) [%s] => \033[32m%s" % (src, cmd, hr), 6)
log("hook(%s) %r => \033[32m%s" % (src, cmd, hr), 6)
if not hr:
return {}
for k, v in hr.items():