Skip to content

Commit

Permalink
Merge pull request #9850 from RocketChat/allow-unlimited-file-size_fi…
Browse files Browse the repository at this point in the history
…x-slack-importer

[FIX] Importers no longer working due to the FileUpload changes
  • Loading branch information
rodrigok committed Feb 26, 2018
2 parents a7f05b1 + 1f68b76 commit 4cdb12d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-file-upload/globalFileRestrictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const slingShotConfig = {

const maxFileSize = RocketChat.settings.get('FileUpload_MaxFileSize');

if (maxFileSize && maxFileSize < file.size) {
if (maxFileSize >= -1 && maxFileSize < file.size) {
throw new Meteor.Error(TAPi18n.__('File_exceeds_allowed_size_of_bytes', { size: filesize(maxFileSize) }));
}

Expand Down
11 changes: 8 additions & 3 deletions packages/rocketchat-file-upload/lib/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ FileUpload = {
throw new Meteor.Error('error-direct-message-file-upload-not-allowed', reason);
}

if (file.size > maxFileSize) {
// -1 maxFileSize means there is no limit
if (maxFileSize >= -1 && file.size > maxFileSize) {
const reason = TAPi18n.__('File_exceeds_allowed_size_of_bytes', {
size: filesize(maxFileSize)
}, user.language);
throw new Meteor.Error('error-file-too-large', reason);
}

if (parseInt(maxFileSize) > 0) {
if (maxFileSize > 0) {
if (file.size > maxFileSize) {
const reason = TAPi18n.__('File_exceeds_allowed_size_of_bytes', {
size: filesize(maxFileSize)
Expand All @@ -56,5 +57,9 @@ FileUpload = {
};

RocketChat.settings.get('FileUpload_MaxFileSize', function(key, value) {
maxFileSize = value;
try {
maxFileSize = parseInt(value);
} catch (e) {
maxFileSize = RocketChat.models.Settings.findOneById('FileUpload_MaxFileSize').packageValue;
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class Base {
RocketChat.models.Settings.updateValueById('Accounts_AllowUsernameChange', true);

this.oldSettings.FileUpload_MaxFileSize = RocketChat.models.Settings.findOneById('FileUpload_MaxFileSize').value;
RocketChat.models.Settings.updateValueById('FileUpload_MaxFileSize', 0);
RocketChat.models.Settings.updateValueById('FileUpload_MaxFileSize', -1);
break;
case ProgressStep.DONE:
case ProgressStep.ERROR:
Expand Down

0 comments on commit 4cdb12d

Please sign in to comment.