mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
sanitize fs-paths in archive error summary
also gets rid of a dumb debug print i forgot
This commit is contained in:
parent
07ea629ca5
commit
5919607ad0
|
@ -759,7 +759,6 @@ class HttpCli(object):
|
|||
is_jinja = True
|
||||
|
||||
if is_jinja:
|
||||
print("applying jinja")
|
||||
with self.conn.hsrv.mutex:
|
||||
if html not in self.conn.hsrv.j2:
|
||||
j2env = jinja2.Environment()
|
||||
|
@ -3423,7 +3422,7 @@ class HttpCli(object):
|
|||
|
||||
bgen = packer(
|
||||
self.log,
|
||||
self.args,
|
||||
self.asrv,
|
||||
fgen,
|
||||
utf8="utf" in uarg,
|
||||
pre_crc="crc" in uarg,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# coding: utf-8
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import stat
|
||||
import tarfile
|
||||
|
||||
from queue import Queue
|
||||
|
||||
from .authsrv import AuthSrv
|
||||
from .bos import bos
|
||||
from .sutil import StreamArc, errdesc
|
||||
from .util import Daemon, fsenc, min_ex
|
||||
|
@ -45,12 +45,12 @@ class StreamTar(StreamArc):
|
|||
def __init__(
|
||||
self,
|
||||
log: "NamedLogger",
|
||||
args: argparse.Namespace,
|
||||
asrv: AuthSrv,
|
||||
fgen: Generator[dict[str, Any], None, None],
|
||||
cmp: str = "",
|
||||
**kwargs: Any
|
||||
):
|
||||
super(StreamTar, self).__init__(log, args, fgen)
|
||||
super(StreamTar, self).__init__(log, asrv, fgen)
|
||||
|
||||
self.ci = 0
|
||||
self.co = 0
|
||||
|
@ -148,7 +148,7 @@ class StreamTar(StreamArc):
|
|||
errors.append((f["vp"], ex))
|
||||
|
||||
if errors:
|
||||
self.errf, txt = errdesc(errors)
|
||||
self.errf, txt = errdesc(self.asrv.vfs, errors)
|
||||
self.log("\n".join(([repr(self.errf)] + txt[1:])))
|
||||
self.ser(self.errf)
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
# coding: utf-8
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import tempfile
|
||||
from datetime import datetime
|
||||
|
||||
from .__init__ import CORES
|
||||
from .authsrv import AuthSrv, VFS
|
||||
from .bos import bos
|
||||
from .th_cli import ThumbCli
|
||||
from .util import UTC, vjoin
|
||||
from .util import UTC, vjoin, vol_san
|
||||
|
||||
if True: # pylint: disable=using-constant-test
|
||||
from typing import Any, Generator, Optional
|
||||
|
@ -21,12 +21,13 @@ class StreamArc(object):
|
|||
def __init__(
|
||||
self,
|
||||
log: "NamedLogger",
|
||||
args: argparse.Namespace,
|
||||
asrv: AuthSrv,
|
||||
fgen: Generator[dict[str, Any], None, None],
|
||||
**kwargs: Any
|
||||
):
|
||||
self.log = log
|
||||
self.args = args
|
||||
self.asrv = asrv
|
||||
self.args = asrv.args
|
||||
self.fgen = fgen
|
||||
self.stopped = False
|
||||
|
||||
|
@ -103,15 +104,18 @@ def enthumb(
|
|||
return f
|
||||
|
||||
|
||||
def errdesc(errors: list[tuple[str, str]]) -> tuple[dict[str, Any], list[str]]:
|
||||
def errdesc(vfs: VFS, errors: list[tuple[str, str]]) -> tuple[dict[str, Any], list[str]]:
|
||||
report = ["copyparty failed to add the following files to the archive:", ""]
|
||||
|
||||
for fn, err in errors:
|
||||
report.extend([" file: {}".format(fn), "error: {}".format(err), ""])
|
||||
|
||||
btxt = "\r\n".join(report).encode("utf-8", "replace")
|
||||
btxt = vol_san(list(vfs.all_vols.values()), btxt)
|
||||
|
||||
with tempfile.NamedTemporaryFile(prefix="copyparty-", delete=False) as tf:
|
||||
tf_path = tf.name
|
||||
tf.write("\r\n".join(report).encode("utf-8", "replace"))
|
||||
tf.write(btxt)
|
||||
|
||||
dt = datetime.now(UTC).strftime("%Y-%m%d-%H%M%S")
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# coding: utf-8
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import calendar
|
||||
import stat
|
||||
import time
|
||||
import zlib
|
||||
|
||||
from .authsrv import AuthSrv
|
||||
from .bos import bos
|
||||
from .sutil import StreamArc, errdesc
|
||||
from .util import min_ex, sanitize_fn, spack, sunpack, yieldfile
|
||||
|
@ -219,13 +219,13 @@ class StreamZip(StreamArc):
|
|||
def __init__(
|
||||
self,
|
||||
log: "NamedLogger",
|
||||
args: argparse.Namespace,
|
||||
asrv: AuthSrv,
|
||||
fgen: Generator[dict[str, Any], None, None],
|
||||
utf8: bool = False,
|
||||
pre_crc: bool = False,
|
||||
**kwargs: Any
|
||||
) -> None:
|
||||
super(StreamZip, self).__init__(log, args, fgen)
|
||||
super(StreamZip, self).__init__(log, asrv, fgen)
|
||||
|
||||
self.utf8 = utf8
|
||||
self.pre_crc = pre_crc
|
||||
|
@ -302,7 +302,7 @@ class StreamZip(StreamArc):
|
|||
mbuf = b""
|
||||
|
||||
if errors:
|
||||
errf, txt = errdesc(errors)
|
||||
errf, txt = errdesc(self.asrv.vfs, errors)
|
||||
self.log("\n".join(([repr(errf)] + txt[1:])))
|
||||
for x in self.ser(errf):
|
||||
yield x
|
||||
|
|
Loading…
Reference in a new issue