@smarterhomeapp/homebridge-vantage 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vantageInfusion.d.ts +1 -0
- package/dist/vantageInfusion.js +26 -0
- package/package.json +1 -1
|
@@ -44,6 +44,7 @@ export declare class VantageInfusion extends EventEmitter {
|
|
|
44
44
|
private buildCacheXml;
|
|
45
45
|
private pullConfigurationXml;
|
|
46
46
|
private writePersistentCacheAtomically;
|
|
47
|
+
private writeLegacyTmpCacheMirror;
|
|
47
48
|
private validateCandidateAgainstExistingCache;
|
|
48
49
|
private validateExistingCacheForReplacement;
|
|
49
50
|
setBrightness(vid: string, level: number): Promise<void>;
|
package/dist/vantageInfusion.js
CHANGED
|
@@ -293,6 +293,7 @@ class VantageInfusion extends events_1.EventEmitter {
|
|
|
293
293
|
}
|
|
294
294
|
this.opts.log.warn(`Persistent cache update failed; using live configuration for this run: ${this.errorMessage(error)}`);
|
|
295
295
|
}
|
|
296
|
+
await this.writeLegacyTmpCacheMirror(xml, validation);
|
|
296
297
|
}
|
|
297
298
|
// Legacy: "end configuration download"
|
|
298
299
|
this.opts.log.debug('VantagePlatform for InFusion Controller (end configuration download)');
|
|
@@ -784,6 +785,31 @@ class VantageInfusion extends events_1.EventEmitter {
|
|
|
784
785
|
throw error;
|
|
785
786
|
}
|
|
786
787
|
}
|
|
788
|
+
async writeLegacyTmpCacheMirror(xml, candidateValidation) {
|
|
789
|
+
const cachePath = path.join('/tmp', 'vantage.dc');
|
|
790
|
+
const tmpPath = `${cachePath}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
791
|
+
try {
|
|
792
|
+
fs.writeFileSync(tmpPath, xml, 'utf8');
|
|
793
|
+
const tmpXml = fs.readFileSync(tmpPath, 'utf8');
|
|
794
|
+
const validation = await this.parseAndValidateConfigurationXml(tmpXml, `legacy temporary cache mirror ${tmpPath}`);
|
|
795
|
+
if (validation.relevantObjectCount !== candidateValidation.relevantObjectCount) {
|
|
796
|
+
throw new Error(`legacy cache mirror validation mismatch: ${validation.relevantObjectCount} relevant objects ` +
|
|
797
|
+
`vs ${candidateValidation.relevantObjectCount} expected`);
|
|
798
|
+
}
|
|
799
|
+
fs.renameSync(tmpPath, cachePath);
|
|
800
|
+
this.opts.log.debug(`Legacy /tmp Vantage cache mirror updated at ${cachePath}`);
|
|
801
|
+
}
|
|
802
|
+
catch (error) {
|
|
803
|
+
try {
|
|
804
|
+
if (fs.existsSync(tmpPath))
|
|
805
|
+
fs.unlinkSync(tmpPath);
|
|
806
|
+
}
|
|
807
|
+
catch {
|
|
808
|
+
/* preserve original error */
|
|
809
|
+
}
|
|
810
|
+
this.opts.log.warn(`Failed to update legacy /tmp Vantage cache mirror: ${this.errorMessage(error)}`);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
787
813
|
async validateCandidateAgainstExistingCache(cachePath, candidateValidation) {
|
|
788
814
|
if (!fs.existsSync(cachePath))
|
|
789
815
|
return;
|