From b90ff0e09a0f5cdae2237c0983996511ed1627e9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 22 Sep 2025 12:54:37 +0200 Subject: [PATCH] refactor(remoteProcess): remove redundant file transfer functions for improved clarity --- bootstrap/helpers/remoteProcess.php | 58 ----------------------------- 1 file changed, 58 deletions(-) diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 56386a55f..3218bf878 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -84,64 +84,6 @@ function instant_scp(string $source, string $dest, Server $server, $throwError = ); } -function transfer_file_to_container(string $content, string $container_path, string $deployment_uuid, Server $server, bool $throwError = true): ?string -{ - $temp_file = tempnam(sys_get_temp_dir(), 'coolify_env_'); - - try { - // Write content to temporary file - file_put_contents($temp_file, $content); - - // Generate unique filename for server transfer - $server_temp_file = '/tmp/coolify_env_'.uniqid().'_'.$deployment_uuid; - - // Transfer file to server - instant_scp($temp_file, $server_temp_file, $server, $throwError); - - // Ensure parent directory exists in container, then copy file - $parent_dir = dirname($container_path); - $commands = []; - if ($parent_dir !== '.' && $parent_dir !== '/') { - $commands[] = executeInDocker($deployment_uuid, "mkdir -p \"$parent_dir\""); - } - $commands[] = "docker cp $server_temp_file $deployment_uuid:$container_path"; - $commands[] = "rm -f $server_temp_file"; // Cleanup server temp file - - return instant_remote_process_with_timeout($commands, $server, $throwError); - - } finally { - // Always cleanup local temp file - if (file_exists($temp_file)) { - unlink($temp_file); - } - } -} - -function transfer_file_to_server(string $content, string $server_path, Server $server, bool $throwError = true): ?string -{ - $temp_file = tempnam(sys_get_temp_dir(), 'coolify_env_'); - - try { - // Write content to temporary file - file_put_contents($temp_file, $content); - - // Ensure parent directory exists on server - $parent_dir = dirname($server_path); - if ($parent_dir !== '.' && $parent_dir !== '/') { - instant_remote_process_with_timeout(["mkdir -p \"$parent_dir\""], $server, $throwError); - } - - // Transfer file directly to server destination - return instant_scp($temp_file, $server_path, $server, $throwError); - - } finally { - // Always cleanup local temp file - if (file_exists($temp_file)) { - unlink($temp_file); - } - } -} - function instant_remote_process_with_timeout(Collection|array $command, Server $server, bool $throwError = true, bool $no_sudo = false): ?string { $command = $command instanceof Collection ? $command->toArray() : $command;