Relax upload type checks for .zst backups

This commit is contained in:
2026-02-11 01:54:30 +02:00
parent 1e66f43d4e
commit a566a2ae64
4 changed files with 7 additions and 23 deletions

View File

@@ -478,7 +478,7 @@ class ImportProcessCommand extends Command
{ {
$archivePath = strtolower($archivePath); $archivePath = strtolower($archivePath);
if (str_ends_with($archivePath, '.tar.zst')) { if (str_ends_with($archivePath, '.tar.zst') || str_ends_with($archivePath, '.zst')) {
return 'tar --zstd -xf'; return 'tar --zstd -xf';
} }

View File

@@ -192,14 +192,6 @@ class DirectAdminMigration extends Page implements HasActions, HasForms
->disk('backups') ->disk('backups')
->directory('directadmin-migrations') ->directory('directadmin-migrations')
->preserveFilenames() ->preserveFilenames()
->acceptedFileTypes([
'application/gzip',
'application/x-gzip',
'application/zstd',
'application/x-zstd',
'application/x-tar',
'application/octet-stream',
])
->visible(fn (Get $get): bool => $get('importMethod') === 'backup_file'), ->visible(fn (Get $get): bool => $get('importMethod') === 'backup_file'),
TextInput::make('backupFilePath') TextInput::make('backupFilePath')
->label(__('Backup File Path')) ->label(__('Backup File Path'))

View File

@@ -230,14 +230,6 @@ class DirectAdminMigration extends Page implements HasActions, HasForms
->label(__('DirectAdmin Backup Archive')) ->label(__('DirectAdmin Backup Archive'))
->storeFiles(false) ->storeFiles(false)
->required() ->required()
->acceptedFileTypes([
'application/octet-stream',
'application/x-tar',
'application/zstd',
'application/x-zstd',
'application/gzip',
'application/x-gzip',
])
->maxSize(512000) // 500MB in KB ->maxSize(512000) // 500MB in KB
->helperText(__('Supported formats: .tar.zst, .tar.gz, .tgz (max 500MB via upload)')), ->helperText(__('Supported formats: .tar.zst, .tar.gz, .tgz (max 500MB via upload)')),
]) ])
@@ -256,8 +248,8 @@ class DirectAdminMigration extends Page implements HasActions, HasForms
$filename = (string) $file->getClientOriginalName(); $filename = (string) $file->getClientOriginalName();
$filename = basename($filename); $filename = basename($filename);
if (! preg_match('/\\.(tar\\.zst|tar\\.gz|tgz)$/i', $filename)) { if (! preg_match('/\\.(tar\\.zst|zst|tar\\.gz|tgz)$/i', $filename)) {
throw new Exception(__('Backup must be a .tar.zst, .tar.gz or .tgz file.')); throw new Exception(__('Backup must be a .zst, .tar.zst, .tar.gz or .tgz file.'));
} }
$maxBytes = 500 * 1024 * 1024; $maxBytes = 500 * 1024 * 1024;
@@ -728,7 +720,7 @@ class DirectAdminMigration extends Page implements HasActions, HasForms
} }
$name = (string) ($item['name'] ?? ''); $name = (string) ($item['name'] ?? '');
if (! preg_match('/\\.(tar\\.zst|tar\\.gz|tgz)$/i', $name)) { if (! preg_match('/\\.(tar\\.zst|zst|tar\\.gz|tgz)$/i', $name)) {
continue; continue;
} }

View File

@@ -12682,7 +12682,7 @@ function discoverDirectAdminBackup(string $backupPath, string $extractDir): arra
$accounts = []; $accounts = [];
$tarArgs = ''; $tarArgs = '';
if (preg_match('/\\.tar\\.zst$/i', $backupPath)) { if (preg_match('/\\.(tar\\.zst|zst)$/i', $backupPath)) {
$tarArgs = '--zstd'; $tarArgs = '--zstd';
} elseif (preg_match('/\\.(tar\\.gz|tgz)$/i', $backupPath)) { } elseif (preg_match('/\\.(tar\\.gz|tgz)$/i', $backupPath)) {
$tarArgs = '-I pigz'; $tarArgs = '-I pigz';
@@ -12725,7 +12725,7 @@ function discoverDirectAdminBackup(string $backupPath, string $extractDir): arra
// Check for multiple user backups (full server backup) // Check for multiple user backups (full server backup)
foreach ($fileList as $file) { foreach ($fileList as $file) {
if (preg_match('/user\\.([a-z0-9_]+)\\.(?:tar\\.zst|tar\\.gz|tgz)$/i', $file, $matches)) { if (preg_match('/user\\.([a-z0-9_]+)\\.(?:tar\\.zst|zst|tar\\.gz|tgz)$/i', $file, $matches)) {
$username = $matches[1]; $username = $matches[1];
// Extract just this user's backup // Extract just this user's backup
@@ -12735,7 +12735,7 @@ function discoverDirectAdminBackup(string $backupPath, string $extractDir): arra
$innerPath = "$extractDir/$innerBackup"; $innerPath = "$extractDir/$innerBackup";
if (file_exists($innerPath)) { if (file_exists($innerPath)) {
$innerTarArgs = ''; $innerTarArgs = '';
if (preg_match('/\\.tar\\.zst$/i', $innerPath)) { if (preg_match('/\\.(tar\\.zst|zst)$/i', $innerPath)) {
$innerTarArgs = '--zstd'; $innerTarArgs = '--zstd';
} elseif (preg_match('/\\.(tar\\.gz|tgz)$/i', $innerPath)) { } elseif (preg_match('/\\.(tar\\.gz|tgz)$/i', $innerPath)) {
$innerTarArgs = '-I pigz'; $innerTarArgs = '-I pigz';