Update platform.service.ts

This commit is contained in:
Eugene Pankov 2022-03-16 10:26:38 +01:00
parent 515ddbf64b
commit 7e876afb3b
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -3,6 +3,7 @@ import * as fs from 'fs/promises'
import * as gracefulFS from 'graceful-fs' import * as gracefulFS from 'graceful-fs'
import * as fsSync from 'fs' import * as fsSync from 'fs'
import * as os from 'os' import * as os from 'os'
import { v4 as uuidv4 } from 'uuid'
import { promisify } from 'util' import { promisify } from 'util'
import promiseIpc, { RendererProcessType } from 'electron-promise-ipc' import promiseIpc, { RendererProcessType } from 'electron-promise-ipc'
import { execFile } from 'mz/child_process' import { execFile } from 'mz/child_process'
@ -119,7 +120,7 @@ export class ElectronPlatformService extends PlatformService {
} }
async _saveConfigInternal (content: string): Promise<void> { async _saveConfigInternal (content: string): Promise<void> {
const tempPath = this.configPath + '.new.' + Date.now().toString() const tempPath = this.configPath + '.new.' + uuidv4().toString()
await fs.writeFile(tempPath, content, 'utf8') await fs.writeFile(tempPath, content, 'utf8')
await fs.writeFile(this.configPath + '.backup', content, 'utf8') await fs.writeFile(this.configPath + '.backup', content, 'utf8')
await promisify(gracefulFS.rename)(tempPath, this.configPath) await promisify(gracefulFS.rename)(tempPath, this.configPath)