Fix SCUM config manifest refresh
This commit is contained in:
@@ -812,11 +812,15 @@ func (svc *CoreService) upsertLatestGamePlugin(plugin domain.GamePlugin) (domain
|
||||
}
|
||||
}
|
||||
if current.ID != "" && !domain.GamePluginIsNewer(plugin, current) {
|
||||
// Re-registering the same stable manifest ID must refresh its declarative
|
||||
// contract; file targets and action assets can be corrected in place.
|
||||
if current.ID != plugin.ID || domain.CompareGamePluginVersions(plugin.Version, current.Version) != 0 {
|
||||
if err := svc.pruneOlderGamePluginVersions(current, matched); err != nil {
|
||||
return domain.GamePlugin{}, err
|
||||
}
|
||||
return domain.CopyGamePlugin(current), nil
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := svc.store.GamePlugins().Get(plugin.ID); err == nil {
|
||||
if err := svc.store.GamePlugins().Update(plugin); err != nil {
|
||||
|
||||
@@ -2011,6 +2011,35 @@ func TestCoreServiceUpsertsDuplicateGamePluginManifest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceRefreshesSameVersionPluginManifestDeclarations(t *testing.T) {
|
||||
svc := newTestCoreService()
|
||||
registration := validPluginManifestRegistration()
|
||||
registration.Manifest.FileWorkspace = domain.PluginFileWorkspace{
|
||||
DefaultDirectoryKey: "config",
|
||||
Directories: []domain.PluginLogicalDirectory{{Key: "config", Label: "配置", Scope: "config"}},
|
||||
Files: []domain.PluginLogicalFile{{Key: "settings", DirectoryKey: "config", Label: "Settings.ini", Kind: "config", Editable: true}},
|
||||
}
|
||||
if _, err := svc.RegisterGamePluginManifest(registration); err != nil {
|
||||
t.Fatalf("register legacy manifest: %v", err)
|
||||
}
|
||||
|
||||
registration.Manifest.FileWorkspace.Files[0].TargetKey = "SCUM/Saved/Config/WindowsServer/ServerSettings.ini"
|
||||
refreshed, err := svc.RegisterGamePluginManifest(registration)
|
||||
if err != nil {
|
||||
t.Fatalf("refresh same-version manifest: %v", err)
|
||||
}
|
||||
if len(refreshed.FileWorkspace.Files) != 1 || refreshed.FileWorkspace.Files[0].TargetKey != "SCUM/Saved/Config/WindowsServer/ServerSettings.ini" {
|
||||
t.Fatalf("expected same-version manifest declaration to refresh, got %+v", refreshed.FileWorkspace)
|
||||
}
|
||||
stored, err := svc.store.GamePlugins().Get(registration.Manifest.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("load refreshed manifest: %v", err)
|
||||
}
|
||||
if stored.FileWorkspace.Files[0].TargetKey != refreshed.FileWorkspace.Files[0].TargetKey {
|
||||
t.Fatalf("expected stored manifest target to refresh, stored=%+v refreshed=%+v", stored.FileWorkspace, refreshed.FileWorkspace)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceKeepsOnlyLatestPluginVersionAndMigratesReferences(t *testing.T) {
|
||||
svc := newTestCoreService()
|
||||
stale := validPluginManifestRegistration()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"id": "game.scum",
|
||||
"name": "SCUM Server",
|
||||
"description": "First-party SCUM game server operations plugin with platform-mediated lifecycle and plugin-owned RCON data flows.",
|
||||
"version": "0.1.26",
|
||||
"version": "0.1.27",
|
||||
"kind": "game-plugin",
|
||||
"tags": [
|
||||
"scum",
|
||||
|
||||
@@ -357,7 +357,7 @@ describe("plugin manifest validation", () => {
|
||||
const serialized = JSON.stringify(manifest).toLowerCase();
|
||||
|
||||
expect(serialized).not.toContain("local-proof");
|
||||
expect(manifest.version).toBe("0.1.26");
|
||||
expect(manifest.version).toBe("0.1.27");
|
||||
expect(installAction.environment?.SERVER_TEMPLATE).toBe("scum-server");
|
||||
expect(manifest.permissions).toEqual(expect.arrayContaining(["server.game-client.read", "server.game-client.command", "server.game-client.maintenance"]));
|
||||
expect(manifest.gameClientBridge.commands.map((command) => command.type)).toEqual(expect.arrayContaining([
|
||||
|
||||
Reference in New Issue
Block a user