check for symlink first to compute disk usage because -f und -s otherwise follow symlinks

This commit is contained in:
Johannes Schauer Marin Rodrigues 2021-09-16 16:11:34 +02:00
parent b41c3ee8cc
commit 631b103ca7
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -4297,6 +4297,9 @@ sub approx_disk_usage {
$installed_size += scalar @devfiles; $installed_size += scalar @devfiles;
} elsif ($File::Find::name =~ /^$directory\/dev\//) { } elsif ($File::Find::name =~ /^$directory\/dev\//) {
# ignore everything below /dev # ignore everything below /dev
} elsif (-l $File::Find::name) {
# -f follows symlinks, so we first check if we have a symlink
$installed_size += 1;
} elsif (-f $File::Find::name) { } elsif (-f $File::Find::name) {
# add file size in 1024 byte blocks, rounded up # add file size in 1024 byte blocks, rounded up
$installed_size += int(((-s $File::Find::name) + 1024) / 1024); $installed_size += int(((-s $File::Find::name) + 1024) / 1024);