flip writing when in scripts

This commit is contained in:
2019-10-20 10:29:49 +03:00
parent c1b4ee8a23
commit 232e99fee6
4 changed files with 21 additions and 15 deletions

3
code/.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
*.pyc
__pycache__
*.swp

View File

@@ -11,10 +11,7 @@ COPY docker-requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt RUN pip3 install -r /requirements.txt
COPY static /code/static COPY static /code/static
COPY templates /code/templates COPY templates /code/templates
COPY utils/__init__.py /code/utils/__init__.py COPY utils /code/utils
COPY utils/files.py /code/utils/files.py
COPY utils/misc.py /code/utils/misc.py
COPY utils/crypt.py /code/utils/crypt.py
COPY revprox.py /code/revprox.py COPY revprox.py /code/revprox.py
COPY notifier.py /code/notifier.py COPY notifier.py /code/notifier.py
COPY app.py /code/app.py COPY app.py /code/app.py

View File

@@ -13,7 +13,7 @@ from revprox import ReverseProxied
from utils import * from utils import *
__FLEES_VERSION__ = "20190830.0" __FLEES_VERSION__ = "20191020.0"
app = Flask(__name__) app = Flask(__name__)
app.config.from_object(__name__) app.config.from_object(__name__)
config_values = read_config(app) config_values = read_config(app)

View File

@@ -72,6 +72,8 @@ _simple_list() {
} }
_write() { _write() {
# stdin is open
[ -t 0 ] || stream_in=1
# no file mentioned, use the name as file # no file mentioned, use the name as file
[[ -z "$FILE" ]] && { [[ -z "$FILE" ]] && {
[[ -e "$NAME" ]] && { [[ -e "$NAME" ]] && {
@@ -80,25 +82,29 @@ _write() {
NAME=$( basename "$NAME" ) NAME=$( basename "$NAME" )
} }
} }
# stdin is open, use stdin [[ -e "$FILE" ]] && {
[ -t 0 ] || stream_in=1 # Input file exists, dont use stream
stream_in=0
}
[ -t 0 ] && [[ -z "$FILE" ]] && { [[ $stream_in -ne 1 ]] && [[ -z "$FILE" ]] && {
_msg File to read needed, or use stdin _msg File to read needed, or use stdin
exit 1 exit 1
} }
_msg "Writing $NAME" _msg "Writing $NAME"
[[ "$stream_in" -eq 1 ]] && { [[ "$stream_in" -eq 1 ]] && {
_write_stdin "$NAME" _write_stdin "$NAME"
} || { return $?
}
[[ -d "$FILE" ]] && { [[ -d "$FILE" ]] && {
[[ "${NAME,,}" = *".tar" ]] || NAME="${NAME}".tar [[ "${NAME,,}" = *".tar" ]] || NAME="${NAME}".tar
_write_folder "$NAME" "$FILE" _write_folder "$NAME" "$FILE"
} || { return $?
}
_write_file "$NAME" "$FILE" _write_file "$NAME" "$FILE"
} }
}
}
_write_folder() { # name, file _write_folder() { # name, file
tar c "$2" | curl -L -F "file=@-;filename=$1" "${FLEES_ROOTURL}upload/${FLEES_SHARE}/${FLEES_TOKEN}" | cat - tar c "$2" | curl -L -F "file=@-;filename=$1" "${FLEES_ROOTURL}upload/${FLEES_SHARE}/${FLEES_TOKEN}" | cat -