From: Nicolas Boisselier Date: Mon, 3 Oct 2016 21:31:22 +0000 (+0200) Subject: clean lock X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=f8a72ed20809c22599182822b57a3f4f60a63d76;p=nb.git clean lock --- diff --git a/bin/owncloud-sync b/bin/owncloud-sync index 211c3763..41366353 100755 --- a/bin/owncloud-sync +++ b/bin/owncloud-sync @@ -89,26 +89,26 @@ Nicolas Boisselier nicolas.boisselier@gmail.com owncloud_sync() { if [ "$DEBUG" -gt 0 ]; then - echo DEBUG: owncloudcmd -n --non-interactive "$1" "$2" + echo DEBUG: owncloudcmd -n --non-interactive --max-sync-retries 1 "$1" "$2" return fi - lock=~/$NAME.lock + lock=~/$NAME.pid + # Clean old lock nd kill + ( find "$lock" -mmin +$((60*2)) -exec cat "{}" \; | xargs kill ) &> /dev/null if [ -e "$lock" ]; then [ "$VERBOSE" -gt 0 ] && echo "$lock already exists" return 1 fi - if ! touch "$lock"; then + if ! echo $$ > "$lock"; then echo "Can't create $lock" 1>&2 rm "$lock" return 1 fi trap "rm $lock*" EXIT - #owncloudcmd -n --non-interactive "$1" "$2" 2>&1 | perl -ne 'print if s/^!!!\s*OCC:://' - #owncloudcmd -n --non-interactive "$1" "$2" 2>&1 | perl -ne 'print join(" ",@_)."\n" and next if @_=/OCC::(\S+).*?"(.*?)" "(.*?)"/;' - owncloudcmd -n --non-interactive "$1" "$2" 2>&1 | \ + owncloudcmd -n --non-interactive --max-sync-retries 1 "$1" "$2" 2>&1 | \ perl -ne 'BEGIN{$v=shift @ARGV };printf("%s %-10s %s\n",$2,$1,$3) if $v and /OCC::(.*?) created for "(.*?)" . "(.*?)" "(.*?)"/' "$VERBOSE" return 0