From b0bdf1a0208fbbde5f065c1c18e81b36b10ed503 Mon Sep 17 00:00:00 2001 From: michele Date: Mon, 30 Mar 2026 16:20:23 +0000 Subject: [PATCH] Supporto Modifiche: usa worktree cache scrivibile --- .../Commands/NetgesconGitSyncCommand.php | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/NetgesconGitSyncCommand.php b/app/Console/Commands/NetgesconGitSyncCommand.php index b6c92d0..60e0406 100644 --- a/app/Console/Commands/NetgesconGitSyncCommand.php +++ b/app/Console/Commands/NetgesconGitSyncCommand.php @@ -109,8 +109,7 @@ public function handle(): int if ($deploySync) { $this->writeProgress(32, 'Creazione sorgente remota pulita', 'running'); - $worktreePath = storage_path('app/support/git-sync-worktrees/' . now()->format('YmdHis') . '-' . uniqid()); - File::ensureDirectoryExists(dirname($worktreePath)); + $worktreePath = $this->buildWorktreePath(); $worktreeAdd = Process::path($repoPath) ->timeout(1800) @@ -361,6 +360,35 @@ private function resolveSourceRepositoryPath(): ?string return null; } + private function buildWorktreePath(): string + { + $baseDir = $this->resolveWorktreeBaseDir(); + + return $baseDir . '/' . now()->format('YmdHis') . '-' . uniqid(); + } + + private function resolveWorktreeBaseDir(): string + { + $candidates = [ + storage_path('framework/cache/git-sync-worktrees'), + storage_path('app/support/git-sync-worktrees'), + ]; + + foreach ($candidates as $candidate) { + if (! is_dir($candidate)) { + @mkdir($candidate, 0775, true); + } + + if (is_dir($candidate) && is_writable($candidate)) { + @chmod($candidate, 0775); + + return $candidate; + } + } + + throw new \RuntimeException('Nessuna directory worktree scrivibile disponibile per la sync Git.'); + } + private function gitCommandArgs(string $path, array $arguments): array { return array_merge(['git', '-c', 'safe.directory=' . $path], $arguments);