1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Feature #2589: libfs.sh "fs_size" handles the new AppMarket size reporting

It now sends a custom header: "OpenNebula-AppMarket-Size" and OpenNebula
obtains the size from that.
This commit is contained in:
Jaime Melis 2014-01-17 19:23:58 +01:00
parent 70f680914b
commit 6d5a0a3517

View File

@ -154,25 +154,18 @@ function gzip_file_size {
function fs_size {
case $1 in
http://*/download|https://*/download)
BASE_URL=${1%%/download}
HEADERS=`wget -S --spider --no-check-certificate $BASE_URL 2>&1`
http://*)
HEADERS=`curl -LIk $1 2>&1`
echo $HEADERS | grep "market" > /dev/null 2>&1
if [ $? -eq 0 ]; then
#URL is from market place
SIZE=`wget -O - -S --no-check-certificate $BASE_URL 2>&1|grep -E "^ *\"size\": \"?[0-9]+\"?.$"|tr -dc 0-9`
if echo "$HEADERS" | grep -q "OpenNebula-AppMarket-Size"; then
# An AppMarket/Marketplace URL
SIZE=$(echo "$HEADERS" | grep "^OpenNebula-AppMarket-Size:" | tail -n1 | cut -d: -f2)
else
#Not a marketplace URL
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
# Not an AppMarket/Marketplace URL
SIZE=$(echo "$HEADERS" | grep "^Content-Length:" | tail -n1 | cut -d: -f2)
fi
error=$?
;;
http://*|https://*)
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
error=$?
;;
*)
if [ -d "$1" ]; then
SIZE=`du -sb "$1" | cut -f1`