clienside hash check
This commit is contained in:
parent
75897a38f7
commit
30c57c8685
17
sup
17
sup
|
@ -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,7 +48,16 @@ sup.env() {
|
|||
done
|
||||
}
|
||||
|
||||
sup.get_hash() {
|
||||
read file_hash _ < <( sha1sum "$1" )
|
||||
}
|
||||
|
||||
sup.upload() {
|
||||
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' \
|
||||
|
@ -56,7 +65,8 @@ sup.upload() {
|
|||
-F secret="$secret" \
|
||||
-F submit="" \
|
||||
-A 'zerofiles.org upload script' \
|
||||
"$cfg_script_url"
|
||||
"$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
|
||||
|
|
Loading…
Reference in New Issue
Block a user