mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
fix(terminal): Update filename parsing regex and improve directory cleanup logic
This commit is contained in:
parent
ec67078d49
commit
2bcf642e22
2 changed files with 6 additions and 3 deletions
|
|
@ -55,7 +55,7 @@ class TerminalFileHelper
|
|||
public static function parseFilename(string $filename): ?array
|
||||
{
|
||||
// Pattern: uploadedAt_expiresAt_serverId_containerUuid_originalName_hash.ext
|
||||
$pattern = '/^(\d+)_(\d+)_(\d+)_([^_]+)_([^_]+)_([a-zA-Z0-9]+)(?:\.(.+))?$/';
|
||||
$pattern = '/^(\d+)_(\d+)_(\d+)_([^_]+)_([^_]+)_([a-zA-Z0-9]+)(?:\.([a-zA-Z0-9]+))?$/';
|
||||
|
||||
if (!preg_match($pattern, $filename, $matches)) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -67,8 +67,11 @@ class CleanupExpiredTerminalFilesJob implements ShouldQueue
|
|||
|
||||
// Clean up empty parent directory
|
||||
$parentDir = dirname($this->localPath);
|
||||
if (is_dir($parentDir) && count(scandir($parentDir)) === 2) { // Only . and ..
|
||||
rmdir($parentDir);
|
||||
if (is_dir($parentDir)) {
|
||||
$contents = scandir($parentDir);
|
||||
if ($contents !== false && count($contents) === 2) { // Only . and ..
|
||||
rmdir($parentDir);
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error("Failed to cleanup terminal file: {$e->getMessage()}", [
|
||||
|
|
|
|||
Loading…
Reference in a new issue