diff --git a/app/Containers/VikonIntegration/Actions/SyncFilesAction.php b/app/Containers/VikonIntegration/Actions/SyncFilesAction.php index dff8261..d25a744 100644 --- a/app/Containers/VikonIntegration/Actions/SyncFilesAction.php +++ b/app/Containers/VikonIntegration/Actions/SyncFilesAction.php @@ -72,12 +72,23 @@ class SyncFilesAction $files = $response->json()['files'] ?? []; if (empty($files)) return 0; + $existingFiles = []; + if (File::isDirectory($filesDir)) { + foreach (File::files($filesDir) as $f) { + $existingFiles[$f->getFilename()] = $f->getSize(); + } + } + $synced = 0; foreach ($files as $file) { $name = $file['n'] ?? null; $identity = $file['i'] ?? null; if (!$name || !$identity) continue; + if (isset($existingFiles[$name]) && $existingFiles[$name] > 0) { + continue; + } + try { $content = $this->http->downloadWithToken( "sync/downloadFileBinaryForSync?identity={$identity}&moduleId={$moduleId}", @@ -107,12 +118,21 @@ class SyncFilesAction $targetDir = $filesDir . '/' . $dirId; File::makeDirectory($targetDir, 0755, true, true); + $existingFiles = []; + foreach (File::files($targetDir) as $f) { + $existingFiles[$f->getFilename()] = $f->getSize(); + } + $synced = 0; foreach ($files as $file) { $name = $file['n'] ?? null; $identity = $file['i'] ?? null; if (!$name || !$identity) continue; + if (isset($existingFiles[$name]) && $existingFiles[$name] > 0) { + continue; + } + try { $content = $this->http->downloadWithToken( "sync/downloadFileBinaryForSync?identity={$identity}&moduleId={$moduleId}", diff --git a/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php b/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php index 7f98318..0d451b0 100644 --- a/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php +++ b/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php @@ -100,12 +100,23 @@ class UpdateCoreAction $files = $response->json()['files'] ?? []; if (empty($files)) return 0; + $existingFiles = []; + if (File::isDirectory($filesDir)) { + foreach (File::files($filesDir) as $f) { + $existingFiles[$f->getFilename()] = $f->getSize(); + } + } + $synced = 0; foreach ($files as $file) { $name = $file['n'] ?? null; $identity = $file['i'] ?? null; if (!$name || !$identity) continue; + if (isset($existingFiles[$name]) && $existingFiles[$name] > 0) { + continue; + } + try { $content = $this->http->downloadWithToken( "sync/downloadFileBinaryForSync?identity={$identity}&moduleId={$moduleId}", @@ -135,12 +146,21 @@ class UpdateCoreAction $targetDir = $filesDir . '/' . $dirId; File::makeDirectory($targetDir, 0755, true, true); + $existingFiles = []; + foreach (File::files($targetDir) as $f) { + $existingFiles[$f->getFilename()] = $f->getSize(); + } + $synced = 0; foreach ($files as $file) { $name = $file['n'] ?? null; $identity = $file['i'] ?? null; if (!$name || !$identity) continue; + if (isset($existingFiles[$name]) && $existingFiles[$name] > 0) { + continue; + } + try { $content = $this->http->downloadWithToken( "sync/downloadFileBinaryForSync?identity={$identity}&moduleId={$moduleId}",