Skip to content

[HOTFIX] [PROD] Post release 2.2.1 #527

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

Merged
merged 2 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions migrations/20200401_increase_path_length_attachments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- UPDATE EXISTING project_attachments table
-- modify column `path`

ALTER TABLE project_attachments ALTER COLUMN "path" TYPE character varying(2048);
2 changes: 1 addition & 1 deletion src/models/projectAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function defineProjectAttachment(sequelize, DataTypes) {
size: { type: DataTypes.INTEGER, allowNull: true }, // size in MB
category: { type: DataTypes.STRING, allowNull: true }, // size in MB
description: { type: DataTypes.STRING, allowNull: true },
path: { type: DataTypes.STRING, allowNull: false },
path: { type: DataTypes.STRING(2048), allowNull: false },
contentType: { type: DataTypes.STRING, allowNull: true },
allowedUsers: DataTypes.ARRAY({ type: DataTypes.INTEGER, allowNull: true }),
deletedAt: { type: DataTypes.DATE, allowNull: true },
Expand Down
17 changes: 10 additions & 7 deletions src/routes/attachments/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ const permissions = tcMiddleware.permissions;
* @returns {Array<Promise>} The array of two promises, first one if the attachment object promise,
* The second promise is for the file pre-signed url (if attachment type is file)
*/
const getPreSignedUrl = (req, attachment) => {
const getPreSignedUrl = async (req, attachment) => {
// If the attachment is a link return it as-is without getting the pre-signed url
if (attachment.type === ATTACHMENT_TYPES.LINK) {
// If the attachment is a link return it as-is without getting the pre-signed url
return [attachment, ''];
} // The attachment is a file
// In development/test mode, if file upload is disabled, we return the dummy attachment object
if (_.includes(['development', 'test'], process.env.NODE_ENV) && config.get('enableFileUpload') === 'false') {
}

// The attachment is a file
// In development mode, if file upload is disabled, we return the dummy attachment object
if (_.includes(['development'], process.env.NODE_ENV) && config.get('enableFileUpload') === 'false') {
return [attachment, 'dummy://url'];
}
// Not in development mode or file upload is not disabled
return [attachment, util.getFileDownloadUrl(req, attachment.path)];
// Not in development mode or file upload is not disabled
const url = await util.getFileDownloadUrl(req, attachment.path);
return [attachment, url];
};

module.exports = [
Expand Down