refactor(package): replace manual MB calculation with format function

- Replace round() calculation with formatMegabytes() function call
- Add new formatMegabytes() utility function for consistent formatting
- Use number_format() for precise decimal handling in MB conversion
- Centralize byte to MB conversion logic in single reusable function
pull/43/head
韩天峰 4 weeks ago
parent 682b17f73f
commit 852c70198b
  1. 9
      package.php

@ -501,7 +501,7 @@ echo "[8/8] 清理临时文件...\n";
// 获取文件大小
$packageSize = filesize($outputFile);
$packageSizeMB = round($packageSize / 1024 / 1024, 2);
$packageSizeMB = formatMegabytes($packageSize);
echo "临时目录: {$topLevelDir}\n";
removeDirectory($topLevelDir);
@ -742,10 +742,15 @@ function packageUnixLike(): void
}
$cleanupArchive = false;
$sizeMb = round(filesize($outputFile) / 1024 / 1024, 2);
$sizeMb = formatMegabytes(filesize($outputFile));
echo "Package successful: {$outputFile} ({$sizeMb} MB)\n";
}
function formatMegabytes(int $bytes): string
{
return number_format($bytes / 1024 / 1024, 3, '.', '');
}
/**
* 递归复制目录
* @param string $src 源目录

Loading…
Cancel
Save