From c3a90e4f5df2dfff5c217b980fd17794538ede91 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 2 Jul 2015 18:54:59 +0200 Subject: [PATCH] fix(downloads): Cannot download unnamed attachments (resolves Sentry #598) --- src/flux/stores/file-download-store.coffee | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/flux/stores/file-download-store.coffee b/src/flux/stores/file-download-store.coffee index 171db9312..b33eaa419 100644 --- a/src/flux/stores/file-download-store.coffee +++ b/src/flux/stores/file-download-store.coffee @@ -119,14 +119,22 @@ FileDownloadStore = Reflux.createStore ######### PUBLIC ####################################################### - # Returns a hash of download objects keyed by fileId - + # Returns a path on disk for saving the file. Note that we must account + # for files that don't have a name and avoid returning + # which causes operations to happen on the directory (badness!) + # pathForFile: (file) -> return undefined unless file - path.join(@_downloadDirectory, file.id, "#{file.filename}") + if file.filename and file.filename.length > 0 + downloadFilename = file.filename + else + downloadFilename = file.id + path.join(@_downloadDirectory, file.id, downloadFilename) downloadDataForFile: (fileId) -> @_downloads[fileId]?.data() + # Returns a hash of download objects keyed by fileId + # downloadDataForFiles: (fileIds=[]) -> downloadData = {} fileIds.forEach (fileId) =>