mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
add ?tar=gz, ?tar=bz2, ?tar=xz with optional level;
defaults are ?tar=gz:3, ?tar=bz2:9, ?tar=xz:1
This commit is contained in:
parent
c1efd227b7
commit
767696185b
|
@ -505,10 +505,16 @@ select which type of archive you want in the `[⚙️] config` tab:
|
||||||
| name | url-suffix | description |
|
| name | url-suffix | description |
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
| `tar` | `?tar` | plain gnutar, works great with `curl \| tar -xv` |
|
| `tar` | `?tar` | plain gnutar, works great with `curl \| tar -xv` |
|
||||||
|
| `tar.gz` | `?tar=gz` | gzip compressed tar, for `curl \| tar -xvz` |
|
||||||
|
| `tar.xz` | `?tar=xz` | gnu-tar with xz / lzma compression (good) |
|
||||||
|
| `tar.bz2` | `?tar=bz2` | bzip2-compressed tar (mostly useless) |
|
||||||
| `zip` | `?zip=utf8` | works everywhere, glitchy filenames on win7 and older |
|
| `zip` | `?zip=utf8` | works everywhere, glitchy filenames on win7 and older |
|
||||||
| `zip_dos` | `?zip` | traditional cp437 (no unicode) to fix glitchy filenames |
|
| `zip_dos` | `?zip` | traditional cp437 (no unicode) to fix glitchy filenames |
|
||||||
| `zip_crc` | `?zip=crc` | cp437 with crc32 computed early for truly ancient software |
|
| `zip_crc` | `?zip=crc` | cp437 with crc32 computed early for truly ancient software |
|
||||||
|
|
||||||
|
* gzip default level is `3` (0=fast, 9=best), change with `?tar=gz:9`
|
||||||
|
* xz default level is `1` (0=fast, 9=best), change with `?tar=xz:9`
|
||||||
|
* bz2 default level is `2` (1=fast, 9=best), change with `?tar=bz2:9`
|
||||||
* hidden files (dotfiles) are excluded unless `-ed`
|
* hidden files (dotfiles) are excluded unless `-ed`
|
||||||
* `up2k.db` and `dir.txt` is always excluded
|
* `up2k.db` and `dir.txt` is always excluded
|
||||||
* `zip_crc` will take longer to download since the server has to read each file twice
|
* `zip_crc` will take longer to download since the server has to read each file twice
|
||||||
|
|
|
@ -989,6 +989,7 @@ def add_optouts(ap):
|
||||||
ap2.add_argument("-nid", action="store_true", help="no info disk-usage -- don't show in UI")
|
ap2.add_argument("-nid", action="store_true", help="no info disk-usage -- don't show in UI")
|
||||||
ap2.add_argument("-nb", action="store_true", help="no powered-by-copyparty branding in UI")
|
ap2.add_argument("-nb", action="store_true", help="no powered-by-copyparty branding in UI")
|
||||||
ap2.add_argument("--no-zip", action="store_true", help="disable download as zip/tar")
|
ap2.add_argument("--no-zip", action="store_true", help="disable download as zip/tar")
|
||||||
|
ap2.add_argument("--no-tarcmp", action="store_true", help="disable download as compressed tar (?tar=gz, ?tar=bz2, ?tar=xz, ?tar=gz:9, ...)")
|
||||||
ap2.add_argument("--no-lifetime", action="store_true", help="disable automatic deletion of uploads after a certain time (as specified by the 'lifetime' volflag)")
|
ap2.add_argument("--no-lifetime", action="store_true", help="disable automatic deletion of uploads after a certain time (as specified by the 'lifetime' volflag)")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2943,7 +2943,11 @@ class HttpCli(object):
|
||||||
self.log("transcoding to [{}]".format(cfmt))
|
self.log("transcoding to [{}]".format(cfmt))
|
||||||
fgen = gfilter(fgen, self.thumbcli, self.uname, vpath, cfmt)
|
fgen = gfilter(fgen, self.thumbcli, self.uname, vpath, cfmt)
|
||||||
|
|
||||||
bgen = packer(self.log, fgen, utf8="utf" in uarg, pre_crc="crc" in uarg)
|
cmp = "" if self.args.no_tarcmp else uarg
|
||||||
|
|
||||||
|
bgen = packer(
|
||||||
|
self.log, fgen, utf8="utf" in uarg, pre_crc="crc" in uarg, cmp=cmp
|
||||||
|
)
|
||||||
bsent = 0
|
bsent = 0
|
||||||
for buf in bgen.gen():
|
for buf in bgen.gen():
|
||||||
if not buf:
|
if not buf:
|
||||||
|
|
|
@ -44,6 +44,7 @@ class StreamTar(StreamArc):
|
||||||
self,
|
self,
|
||||||
log: "NamedLogger",
|
log: "NamedLogger",
|
||||||
fgen: Generator[dict[str, Any], None, None],
|
fgen: Generator[dict[str, Any], None, None],
|
||||||
|
cmp: str = "",
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
):
|
):
|
||||||
super(StreamTar, self).__init__(log, fgen)
|
super(StreamTar, self).__init__(log, fgen)
|
||||||
|
@ -53,10 +54,31 @@ class StreamTar(StreamArc):
|
||||||
self.qfile = QFile()
|
self.qfile = QFile()
|
||||||
self.errf: dict[str, Any] = {}
|
self.errf: dict[str, Any] = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
cmp, lv = cmp.replace(":", ",").split(",")
|
||||||
|
lv = int(lv)
|
||||||
|
except:
|
||||||
|
lv = None
|
||||||
|
|
||||||
# python 3.8 changed to PAX_FORMAT as default,
|
# python 3.8 changed to PAX_FORMAT as default,
|
||||||
# waste of space and don't care about the new features
|
# waste of space and don't care about the new features
|
||||||
fmt = tarfile.GNU_FORMAT
|
fmt = tarfile.GNU_FORMAT
|
||||||
self.tar = tarfile.open(fileobj=self.qfile, mode="w|", format=fmt) # type: ignore
|
|
||||||
|
arg = {"name": None, "fileobj": self.qfile, "mode": "w", "format": fmt}
|
||||||
|
if cmp == "gz":
|
||||||
|
fun = tarfile.TarFile.gzopen
|
||||||
|
arg["compresslevel"] = lv if lv is not None else 3
|
||||||
|
elif cmp == "bz2":
|
||||||
|
fun = tarfile.TarFile.bz2open
|
||||||
|
arg["compresslevel"] = lv if lv is not None else 2
|
||||||
|
elif cmp == "xz":
|
||||||
|
fun = tarfile.TarFile.xzopen
|
||||||
|
arg["preset"] = lv if lv is not None else 1
|
||||||
|
else:
|
||||||
|
fun = tarfile.open
|
||||||
|
arg["mode"] = "w|"
|
||||||
|
|
||||||
|
self.tar = fun(**arg)
|
||||||
|
|
||||||
Daemon(self._gen, "star-gen")
|
Daemon(self._gen, "star-gen")
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,7 @@ class StreamZip(StreamArc):
|
||||||
fgen: Generator[dict[str, Any], None, None],
|
fgen: Generator[dict[str, Any], None, None],
|
||||||
utf8: bool = False,
|
utf8: bool = False,
|
||||||
pre_crc: bool = False,
|
pre_crc: bool = False,
|
||||||
|
**kwargs: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
super(StreamZip, self).__init__(log, fgen)
|
super(StreamZip, self).__init__(log, fgen)
|
||||||
|
|
||||||
|
|
|
@ -375,7 +375,9 @@ var Ls = {
|
||||||
"fu_xe1": "failed to load unpost list from server:\n\nerror ",
|
"fu_xe1": "failed to load unpost list from server:\n\nerror ",
|
||||||
"fu_xe2": "404: File not found??",
|
"fu_xe2": "404: File not found??",
|
||||||
|
|
||||||
"fz_tar": "plain gnutar file (linux / mac)",
|
"fz_tar": "plain gnu-tar file (linux / mac)",
|
||||||
|
"fz_targz": "tar with gzip level 3 compression",
|
||||||
|
"fz_tarxz": "tar with xz level 1 compression",
|
||||||
"fz_zip8": "zip with utf8 filenames (maybe wonky on windows 7 and older)",
|
"fz_zip8": "zip with utf8 filenames (maybe wonky on windows 7 and older)",
|
||||||
"fz_zipd": "zip with traditional cp437 filenames, for really old software",
|
"fz_zipd": "zip with traditional cp437 filenames, for really old software",
|
||||||
"fz_zipc": "cp437 with crc32 computed early,$Nfor MS-DOS PKZIP v2.04g (october 1993)$N(takes longer to process before download can start)",
|
"fz_zipc": "cp437 with crc32 computed early,$Nfor MS-DOS PKZIP v2.04g (october 1993)$N(takes longer to process before download can start)",
|
||||||
|
@ -840,6 +842,8 @@ var Ls = {
|
||||||
"fu_xe2": "404: Filen finnes ikke??",
|
"fu_xe2": "404: Filen finnes ikke??",
|
||||||
|
|
||||||
"fz_tar": "ukomprimert gnu-tar arkiv, for linux og mac",
|
"fz_tar": "ukomprimert gnu-tar arkiv, for linux og mac",
|
||||||
|
"fz_targz": "gnu-tar pakket med gzip (nivå 3)",
|
||||||
|
"fz_tarxz": "gnu-tar pakket med xz (nivå 1)",
|
||||||
"fz_zip8": "zip med filnavn i utf8 (noe problematisk på windows 7 og eldre)",
|
"fz_zip8": "zip med filnavn i utf8 (noe problematisk på windows 7 og eldre)",
|
||||||
"fz_zipd": "zip med filnavn i cp437, for høggamle maskiner",
|
"fz_zipd": "zip med filnavn i cp437, for høggamle maskiner",
|
||||||
"fz_zipc": "cp437 med tidlig crc32,$Nfor MS-DOS PKZIP v2.04g (oktober 1993)$N(øker behandlingstid på server)",
|
"fz_zipc": "cp437 med tidlig crc32,$Nfor MS-DOS PKZIP v2.04g (oktober 1993)$N(øker behandlingstid på server)",
|
||||||
|
@ -6672,6 +6676,8 @@ var arcfmt = (function () {
|
||||||
var html = [],
|
var html = [],
|
||||||
fmts = [
|
fmts = [
|
||||||
["tar", "tar", L.fz_tar],
|
["tar", "tar", L.fz_tar],
|
||||||
|
["tgz", "tar=gz", L.fz_targz],
|
||||||
|
["txz", "tar=xz", L.fz_tarxz],
|
||||||
["zip", "zip=utf8", L.fz_zip8],
|
["zip", "zip=utf8", L.fz_zip8],
|
||||||
["zip_dos", "zip", L.fz_zipd],
|
["zip_dos", "zip", L.fz_zipd],
|
||||||
["zip_crc", "zip=crc", L.fz_zipc]
|
["zip_crc", "zip=crc", L.fz_zipc]
|
||||||
|
@ -6701,7 +6707,7 @@ var arcfmt = (function () {
|
||||||
|
|
||||||
for (var a = 0, aa = tds.length; a < aa; a++) {
|
for (var a = 0, aa = tds.length; a < aa; a++) {
|
||||||
var o = tds[a], txt = o.textContent, href = o.getAttribute('href');
|
var o = tds[a], txt = o.textContent, href = o.getAttribute('href');
|
||||||
if (txt != 'tar' && txt != 'zip')
|
if (!/^(zip|tar|tgz|txz)$/.exec(txt))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var ofs = href.lastIndexOf('?');
|
var ofs = href.lastIndexOf('?');
|
||||||
|
|
Loading…
Reference in a new issue