mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
add eventhook sanchecks
This commit is contained in:
parent
4310580cd4
commit
ead31b6823
|
@ -578,19 +578,26 @@ def get_sects():
|
|||
each command will execute in order unless one returns non-zero
|
||||
|
||||
optionally prefix the command with comma-sep. flags similar to -mtp:
|
||||
|
||||
\033[36mf\033[35m forks the process, doesn't wait for completion
|
||||
\033[36mc\033[35m checks return code, blocks the action if non-zero
|
||||
\033[36mj\033[35m provides json with info as 1st arg instead of filepath
|
||||
\033[36mwN\033[35m waits N sec after command has been started before continuing
|
||||
\033[36mtN\033[35m sets an N sec timeout before the command is abandoned
|
||||
|
||||
\033[36mkt\033[35m kills the entire process tree on timeout (default),
|
||||
\033[36mkm\033[35m kills just the main process
|
||||
\033[36mkn\033[35m lets it continue running until copyparty is terminated
|
||||
|
||||
\033[36mc0\033[35m show all process output (default)
|
||||
\033[36mc1\033[35m show only stderr
|
||||
\033[36mc2\033[35m show only stdout
|
||||
\033[36mc3\033[35m mute all process otput
|
||||
\033[0m"""
|
||||
\033[0m
|
||||
except for \033[36mxm\033[0m, only one hook / one action can run at a time,
|
||||
so it's recommended to use the \033[36mf\033[0m flag unless you really need
|
||||
to wait for the hook to finish before continuing (without \033[36mf\033[0m
|
||||
the upload speed can easily drop to 10% for small files)"""
|
||||
),
|
||||
],
|
||||
[
|
||||
|
|
|
@ -1152,9 +1152,32 @@ class AuthSrv(object):
|
|||
vol.flags["mth"] = self.args.mth
|
||||
|
||||
# append additive args from argv to volflags
|
||||
for name in ["mtp", "xbu", "xau", "xbr", "xar", "xbd", "xad", "xm"]:
|
||||
hooks = "xbu xau xbr xar xbd xad xm".split()
|
||||
for name in ["mtp"] + hooks:
|
||||
self._read_volflag(vol.flags, name, getattr(self.args, name), True)
|
||||
|
||||
for hn in hooks:
|
||||
cmds = vol.flags.get(hn)
|
||||
if not cmds:
|
||||
continue
|
||||
|
||||
ncmds = []
|
||||
for cmd in cmds:
|
||||
hfs = []
|
||||
ocmd = cmd
|
||||
while "," in cmd[:6]:
|
||||
zs, cmd = cmd.split(",", 1)
|
||||
hfs.append(zs)
|
||||
|
||||
if "c" in hfs and "f" in hfs:
|
||||
t = "cannot combine flags c and f; removing f from eventhook [{}]"
|
||||
self.log(t.format(ocmd), 1)
|
||||
hfs = [x for x in hfs if x != "f"]
|
||||
ocmd = ",".join(hfs + [cmd])
|
||||
|
||||
ncmds.append(ocmd)
|
||||
vol.flags[hn] = ncmds
|
||||
|
||||
# d2d drops all database features for a volume
|
||||
for grp, rm in [["d2d", "e2d"], ["d2t", "e2t"], ["d2d", "e2v"]]:
|
||||
if not vol.flags.get(grp, False):
|
||||
|
|
|
@ -1329,6 +1329,8 @@ class HttpCli(object):
|
|||
if rnd and not self.args.nw:
|
||||
fn = self.rand_name(fdir, fn, rnd)
|
||||
|
||||
path = os.path.join(fdir, fn)
|
||||
|
||||
if is_put and not self.args.no_dav:
|
||||
# allow overwrite if...
|
||||
# * volflag 'daw' is set
|
||||
|
@ -1337,7 +1339,6 @@ class HttpCli(object):
|
|||
# * file exists and is empty
|
||||
# * and there is no .PARTIAL
|
||||
|
||||
path = os.path.join(fdir, fn)
|
||||
tnam = fn + ".PARTIAL"
|
||||
if self.args.dotpart:
|
||||
tnam = "." + tnam
|
||||
|
|
Loading…
Reference in a new issue