@iobroker/db-base
Advanced tools
Comparing version 4.0.0-alpha.53-20220127-399b0768 to 4.0.0-alpha.54-20220128-6762bedd
@@ -119,2 +119,17 @@ /** | ||
ret = await this.loadDatasetFile(datasetName); | ||
// loading worked, make sure that "bak" File is not broken | ||
try { | ||
await fs.readJSON(`${datasetName}.bak`); | ||
} catch (e) { | ||
this.log.info( | ||
`${this.namespace} Rewrite bak file, because error on verify ${datasetName}.bak: ${e.message}` | ||
); | ||
try { | ||
const jsonString = JSON.stringify(ret); | ||
await fs.writeFile(`${datasetName}.bak`, jsonString); | ||
} catch (e) { | ||
this.log.error(`${this.namespace} Cannot save ${datasetName}.bak: ${e.message}`); | ||
} | ||
} | ||
} catch (err) { | ||
@@ -124,3 +139,3 @@ this.log.error(`${this.namespace} Cannot load ${datasetName}: ${err.message}. We try last Backup!`); | ||
try { | ||
ret = await this.loadDatasetFile(datasetName + '.bak'); | ||
ret = await this.loadDatasetFile(`${datasetName}.bak`); | ||
@@ -127,0 +142,0 @@ // it worked, lets overwrite old file and store the broken one for pot. forensic check |
{ | ||
"name": "@iobroker/db-base", | ||
"version": "4.0.0-alpha.53-20220127-399b0768", | ||
"version": "4.0.0-alpha.54-20220128-6762bedd", | ||
"engines": { | ||
@@ -8,3 +8,3 @@ "node": ">=12.0.0" | ||
"dependencies": { | ||
"@iobroker/js-controller-common": "4.0.0-alpha.53-20220127-399b0768", | ||
"@iobroker/js-controller-common": "4.0.0-alpha.54-20220128-6762bedd", | ||
"deep-clone": "^3.0.3", | ||
@@ -39,3 +39,3 @@ "fs-extra": "^10.0.0", | ||
], | ||
"gitHead": "2bb52808377c47630ce5a08d37f25565a64bc2ac" | ||
"gitHead": "df746a8ff737e7e91c49ebdfbe7d88a3486ea4d9" | ||
} |
35006
843