From e929964198b26e8b5c2c171fd28a85c804af286c Mon Sep 17 00:00:00 2001 From: SupeChicken666 Date: Thu, 21 Aug 2025 19:09:58 +0800 Subject: [PATCH] crew: Fix file size calculation (#12578) Signed-off-by: SupeChicken666 --- bin/crew | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/crew b/bin/crew index 7ed77d877..20f1ed2bb 100755 --- a/bin/crew +++ b/bin/crew @@ -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")