crew: Fix file size calculation (#12578)

Signed-off-by: SupeChicken666 <supechicken666@gmail.com>
This commit is contained in:
SupeChicken666
2025-08-21 19:09:58 +08:00
committed by GitHub
parent 8bdd6cd128
commit e929964198

View File

@@ -868,13 +868,17 @@ def prepare_package(destdir)
# Allow postbuild to override the filelist contents
@pkg.postbuild
# create file list
filelist = Dir[".{#{CREW_PREFIX},#{HOME}}/**/{*,.?*}"].filter_map { |e| File.file?(e) || File.symlink?(e) ? e[1..] : nil }.sort
total_size = filelist.sum { |file| File.file?(File.join(CREW_DEST_DIR, file)) ? File.size(File.join(CREW_DEST_DIR, file)) : 0 }
# Create file list and calculate file size
filelist = Dir[".{#{CREW_PREFIX},#{HOME}}/**/{*,.?*}"].select do |e|
File.file?(e) || File.symlink?(e)
end.to_h do |e|
# Ignore symlinks to prevent duplicating calculation.
[e[1..], File.symlink?(e) ? 0 : File.size(e)]
end
File.write 'filelist', <<~EOF
# Total size: #{total_size}
#{filelist.join("\n")}
# Total size: #{filelist.values.sum}
#{filelist.keys.sort.join("\n")}
EOF
if Dir.exist?("#{CREW_LOCAL_REPO_ROOT}/manifest") && File.writable?("#{CREW_LOCAL_REPO_ROOT}/manifest")