diff options
-rw-r--r-- | ymir.nix | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -86,9 +86,9 @@ in rec { | |||
86 | baseDir=/srv/www/files | 86 | baseDir=/srv/www/files |
87 | baseUrl="https://f.141.li" | 87 | baseUrl="https://f.141.li" |
88 | 88 | ||
89 | tmpFile=$(mktemp "$baseDir/.upload.XXXXXXXXXX") | 89 | tmpFile=$(mktemp "''${baseDir}/.upload.XXXXXXXXXX") |
90 | 90 | ||
91 | TRAPEXIT() { [[ -n "''${tmpFile}" && -e "''${tmpFile}" ]] && rm -f "''${tmpFile}" } | 91 | function zshexit() { [[ -n "''${tmpFile}" && -e "''${tmpFile}" ]] && rm -f "''${tmpFile}" } |
92 | 92 | ||
93 | cat >! "''${tmpFile}" | 93 | cat >! "''${tmpFile}" |
94 | 94 | ||
@@ -96,9 +96,8 @@ in rec { | |||
96 | prefix=''${prefix:l} | 96 | prefix=''${prefix:l} |
97 | filename="$1" | 97 | filename="$1" |
98 | 98 | ||
99 | [[ -z "''${prefix}" ]] && exit 2; | 99 | [[ -z "''${prefix}" || -z "''${filename}" ]] && exit 2; |
100 | [[ -z "''${filename}" ]] && exit 2; | 100 | [[ ! -f "''${tmpFile}" || $(stat -c '%s' "''${tmpFile}") == "0" ]] && exit 3; |
101 | [[ $(stat -c '%s' ''${tmpFile}) == "0" ]] && exit 2; | ||
102 | 101 | ||
103 | mkdir -p "''${baseDir}/''${prefix}" | 102 | mkdir -p "''${baseDir}/''${prefix}" |
104 | mv $tmpFile "''${baseDir}/''${prefix}/''${filename}" | 103 | mv $tmpFile "''${baseDir}/''${prefix}/''${filename}" |