Skip to content

Commit

Permalink
fix: limit cockpit editor file size
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Medeiros authored and iurimatias committed Mar 11, 2019
1 parent 616af6d commit f12ca22
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/embark-ui/src/services/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

export async function addEditorTabs({file}) {
const editorTabs = findOrCreateEditorTabs();

// Avoid files bigger than 1MB. Browsers limit heavily
// how much local storage we can actually use.
if(file.content.length > 1024 * 1024) {
alert('File is too big');
return {response: {data: editorTabs}};
}

editorTabs.forEach(f => f.active = false);
const alreadyAddedFile = editorTabs.find(f => f.name === file.name);
if (alreadyAddedFile) {
Expand Down

0 comments on commit f12ca22

Please sign in to comment.