Skip to content

Commit 860b6ef

Browse files
author
Vikas Agarwal
committed
We don’t need to set download URL any more per attachment because we calculate the download URL at run time to avoid expiration of the signed url. It would also fix the issue in performance because now it won’t make extra calls to fetch download urls and also fixed the issue where we are unable to load project with many attachments.
1 parent 25e4b65 commit 860b6ef

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

src/util.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -248,26 +248,9 @@ _.assignIn(util, {
248248
return models.ProjectAttachment.getActiveProjectAttachments(projectId)
249249
.then((_attachments) => {
250250
// if attachments were requested
251-
if (attachments) {
251+
if (_attachments) {
252252
attachments = _attachments;
253-
} else {
254-
return attachments;
255253
}
256-
// TODO consider using redis to cache attachments urls
257-
const promises = [];
258-
_.each(attachments, (a) => {
259-
promises.push(util.getFileDownloadUrl(req, a.filePath));
260-
});
261-
return Promise.all(promises);
262-
})
263-
.then((result) => {
264-
// result is an array of 'tuples' => [[path, url], [path,url]]
265-
// convert it to a map for easy lookup
266-
const urls = _.fromPairs(result);
267-
_.each(attachments, (at) => {
268-
const a = at;
269-
a.downloadUrl = urls[a.filePath];
270-
});
271254
return attachments;
272255
});
273256
},

0 commit comments

Comments
 (0)