release(v1.8.7): fix(zip-download): stream clean ZIP response and purge stale temp archives

This commit is contained in:
Ryan
2025-11-05 00:02:32 -05:00
committed by GitHub
parent 34a4e06a23
commit 7669f5a10b
3 changed files with 78 additions and 32 deletions

View File

@@ -557,6 +557,13 @@ class FileModel {
* @return array An associative array with either an "error" key or a "zipPath" key.
*/
public static function createZipArchive($folder, $files) {
// (optional) purge old temp zips > 6h
$zipRoot = rtrim((string)META_DIR, '/\\') . DIRECTORY_SEPARATOR . 'ziptmp';
$now = time();
foreach (glob($zipRoot . DIRECTORY_SEPARATOR . 'download-*.zip') ?: [] as $zp) {
if (is_file($zp) && ($now - @filemtime($zp)) > 21600) { @unlink($zp); }
}
// Normalize and validate target folder
$folder = trim((string)$folder) ?: 'root';
$baseDir = realpath(UPLOAD_DIR);