refactor: reorganize device directories to use true deviceId from /info endpoint

- Replace serial number-based directory structure with deviceId from device /info
- Extract migration logic to handle transition from old to new directory structure
- Fix directory resolution bug that prevented proper migration to deviceId-based paths
- Ensure all device data (Presets.xml, Sources.xml, Recents.xml) preserved during transition
- Add configurable migration with --migration-enabled and --migration-dry-run flags
- Update DeviceInfo.xml to reflect authoritative deviceId from device's /info endpoint
- Directory structure now: /devices/{deviceId}/ instead of /devices/{serialNumber}/

This aligns the directory structure with the device's self-declared identity
and ensures data consistency with the device's /info endpoint.
This commit is contained in:
Tobias Gesellchen
2026-02-24 21:45:40 +01:00
parent 0b75a2f70d
commit a1d0213f92
30 changed files with 4081 additions and 102 deletions
+3 -3
View File
@@ -72,7 +72,7 @@ func TestUPnP_EnrichDeviceInfo_RealDeviceXML(t *testing.T) {
// Create a discovered device to enrich
device := &models.DiscoveredDevice{
Host: "192.168.178.35",
Host: "192.168.1.100",
Port: 8091,
Name: "Initial Device Name",
}
@@ -197,7 +197,7 @@ func TestUPnP_MACAddressDiscovery_Integration(t *testing.T) {
func TestUPnP_URLPattern_Realistic(t *testing.T) {
// Test the exact URL pattern mentioned:
// http://192.168.178.35:8091/XD/BO5EBO5E-F00D-F00D-FEED-A81B6A536A98.xml
// http://192.168.1.100:8091/XD/BO5EBO5E-F00D-F00D-FEED-A81B6A536A98.xml
realDeviceXML := `<?xml version="1.0" encoding="utf-8"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
@@ -224,7 +224,7 @@ func TestUPnP_URLPattern_Realistic(t *testing.T) {
// Test enrichment using the realistic URL path
device := &models.DiscoveredDevice{
Host: "192.168.178.35",
Host: "192.168.1.100",
Port: 8091,
Name: "Initial Name",
}