From 88c16d1bbef5a5343b70161796e03c9c82a7cfd3 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Mon, 23 Nov 2020 23:52:12 +0100 Subject: [PATCH] Add skipDuplicates option to upload in consumedir The `-m` setting checks before upload if a file exists. It is now also checked when the file is being processed. --- tools/consumedir.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/consumedir.sh b/tools/consumedir.sh index b0df9abb..c4d4169e 100755 --- a/tools/consumedir.sh +++ b/tools/consumedir.sh @@ -197,9 +197,15 @@ upload() { if [ "$dryrun" = "y" ]; then info "- Not uploading (dry-run) $file to $url with opts $OPTS" else + META1="" + META2="" + if [ "$distinct" = "y" ]; then + META1="-F" + META2="meta={\"multiple\": false, \"skipDuplicates\": true}" + fi trace "- Uploading $file to $url with options $OPTS" tf1=$($MKTEMP_CMD) tf2=$($MKTEMP_CMD) rc=0 - $CURL_CMD --fail -# -o "$tf1" --stderr "$tf2" $OPTS -XPOST -F file=@"$file" "$url" + $CURL_CMD --fail -# -o "$tf1" --stderr "$tf2" $OPTS -XPOST $META1 "$META2" -F file=@"$file" "$url" if [ $? -ne 0 ]; then info "Upload failed. Exit code: $rc" cat "$tf1"