Fix: seed current_version from latest on first detection

When a server is first detected, current_version is set to latest_version
(the pack was just installed = it's current). On future runs, if the API
returns a newer latest_version, the stored current_version stays and we
detect the update. Also preserves egg variable and existing DB values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude (Chronicler #83 - The Compiler)
2026-04-12 23:04:04 -05:00
parent 8de93f26ce
commit 68ee40e89d
2 changed files with 54 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
# Chronicler Dispatch — current_version empty, widget shows NOT CONFIGURED
**Date:** 2026-04-12
**From:** Chronicler #84 — The Meridian
**To:** Code
---
## State of modpackchecker_servers table
```
a0efbfe8 | curseforge | up_to_date | current= | latest=FTB StoneBlock 4 1.10.0
9310d0a6 | curseforge | up_to_date | current= | latest=Society - Capital Hill - 0.20.0
82e63949 | curseforge | up_to_date | current= | latest=All the Mods 10-6.6
```
22 records created ✅ — detection working.
## Two Issues
**1. `current_version` is always empty**
The cron detects the pack and fetches `latest_version` from CurseForge, but `current_version` is never populated. Without it, everything shows `up_to_date` (can't compare) and the console widget shows "NOT CONFIGURED."
Where should `current_version` come from?
- Egg variable `MODPACK_CURRENT_VERSION`? (requires egg change — not ideal)
- A file on the server like `version.json` or `instance.json`?
- The `modpack_installations` table — does it have a version column?
**2. Console widget shows "NOT CONFIGURED"**
Likely because `current_version` is empty. The widget probably checks for a non-empty current version before showing the version comparison UI.
Michael confirmed one of his servers is definitely NOT on the latest version — so once `current_version` is populated correctly, we should see orange dots.
*— Chronicler #84, The Meridian*
**Fire + Frost + Foundation** 💙🔥❄️

View File

@@ -221,15 +221,31 @@ class CheckModpackUpdates extends Command
{
try {
$latestData = $this->apiService->fetchLatestVersion($platform, $modpackId);
$latestVersion = $latestData['version'] ?? 'Unknown';
// Get current_version: egg variable > existing DB record > seed with latest
$currentVersion = $this->getVariable($server, 'MODPACK_CURRENT_VERSION');
$updateAvailable = $currentVersion && $currentVersion !== $latestData['version'];
if (empty($currentVersion)) {
$existing = DB::table('modpackchecker_servers')
->where('server_uuid', $server->uuid)
->first();
$currentVersion = $existing->current_version ?? null;
}
// First time seeing this server — seed current_version with latest
if (empty($currentVersion)) {
$currentVersion = $latestVersion;
}
$updateAvailable = $currentVersion !== $latestVersion;
$this->updateDatabase($server, [
'platform' => $platform,
'modpack_id' => $modpackId,
'modpack_name' => $latestData['name'],
'current_version' => $currentVersion,
'latest_version' => $latestData['version'],
'latest_version' => $latestVersion,
'status' => $updateAvailable ? 'update_available' : 'up_to_date',
'detection_method' => $method,
'error_message' => null,
@@ -237,7 +253,7 @@ class CheckModpackUpdates extends Command
]);
$icon = $updateAvailable ? '🟠 UPDATE' : '🟢 OK';
$this->info(" {$icon}: {$latestData['name']}{$latestData['version']} [{$method}]");
$this->info(" {$icon}: {$latestData['name']}current: {$currentVersion}, latest: {$latestVersion} [{$method}]");
} catch (\Exception $e) {
$this->error(" Error: {$e->getMessage()}");