clienside hash check

This commit is contained in:
Jack L. Frost 2015-06-21 09:52:29 +03:00
parent 75897a38f7
commit 30c57c8685

31
sup
View File

@ -8,7 +8,7 @@ _self="${0##*/}"
cfg_url_regex='^[A-Za-z]([A-Za-z0-9+.-]+)?://.+'
cfg_tmp_dir="/tmp/$USER/sup"; TEMPDIR="$cfg_tmp_dir"
cfg_script_url='https://zfh.so/upload'
cfg_service_url='https://zfh.so'
cfg_screenshot_ext='png'
[[ -f $HOME/.suprc ]] && { source "$HOME/.suprc"; }
@ -38,7 +38,7 @@ sup.usage() {
# Others are self-explanatory:
cfg_url_regex
cfg_tmp_dir
cfg_script_url
cfg_service_url
EOF
}
@ -48,15 +48,25 @@ sup.env() {
done
}
sup.get_hash() {
read file_hash _ < <( sha1sum "$1" )
}
sup.upload() {
curl -fsL \
-F file="@$file" \
-F upload_mode='api' \
-F flag_private="$flag_private" \
-F secret="$secret" \
-F submit="" \
-A 'zerofiles.org upload script' \
"$cfg_script_url"
sup.get_hash "$file"
if curl -fsL "${cfg_service_url}/hell/${file_hash}" &>/dev/null; then
printf '%s\n' "${cfg_service_url}/hell/${file_hash}"
else
curl -fsL \
-F file="@$file" \
-F upload_mode='api' \
-F flag_private="$flag_private" \
-F secret="$secret" \
-F submit="" \
-A 'zerofiles.org upload script' \
"$cfg_service_url/upload"
fi
}
sup.mktemp() {
@ -197,6 +207,7 @@ main() {
if sup.upload; then
if (( "$flag_rm" )); then
sup.msg "Removing file: $file"
rm "$file"
fi
else