mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
Major architectural improvements: - Merged download and restore into single atomic operation - Eliminated separate S3DownloadFinished event (redundant) - Files now transfer directly: S3 → helper container → server → database container - Removed download progress tracking in favor of unified restore progress UI/UX improvements: - Unified restore method selection with visual cards - Consistent "File Information" display between local and S3 restore - Single slide-over for all restore operations (removed separate S3 download monitor) - Better visual feedback with loading states Security enhancements: - Added isSafeTmpPath() helper for path traversal protection - URL decode validation to catch encoded attacks - Canonical path resolution to prevent symlink attacks - Comprehensive path validation in all cleanup events Cleanup improvements: - S3RestoreJobFinished now handles all cleanup (helper container + all temp files) - RestoreJobFinished uses new isSafeTmpPath() validation - CoolifyTask dispatches cleanup events even on job failure - All cleanup uses non-throwing commands (2>/dev/null || true) Other improvements: - S3 storage policy authorization on Show component - Storage Form properly syncs is_usable state after test - Removed debug code and improved error handling - Better command organization and documentation 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
it('formats zero bytes correctly', function () {
|
|
expect(formatBytes(0))->toBe('0 B');
|
|
});
|
|
|
|
it('formats null bytes correctly', function () {
|
|
expect(formatBytes(null))->toBe('0 B');
|
|
});
|
|
|
|
it('handles negative bytes safely', function () {
|
|
expect(formatBytes(-1024))->toBe('0 B');
|
|
expect(formatBytes(-100))->toBe('0 B');
|
|
});
|
|
|
|
it('formats bytes correctly', function () {
|
|
expect(formatBytes(512))->toBe('512 B');
|
|
expect(formatBytes(1023))->toBe('1023 B');
|
|
});
|
|
|
|
it('formats kilobytes correctly', function () {
|
|
expect(formatBytes(1024))->toBe('1 KB');
|
|
expect(formatBytes(2048))->toBe('2 KB');
|
|
expect(formatBytes(1536))->toBe('1.5 KB');
|
|
});
|
|
|
|
it('formats megabytes correctly', function () {
|
|
expect(formatBytes(1048576))->toBe('1 MB');
|
|
expect(formatBytes(5242880))->toBe('5 MB');
|
|
});
|
|
|
|
it('formats gigabytes correctly', function () {
|
|
expect(formatBytes(1073741824))->toBe('1 GB');
|
|
expect(formatBytes(2147483648))->toBe('2 GB');
|
|
});
|
|
|
|
it('respects precision parameter', function () {
|
|
expect(formatBytes(1536, 0))->toBe('2 KB');
|
|
expect(formatBytes(1536, 1))->toBe('1.5 KB');
|
|
expect(formatBytes(1536, 2))->toBe('1.5 KB');
|
|
expect(formatBytes(1536, 3))->toBe('1.5 KB');
|
|
});
|