Skip to content

Commit a490317

Browse files
author
vikasrohit
authored
Merge pull request #527 from topcoder-platform/hotfix/post-release-2.2.1
[HOTFIX] [PROD] Post release 2.2.1
2 parents f5283dc + 6b25df7 commit a490317

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- UPDATE EXISTING project_attachments table
2+
-- modify column `path`
3+
4+
ALTER TABLE project_attachments ALTER COLUMN "path" TYPE character varying(2048);

src/models/projectAttachment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function defineProjectAttachment(sequelize, DataTypes) {
1717
size: { type: DataTypes.INTEGER, allowNull: true }, // size in MB
1818
category: { type: DataTypes.STRING, allowNull: true }, // size in MB
1919
description: { type: DataTypes.STRING, allowNull: true },
20-
path: { type: DataTypes.STRING, allowNull: false },
20+
path: { type: DataTypes.STRING(2048), allowNull: false },
2121
contentType: { type: DataTypes.STRING, allowNull: true },
2222
allowedUsers: DataTypes.ARRAY({ type: DataTypes.INTEGER, allowNull: true }),
2323
deletedAt: { type: DataTypes.DATE, allowNull: true },

src/routes/attachments/get.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ const permissions = tcMiddleware.permissions;
1919
* @returns {Array<Promise>} The array of two promises, first one if the attachment object promise,
2020
* The second promise is for the file pre-signed url (if attachment type is file)
2121
*/
22-
const getPreSignedUrl = (req, attachment) => {
22+
const getPreSignedUrl = async (req, attachment) => {
23+
// If the attachment is a link return it as-is without getting the pre-signed url
2324
if (attachment.type === ATTACHMENT_TYPES.LINK) {
24-
// If the attachment is a link return it as-is without getting the pre-signed url
2525
return [attachment, ''];
26-
} // The attachment is a file
27-
// In development/test mode, if file upload is disabled, we return the dummy attachment object
28-
if (_.includes(['development', 'test'], process.env.NODE_ENV) && config.get('enableFileUpload') === 'false') {
26+
}
27+
28+
// The attachment is a file
29+
// In development mode, if file upload is disabled, we return the dummy attachment object
30+
if (_.includes(['development'], process.env.NODE_ENV) && config.get('enableFileUpload') === 'false') {
2931
return [attachment, 'dummy://url'];
3032
}
31-
// Not in development mode or file upload is not disabled
32-
return [attachment, util.getFileDownloadUrl(req, attachment.path)];
33+
// Not in development mode or file upload is not disabled
34+
const url = await util.getFileDownloadUrl(req, attachment.path);
35+
return [attachment, url];
3336
};
3437

3538
module.exports = [

0 commit comments

Comments
 (0)