server: improve mixin failures by detecting sameset/superset

This commit is contained in:
Koushik Dutta
2023-01-04 09:28:03 -08:00
parent 040ea4d26d
commit e0da8b402a
3 changed files with 20 additions and 7 deletions

View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/server",
"version": "0.5.6",
"version": "0.5.7",
"description": "",
"dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.1.0",

View File

@@ -203,14 +203,27 @@ export class PluginDeviceProxyHandler implements PrimitiveProxyHandler<any>, 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;
});
}