From 431913a24b065327e64b01ffc3a41f70d426680f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 4 May 2016 15:49:32 +0200 Subject: cleanup --- ymir.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ymir.nix b/ymir.nix index 80580442..fd5bbb90 100644 --- a/ymir.nix +++ b/ymir.nix @@ -86,9 +86,9 @@ in rec { baseDir=/srv/www/files baseUrl="https://f.141.li" - tmpFile=$(mktemp "$baseDir/.upload.XXXXXXXXXX") + tmpFile=$(mktemp "''${baseDir}/.upload.XXXXXXXXXX") - TRAPEXIT() { [[ -n "''${tmpFile}" && -e "''${tmpFile}" ]] && rm -f "''${tmpFile}" } + function zshexit() { [[ -n "''${tmpFile}" && -e "''${tmpFile}" ]] && rm -f "''${tmpFile}" } cat >! "''${tmpFile}" @@ -96,9 +96,8 @@ in rec { prefix=''${prefix:l} filename="$1" - [[ -z "''${prefix}" ]] && exit 2; - [[ -z "''${filename}" ]] && exit 2; - [[ $(stat -c '%s' ''${tmpFile}) == "0" ]] && exit 2; + [[ -z "''${prefix}" || -z "''${filename}" ]] && exit 2; + [[ ! -f "''${tmpFile}" || $(stat -c '%s' "''${tmpFile}") == "0" ]] && exit 3; mkdir -p "''${baseDir}/''${prefix}" mv $tmpFile "''${baseDir}/''${prefix}/''${filename}" -- cgit v1.2.3