Fix: manualCheck now checks modpack_installations + cron cache
Detection priority in manualCheck(): 1. Egg variables 2. modpack_installations table (NEW) 3. DaemonFileRepository file scan 4. Cached cron data from modpackchecker_servers (NEW) Also returns current_version and update_available in response so the console widget can show version comparison. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dce0e06023
commit
32e2d726bb
@@ -92,14 +92,36 @@ class ModpackAPIController extends Controller
|
||||
};
|
||||
}
|
||||
|
||||
// 2. If no egg variables, try file detection
|
||||
// 2. Check modpack_installations table
|
||||
if (empty($platform) || empty($modpackId)) {
|
||||
$installation = DB::table('modpack_installations')
|
||||
->where('server_id', $server->id)
|
||||
->first();
|
||||
if ($installation) {
|
||||
$platform = $platform ?: ($installation->provider ?? null);
|
||||
$modpackId = $modpackId ?: (string) ($installation->modpack_id ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
// 3. If still nothing, try file detection
|
||||
if (empty($platform) || empty($modpackId)) {
|
||||
$detected = $this->detectFromFiles($server);
|
||||
$platform = $platform ?: ($detected['platform'] ?? null);
|
||||
$modpackId = $modpackId ?: ($detected['modpack_id'] ?? null);
|
||||
}
|
||||
|
||||
// 3. If still nothing, return helpful error
|
||||
// 4. If still nothing, check cached cron data
|
||||
if (empty($platform) || empty($modpackId)) {
|
||||
$cached = DB::table('modpackchecker_servers')
|
||||
->where('server_uuid', $server->uuid)
|
||||
->first();
|
||||
if ($cached && !empty($cached->platform) && !empty($cached->modpack_id)) {
|
||||
$platform = $cached->platform;
|
||||
$modpackId = $cached->modpack_id;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. If still nothing, return helpful error
|
||||
if (empty($platform) || empty($modpackId)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
@@ -109,16 +131,24 @@ class ModpackAPIController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// 4. Check the appropriate API using the unified Service
|
||||
// 6. Check the appropriate API using the unified Service
|
||||
try {
|
||||
$versionData = $this->apiService->fetchLatestVersion($platform, $modpackId);
|
||||
|
||||
// Get cached current_version for comparison
|
||||
$cached = DB::table('modpackchecker_servers')
|
||||
->where('server_uuid', $server->uuid)
|
||||
->first();
|
||||
$currentVersion = $cached->current_version ?? null;
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'platform' => $platform,
|
||||
'modpack_id' => $modpackId,
|
||||
'modpack_name' => $versionData['name'],
|
||||
'current_version' => $currentVersion,
|
||||
'latest_version' => $versionData['version'],
|
||||
'update_available' => $currentVersion && $currentVersion !== $versionData['version'],
|
||||
'status' => 'checked',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user