feat(vikon): cleanup _old/_new artifacts after successful sync

This commit is contained in:
F4ilji
2026-07-05 13:58:00 +05:00
parent 416403b6ce
commit b0ff3bf397
3 changed files with 63 additions and 2 deletions
@@ -28,6 +28,7 @@ class UpdateCoreAction
$this->downloadCore($moduleId, $modulePath, $tempPath, $accessToken);
$this->syncFromFM($moduleId, $modulePath, $accessToken);
$this->cleanupPostSync($modulePath);
File::put($modulePath . '/.vikon', date('Y-m-d H:i:s'));
@@ -302,4 +303,34 @@ class UpdateCoreAction
}
}
}
private function cleanupPostSync(string $modulePath): void
{
if (!File::isDirectory($modulePath)) {
return;
}
$removed = 0;
// Remove _old and _new directories/files left after successful atomic swap
foreach (File::directories($modulePath) as $dir) {
$name = basename($dir);
if (str_ends_with($name, '_old') || str_ends_with($name, '_new')) {
File::deleteDirectory($dir);
$removed++;
}
}
foreach (File::files($modulePath) as $file) {
$name = $file->getFilename();
if (str_ends_with($name, '_old') || str_ends_with($name, '_new')) {
File::delete($file->getPathname());
$removed++;
}
}
if ($removed > 0) {
Log::info('Vikon: cleaned up post-sync', ['removed' => $removed]);
}
}
}