Preserve MPC-HC registry keys when applying settings
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good
Details
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good
Details
This commit is contained in:
parent
98ca7a1b61
commit
f3ed5d9411
1
TASKS.md
1
TASKS.md
|
|
@ -133,3 +133,4 @@ open until it is run on disposable machines with the required account setups.
|
|||
- [x] Report CLI exceptions concisely on stderr without throwing from the error handler; preserve exit code 2 and JSON errors.
|
||||
- [x] Accept signed registry DWORD/QWORD exports and validate the complete MPC-HC declaration with mocked registry writes.
|
||||
- [x] Color terminal item statuses while preserving plain redirected output and supporting NO_COLOR.
|
||||
- [x] Preserve existing registry keys during MPC-HC apply and document registry-only storage and capture filtering.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,18 @@ MPC-HC normally stores preferences below
|
|||
`HKCU\Software\MPC-HC\MPC-HC`. Config Central applies only values listed in
|
||||
`configs/mpc-hc/settings.json`; it does not delete other values or registry keys.
|
||||
|
||||
This adapter supports **registry mode only**. MPC-HC also supports an INI file
|
||||
next to its executable (`mpc-hc.ini` or `mpc-hc64.ini`). Check the player's
|
||||
settings-storage option before capture or apply: an old registry key can remain
|
||||
even when the active player uses INI storage. A successful registry write does
|
||||
not prove the player reads that registry key.
|
||||
See [MPC-HC's storage implementation](https://github.com/clsid2/mpc-hc/blob/develop/src/mpc-hc/mplayerc.cpp).
|
||||
|
||||
Capture is deliberately filtered, not a complete player backup: monitor/device
|
||||
selection and other machine-specific or private values are excluded. Apply only
|
||||
updates declared values for the current Windows user. Close MPC-HC before
|
||||
capture or deployment, then reopen it afterward.
|
||||
|
||||
On the machine whose settings should be the baseline, close MPC-HC and run:
|
||||
|
||||
```powershell
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ function Set-RegistryDeclaration {
|
|||
param([string]$Root, $Declaration)
|
||||
foreach ($entry in $Declaration.values) {
|
||||
$path = if ([string]::IsNullOrWhiteSpace([string]$entry.path)) { $Root } else { Join-Path $Root $entry.path }
|
||||
[void](New-Item -Path $path -Force)
|
||||
if (-not (Test-Path -LiteralPath $path)) { [void](New-Item -Path $path -ErrorAction Stop) }
|
||||
$value = switch ($entry.type) {
|
||||
'DWord' { if ($entry.value -lt 0) { [int32]$entry.value } else { [uint32]$entry.value } }
|
||||
'QWord' { if ($entry.value -lt 0) { [int64]$entry.value } else { [uint64]$entry.value } }
|
||||
|
|
|
|||
|
|
@ -89,3 +89,35 @@ Describe 'Registry integer deployment' {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Registry key preservation' {
|
||||
It 'preserves existing values while applying multiple values to the same key' {
|
||||
InModuleScope Adapters {
|
||||
$script:stored = @{ Existing = 'keep' }
|
||||
Mock Test-Path { $true }
|
||||
Mock New-Item { throw 'Existing key must not be recreated' }
|
||||
Mock New-ItemProperty { $script:stored[$Name] = $Value }
|
||||
$declaration = [pscustomobject]@{ values = @(
|
||||
[pscustomobject]@{ path = ''; name = 'First'; type = 'DWord'; value = 1 },
|
||||
[pscustomobject]@{ path = ''; name = 'Second'; type = 'DWord'; value = 2 }
|
||||
) }
|
||||
Set-RegistryDeclaration -Root 'TestRoot' -Declaration $declaration
|
||||
$script:stored.Existing | Should -Be 'keep'
|
||||
$script:stored.First | Should -Be 1
|
||||
$script:stored.Second | Should -Be 2
|
||||
Should -Invoke New-Item -Times 0
|
||||
}
|
||||
}
|
||||
It 'creates a missing key without forcing replacement' {
|
||||
InModuleScope Adapters {
|
||||
Mock Test-Path { $false }
|
||||
Mock New-Item {}
|
||||
Mock New-ItemProperty {}
|
||||
$declaration = [pscustomobject]@{ values = @(
|
||||
[pscustomobject]@{ path = ''; name = 'First'; type = 'DWord'; value = 1 }
|
||||
) }
|
||||
Set-RegistryDeclaration -Root 'TestRoot' -Declaration $declaration
|
||||
Should -Invoke New-Item -Times 1 -ParameterFilter { -not $Force }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue