pathname: make compute_disk_usage handle symlinks.

This commit is contained in:
Mike McQuaid 2017-01-06 08:50:20 +00:00
parent a68d38743a
commit 6c2b614a04

View File

@ -26,11 +26,17 @@ module DiskUsageExtension
private
def compute_disk_usage
if directory?
path = if symlink?
resolved_path
else
self
end
if path.directory?
scanned_files = Set.new
@file_count = 0
@disk_usage = 0
find do |f|
path.find do |f|
if f.directory?
@disk_usage += f.lstat.size
else
@ -47,7 +53,7 @@ module DiskUsageExtension
end
else
@file_count = 1
@disk_usage = lstat.size
@disk_usage = path.lstat.size
end
end
end