mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-08 04:06:08 +08:00
fix(attachments): Present filesystem access errors
This commit is contained in:
parent
c265cf0dfa
commit
1e0717b801
1 changed files with 17 additions and 1 deletions
|
@ -192,12 +192,15 @@ FileDownloadStore = Reflux.createStore
|
||||||
mkdirpAsync(targetFolder)
|
mkdirpAsync(targetFolder)
|
||||||
|
|
||||||
_fetch: (file) ->
|
_fetch: (file) ->
|
||||||
@_runDownload(file).catch ->
|
@_runDownload(file)
|
||||||
|
.catch(@_catchFSErrors)
|
||||||
|
.catch (error) ->
|
||||||
# Passively ignore
|
# Passively ignore
|
||||||
|
|
||||||
_fetchAndOpen: (file) ->
|
_fetchAndOpen: (file) ->
|
||||||
@_runDownload(file).then (download) ->
|
@_runDownload(file).then (download) ->
|
||||||
shell.openItem(download.targetPath)
|
shell.openItem(download.targetPath)
|
||||||
|
.catch(@_catchFSErrors)
|
||||||
.catch =>
|
.catch =>
|
||||||
@_presentError(file)
|
@_presentError(file)
|
||||||
|
|
||||||
|
@ -224,6 +227,7 @@ FileDownloadStore = Reflux.createStore
|
||||||
@_runDownload(file)
|
@_runDownload(file)
|
||||||
.then (download) => @_saveDownload(download, savePath)
|
.then (download) => @_saveDownload(download, savePath)
|
||||||
.then => shell.showItemInFolder(savePath)
|
.then => shell.showItemInFolder(savePath)
|
||||||
|
.catch(@_catchFSErrors)
|
||||||
.catch =>
|
.catch =>
|
||||||
@_presentError(file)
|
@_presentError(file)
|
||||||
|
|
||||||
|
@ -251,6 +255,7 @@ FileDownloadStore = Reflux.createStore
|
||||||
Promise.all(savePromises)
|
Promise.all(savePromises)
|
||||||
.then =>
|
.then =>
|
||||||
shell.showItemInFolder(lastSavePath) if lastSavePath
|
shell.showItemInFolder(lastSavePath) if lastSavePath
|
||||||
|
.catch(@_catchFSErrors)
|
||||||
.catch =>
|
.catch =>
|
||||||
@_presentError(file)
|
@_presentError(file)
|
||||||
|
|
||||||
|
@ -292,5 +297,16 @@ FileDownloadStore = Reflux.createStore
|
||||||
Check your network connection and try again."
|
Check your network connection and try again."
|
||||||
buttons: ["OK"]
|
buttons: ["OK"]
|
||||||
|
|
||||||
|
_catchFSErrors: (error) ->
|
||||||
|
if error.code in ['EPERM', 'EMFILE', 'EACCES']
|
||||||
|
remote.dialog.showMessageBox
|
||||||
|
type: 'warning'
|
||||||
|
message: "Download Failed"
|
||||||
|
detail: "N1 could not save an attachment. Check that permissions are set correctly and that you have enough disk space.\n\n#{error.message}"
|
||||||
|
buttons: ["OK"]
|
||||||
|
return Promise.resolve()
|
||||||
|
else
|
||||||
|
return Promise.reject(error)
|
||||||
|
|
||||||
# Expose the Download class for our tests, and possibly for other things someday
|
# Expose the Download class for our tests, and possibly for other things someday
|
||||||
FileDownloadStore.Download = Download
|
FileDownloadStore.Download = Download
|
||||||
|
|
Loading…
Add table
Reference in a new issue