Skip to content

Commit

Permalink
Empty tmp folder on start
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkilr88 committed Apr 6, 2020
1 parent d5d9611 commit 4c3c154
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main.js
Expand Up @@ -16,12 +16,20 @@ const outputPath = isDev
? path.join(__dirname, 'tmp')
: path.join(app.getPath('userData'), 'tmp')

// TODO: Empty out this directory on app start.
// If the app is closed while downloading a file, the file is not removed
// Create tmp directory if it doesn't exist
if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath)
}

// Empty out this directory on app start.
// If the app is closed while downloading a file, the file is not removed
// ? How to do this before close
const files = fs.readdirSync(outputPath)

for (let file of files) {
removeFile(path.join(outputPath, file))
}

const downloader = new Downloader({
outputPath,
})
Expand Down

0 comments on commit 4c3c154

Please sign in to comment.