Merge from vscode 5b9869eb02fa4c96205a74d05cad9164dfd06d60 (#5607)

This commit is contained in:
Anthony Dresser
2019-05-24 12:20:30 -07:00
committed by GitHub
parent 361ada4963
commit bcc449b524
126 changed files with 3096 additions and 2255 deletions

View File

@@ -26,21 +26,23 @@ export class FileStorage {
return this._database;
}
init(): Promise<void> {
return readFile(this.dbPath).then(contents => {
async init(): Promise<void> {
try {
const contents = await readFile(this.dbPath);
try {
this.lastFlushedSerializedDatabase = contents.toString();
this._database = JSON.parse(this.lastFlushedSerializedDatabase);
} catch (error) {
this._database = {};
}
}, error => {
} catch (error) {
if (error.code !== 'ENOENT') {
this.onError(error);
}
this._database = {};
});
}
}
private loadSync(): object {