mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Bug #867: Image size is not accurate for empty files.
This commit is contained in:
parent
7aff65c28c
commit
dfa237b2ee
@ -41,14 +41,19 @@ echo "$IMAGE_REPOSITORY_PATH/`echo $CANONICAL_MD5 | cut -d ' ' -f1`"
|
||||
}
|
||||
|
||||
function fs_du {
|
||||
SIZE=""
|
||||
|
||||
SIZE=`$DU -m $1 2>/dev/null`
|
||||
QEMU_IMG=`command -v qemu-img`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
SIZE=0
|
||||
else
|
||||
SIZE=`echo $SIZE | cut -f1 -d' '`
|
||||
fi
|
||||
if [ "$?" = "0" ]; then
|
||||
SIZE=$($QEMU_IMG info $1|awk '/^virtual size:/{print substr($4,2)}')
|
||||
fi
|
||||
|
||||
echo "$SIZE"
|
||||
if [ -z "$SIZE" ]; then
|
||||
SIZE=$(stat -c %s $1)
|
||||
fi
|
||||
|
||||
SIZE=$(($SIZE/1048576))
|
||||
|
||||
echo "$SIZE"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user