3 declare -A h # header array
4 # default (empty) action, to be overridden in config
21 if [ $(date +%s) -gt $toolate ]
29 checkshaandmoveorexit () {
33 if [ "$sha" ] && sha1=$(sha1sum "$src" | awk '{print$1}')
35 if [ "$sha1" = "$sha" ]
37 echo "$n $src sha1 ok"
38 wrap mv -v "$src" "$dst"
42 echo "$n $src sha1 FALSCH"
43 # keine action, aber ACK
48 wrap mv -v "$src" "$dst"
56 -f) f=$2;shift ;; # filename
57 -m) m=$2;shift ;; # mime type
58 -h) setheader "$2";shift ;; # headers
59 -n) n=$2;shift ;; # seq number
60 -r) r=$2;shift ;; # routing key
61 -d) dest=$2;shift ;; # file destination dir
62 -c) . $2 || exit;shift ;; # config snippet
63 -p) prio=$2;shift ;; # priority
64 -t) t=$2;shift ;; # timestamp
68 trap "rm -f -- \"$f\"" 0 1 2 3 15
69 if [ "${h[chunkSize]}" -a "${h[fileSize]}" ]
77 toolate=$((begin+maxwait))
78 if [ "${h[chunkSize]}" = "${h[fileSize]}" ]
81 wrap cp -v "$f" "$temp/${h[fileName]}"
82 checkshaandmoveorexit "${h[sha1]}" "$temp/${h[fileName]}" "$dest/${h[fileName]}"
83 elif [ "${h[chunkIndex]}" ]
86 wrap cp -v "$f" "$temp/${h[fileName]}.part${h[chunkIndex]}"
87 if [ "${h[chunkCount]}" = "${h[chunkIndex]}" ]
91 until checktimeout; [ -f "$temp/${h[fileName]}.part" ]
93 for i in `seq 1 ${h[chunkCount]}`
95 if ! [ -f "$temp/${h[fileName]}.part$i" ]
97 # einer fehlt. versuch beenden. warten bis der da ist. nochmal probieren.
98 rm -f "$temp/${h[fileName]}.part"
102 # ls -l "$temp/${h[fileName]}.part$i"
103 cat "$temp/${h[fileName]}.part$i" >> "$temp/${h[fileName]}.part"
106 # warten, bis die Prozesse der anderen Teile sich beendet und ihre
107 # Datei entfernt haben und keine *.part* mehr da sind
108 wrap mv -v "$temp/${h[fileName]}.part" "$temp/${h[fileName]}"
109 rm -f -- "$temp/${h[fileName]}.part${h[chunkIndex]}"
110 until checktimeout; [ "$(echo "$temp/${h[fileName]}.part"*)" = "$temp/${h[fileName]}.part*" ]
114 checkshaandmoveorexit "${h[sha1]}" "$temp/${h[fileName]}" "$dest/${h[fileName]}"
117 # erst ACKen, wenn alle Teile da sind und zusammengesetzt sind.
118 until checktimeout; [ -f "$temp/${h[fileName]}" ]
122 rm -f -- "$temp/${h[fileName]}.part${h[chunkIndex]}"
126 # keine headerdaten, normal!