Skip to content

Commit

Permalink
All: For now, disable attaching resources larger than 10MB due to #371
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed May 3, 2018
1 parent 4c210d0 commit 80b467e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ElectronClient/app/gui/NoteText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ class NoteTextComponent extends React.Component {
});
} catch (error) {
reg.logger().error(error);
bridge().showErrorMessageBox(error.message);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions ReactNativeClient/lib/components/screens/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,16 @@ class NoteScreenComponent extends BaseScreenComponent {
return;
} else {
await RNFetchBlob.fs.cp(localFilePath, targetPath);
const stat = await shim.fsDriver().stat(targetPath);
if (stat.size >= 10000000) {
await shim.fsDriver().remove(targetPath);
throw new Error('Resources larger than 10 MB are not currently supported as they may crash the mobile applications. The issue is being investigated and will be fixed at a later time.');
}
}
}
} catch (error) {
reg.logger().warn('Could not attach file:', error);
await dialogs.error(this, error.message);
return;
}

Expand Down
3 changes: 3 additions & 0 deletions ReactNativeClient/lib/shim-init-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ function shimInit() {
if (resource.mime == 'image/jpeg' || resource.mime == 'image/jpg' || resource.mime == 'image/png') {
const result = await resizeImage_(filePath, targetPath, resource.mime);
} else {
const stat = await shim.fsDriver().stat(filePath);
if (stat.size >= 10000000) throw new Error('Resources larger than 10 MB are not currently supported as they may crash the mobile applications. The issue is being investigated and will be fixed at a later time.');

await fs.copy(filePath, targetPath, { overwrite: true });
}

Expand Down

0 comments on commit 80b467e

Please sign in to comment.