Skip to content

Commit

Permalink
refactor: use rmdir recursive instead of iterate over files
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Mar 21, 2024
1 parent f80ac0e commit 0f51219
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions electron/walletManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,7 @@ export class WalletManager {

public clearWalletFiles(pathToClear: string) {
if (fs.existsSync(pathToClear)) {
const items = fs.readdirSync(pathToClear, { withFileTypes: true })

for (const item of items) {
const itemPath = path.resolve(pathToClear, item.name)

if (fs.existsSync(itemPath)) {
if (item.isDirectory()) {
this.clearWalletFiles(itemPath)
} else if (item.isFile()) {
fs.unlinkSync(itemPath)
}
}
}

fs.rmdirSync(pathToClear)
fs.rmdirSync(pathToClear, { recursive: true })
}
}

Expand Down Expand Up @@ -319,7 +305,7 @@ export class WalletManager {
this.walletProcess.on('exit', () => {
if (this.relaunch) {
actions.quitApp()
actions.relaunch()
// actions.relaunch()
} else {
actions.quitApp()
}
Expand Down

0 comments on commit 0f51219

Please sign in to comment.