From b538b4119fa2916c1a49bb7a63bd5ec9094f26d3 Mon Sep 17 00:00:00 2001 From: F4ilji Date: Sat, 4 Jul 2026 23:02:43 +0500 Subject: [PATCH] fix(vikon): all FM files go to files/ dir, matching original PHP getFsPathByModule Original vikon_core Path::getFsPathByModule() returns moduleRoot/files/, not moduleRoot. Root FM files, 3-letter subdirs, and new files all go under files/ directory. index.html etc come from core ZIP, not FM sync. --- .../VikonIntegration/Actions/SyncFilesAction.php | 15 ++++++--------- .../VikonIntegration/Actions/UpdateCoreAction.php | 12 ++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/Containers/VikonIntegration/Actions/SyncFilesAction.php b/app/Containers/VikonIntegration/Actions/SyncFilesAction.php index c539e00..dff8261 100644 --- a/app/Containers/VikonIntegration/Actions/SyncFilesAction.php +++ b/app/Containers/VikonIntegration/Actions/SyncFilesAction.php @@ -27,13 +27,13 @@ class SyncFilesAction $synced = 0; - $synced += $this->syncRootDir($moduleId, $modulePath, $accessToken); + $synced += $this->syncRootDir($moduleId, $filesDir, $accessToken); foreach ($dirIds as $dirId) { $synced += $this->syncSubDir($dirId, $moduleId, $filesDir, $accessToken); } - $newSynced = $this->syncNewFiles($moduleId, $accessToken, $modulePath); + $newSynced = $this->syncNewFiles($moduleId, $accessToken, $filesDir); $total = $synced + $newSynced; Log::info('Vikon FM: sync complete', ['downloaded' => $synced, 'new' => $newSynced]); @@ -61,7 +61,7 @@ class SyncFilesAction return $body['directories'] ?? []; } - private function syncRootDir(int $moduleId, string $modulePath, string $accessToken): int + private function syncRootDir(int $moduleId, string $filesDir, string $accessToken): int { $response = $this->http->getWithToken( "sync/getFileNamesFromRootDirectoryByModule?moduleId={$moduleId}", @@ -84,7 +84,7 @@ class SyncFilesAction $accessToken, 'filemanager' ); - file_put_contents($modulePath . '/' . $name, $content); + file_put_contents($filesDir . '/' . $name, $content); $synced++; } catch (\Throwable $e) { Log::warning('Vikon FM: root download failed', ['identity' => $identity, 'error' => $e->getMessage()]); @@ -128,7 +128,7 @@ class SyncFilesAction return $synced; } - private function syncNewFiles(int $moduleId, string $accessToken, string $modulePath): int + private function syncNewFiles(int $moduleId, string $accessToken, string $filesDir): int { $synced = 0; @@ -148,10 +148,7 @@ class SyncFilesAction $filename = $body['file_name']; $directory = $body['dir_name'] ?? null; - $targetDir = $modulePath; - if ($directory) { - $targetDir = $modulePath . '/' . $directory; - } + $targetDir = $directory ? $filesDir . '/' . $directory : $filesDir; $content = $this->http->downloadWithToken( "sync/downloadFileBinary?identity={$identity}", diff --git a/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php b/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php index d1e3ec1..7f98318 100644 --- a/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php +++ b/app/Containers/VikonIntegration/Actions/UpdateCoreAction.php @@ -78,18 +78,18 @@ class UpdateCoreAction $synced = 0; - $synced += $this->syncRootDir($moduleId, $modulePath, $accessToken); + $synced += $this->syncRootDir($moduleId, $filesDir, $accessToken); foreach ($dirIds as $dirId) { $synced += $this->syncSubDir($dirId, $moduleId, $filesDir, $accessToken); } - $newSynced = $this->syncNewFiles($moduleId, $accessToken, $modulePath); + $newSynced = $this->syncNewFiles($moduleId, $accessToken, $filesDir); Log::info('Vikon FM: sync done', ['synced' => $synced, 'new' => $newSynced]); } - private function syncRootDir(int $moduleId, string $modulePath, string $accessToken): int + private function syncRootDir(int $moduleId, string $filesDir, string $accessToken): int { $response = $this->http->getWithToken( "sync/getFileNamesFromRootDirectoryByModule?moduleId={$moduleId}", @@ -112,7 +112,7 @@ class UpdateCoreAction $accessToken, 'filemanager' ); - file_put_contents($modulePath . '/' . $name, $content); + file_put_contents($filesDir . '/' . $name, $content); $synced++; } catch (\Throwable $e) { Log::warning('Vikon FM: root download failed', ['identity' => $identity, 'error' => $e->getMessage()]); @@ -156,7 +156,7 @@ class UpdateCoreAction return $synced; } - private function syncNewFiles(int $moduleId, string $accessToken, string $modulePath): int + private function syncNewFiles(int $moduleId, string $accessToken, string $filesDir): int { $synced = 0; while (true) { @@ -173,7 +173,7 @@ class UpdateCoreAction $filename = $body['file_name']; $directory = $body['dir_name'] ?? null; - $targetDir = $directory ? $modulePath . '/' . $directory : $modulePath; + $targetDir = $directory ? $filesDir . '/' . $directory : $filesDir; try { $content = $this->http->downloadWithToken(