diff --git a/server/package-lock.json b/server/package-lock.json index 460ec10f6..fdb5a10b3 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/server", - "version": "0.5.6", + "version": "0.5.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/server", - "version": "0.5.6", + "version": "0.5.7", "license": "ISC", "dependencies": { "@ffmpeg-installer/ffmpeg": "^1.1.0", diff --git a/server/package.json b/server/package.json index db62dda88..43d39ce63 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/server", - "version": "0.5.6", + "version": "0.5.7", "description": "", "dependencies": { "@ffmpeg-installer/ffmpeg": "^1.1.0", diff --git a/server/src/plugin/plugin-device.ts b/server/src/plugin/plugin-device.ts index 6d250974a..a5936b25f 100644 --- a/server/src/plugin/plugin-device.ts +++ b/server/src/plugin/plugin-device.ts @@ -203,14 +203,27 @@ export class PluginDeviceProxyHandler implements PrimitiveProxyHandler, Scr } return this.mixinTable[0].entry.then(entry => { - if (!entry.error) { + let persist = !entry.error; + if (entry.error) { + console.error('Mixin device creation completed with error.'); + const allInterfaces = new Set(entry.allInterfaces); + const previousInterfaces = getState(pluginDevice, ScryptedInterfaceProperty.interfaces) as string[] || []; + + let containsAll = true; + while (containsAll && previousInterfaces.length) { + containsAll &&= allInterfaces.has(previousInterfaces.pop()); + } + + persist = containsAll; + if (persist) + console.log('Mixin device completed with interface same set or super set of previous set. Persisting.') + } + + if (persist) { const changed = this.scrypted.stateManager.setPluginDeviceState(pluginDevice, ScryptedInterfaceProperty.interfaces, PluginDeviceProxyHandler.sortInterfaces(entry.allInterfaces)); if (changed) this.scrypted.notifyPluginDeviceDescriptorChanged(pluginDevice); } - else { - console.error('Mixin device creation completed with error.'); - } return pluginDevice; }); }