mirror of
https://github.com/Eugeny/tabby
synced 2024-11-15 01:17:14 +00:00
fixed config file getting spontaneously erased - fixes #4293
This commit is contained in:
parent
94819019ec
commit
8b8bacdf69
1 changed files with 12 additions and 1 deletions
|
@ -24,6 +24,7 @@ try {
|
|||
export class ElectronPlatformService extends PlatformService {
|
||||
supportsWindowControls = true
|
||||
private configPath: string
|
||||
private _configSaveInProgress = Promise.resolve()
|
||||
|
||||
constructor (
|
||||
private hostApp: HostAppService,
|
||||
|
@ -107,7 +108,17 @@ export class ElectronPlatformService extends PlatformService {
|
|||
}
|
||||
|
||||
async saveConfig (content: string): Promise<void> {
|
||||
await fs.writeFile(this.configPath, content, 'utf8')
|
||||
try {
|
||||
await this._configSaveInProgress
|
||||
} catch { }
|
||||
this._configSaveInProgress = this._saveConfigInternal(content)
|
||||
await this._configSaveInProgress
|
||||
}
|
||||
|
||||
async _saveConfigInternal (content: string): Promise<void> {
|
||||
const tempPath = this.configPath + '.new'
|
||||
await fs.writeFile(tempPath, content, 'utf8')
|
||||
await fs.rename(tempPath, this.configPath)
|
||||
}
|
||||
|
||||
getConfigPath (): string|null {
|
||||
|
|
Loading…
Reference in a new issue