Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print useful error on write fail #1843

Merged
merged 2 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
},
"couldNotSaveDialog": {
"title": "Could not write to disk",
"message": "There was an error writing to the disk. Please try again."
"message": "There was an error writing to \"{ dir }\": \"{ error }\". Please try again or inspect logs for more details."
},
"launchAtLoginNotSupported": {
"title": "Error",
Expand Down
3 changes: 2 additions & 1 deletion src/dialogs/prompt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ module.exports = async function showPrompt (options) {
? pallette.dark.background
: pallette.default.background,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
},
...options.window
})
Expand Down
12 changes: 8 additions & 4 deletions src/download-cid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ const SHORTCUT = IS_MAC
: 'CommandOrControl+Alt+D'

async function saveFile (dir, file) {
const location = join(dir, file.path)
await fs.outputFile(location, file.content)
const destination = join(dir, file.path)
if (!destination.startsWith(dir)) {
throw new Error(`unable to create '${file.path}' outside of '${dir}'`)
}
lidel marked this conversation as resolved.
Show resolved Hide resolved
await fs.outputFile(destination, file.content)
}

async function get (ipfs, cid) {
Expand Down Expand Up @@ -129,11 +132,12 @@ async function downloadCid (ctx) {
shell.showItemInFolder(join(dir, files[0].path))
}
} catch (err) {
logger.error(`[cid download] ${err.toString()}`)
const errMsg = err.toString()
logger.error(`[cid download] ${errMsg}`)

showDialog({
title: i18n.t('couldNotSaveDialog.title'),
message: i18n.t('couldNotSaveDialog.message'),
message: i18n.t('couldNotSaveDialog.message', { dir, error: errMsg }),
buttons: [i18n.t('close')]
})
}
Expand Down