diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-05-04 15:49:32 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-05-04 15:49:32 +0200 |
commit | 431913a24b065327e64b01ffc3a41f70d426680f (patch) | |
tree | 5abfcd8a6de9412031ae6fd7e028ffa581fa0725 | |
parent | 5d9e7e37114237887ed98e95a1fe617e70cbd3b2 (diff) | |
download | nixos-431913a24b065327e64b01ffc3a41f70d426680f.tar nixos-431913a24b065327e64b01ffc3a41f70d426680f.tar.gz nixos-431913a24b065327e64b01ffc3a41f70d426680f.tar.bz2 nixos-431913a24b065327e64b01ffc3a41f70d426680f.tar.xz nixos-431913a24b065327e64b01ffc3a41f70d426680f.zip |
cleanup
-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}" |