mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
The route read the whole upload into memory, up to its 200 MB cap, opened the zip from that buffer, and read each attachment whole, up to 100 MB, to put it on the board JSON as base64. The upload is now written to a temporary file as it arrives, under the same cap, the zip is opened from the file, and each attachment streams from its entry into storage through TrelloCreator, counted against the same per-file limit and the same 1 GB budget of everything inflated (server/lib/boundedZipEntry.js boundedZipEntryStream). Only the board JSON files are held in memory. The .zip import takes the people choice too. Removed from TODO Later. Thanks to markusst1982 and xet7 !
40 lines
2.0 KiB
JavaScript
40 lines
2.0 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
|
|
const imports = read('client/imports.js');
|
|
const sidebar = read('client/components/sidebar/sidebar.js');
|
|
const htmlExport = read('client/lib/exportHTML.js');
|
|
const gantt = read('client/components/gantt/gantt.js');
|
|
const uploads = read('client/lib/attachmentUploadConfig.js');
|
|
const attachments = read('client/components/cards/attachments.js');
|
|
const trelloZip = read('server/routes/importTrelloZip.js');
|
|
|
|
assert.doesNotMatch(imports, /import ['"]\/client\/lib\/exportHTML['"]/,
|
|
'the uncommon HTML exporter is not part of every page bootstrap');
|
|
assert.match(sidebar,
|
|
/click \.html-export-board[\s\S]{0,180}await import\('\/client\/lib\/exportHTML'\)/,
|
|
'the board action loads its implementation only after the user requests it');
|
|
assert.match(htmlExport, /await import\('fflate'\)/,
|
|
'the shared ZIP implementation remains behind the lazy feature boundary');
|
|
assert.doesNotMatch(htmlExport, /JSZip|from ['"]fflate['"]/,
|
|
'no second ZIP package or eager fflate import reaches page startup');
|
|
assert.doesNotMatch(gantt, /markdown-it|markdownit/,
|
|
'the Gantt page does not load an unused Markdown parser');
|
|
assert.match(uploads, /Random\.hexString\(24\)/,
|
|
'attachment ids use the already-present Meteor random primitive');
|
|
assert.doesNotMatch(`${uploads}\n${attachments}`, /from ['"]bson['"]/,
|
|
'attachment UI does not load BSON merely to create or display an id');
|
|
assert.doesNotMatch(trelloZip, /jszip|JSZip/i,
|
|
'Trello import shares the existing streaming server ZIP reader');
|
|
// The upload is written to a temporary file and opened from there, so the
|
|
// package is not held in memory.
|
|
assert.match(trelloZip, /unzipper\.Open\.file\(zipPath\)/,
|
|
'Trello ZIP metadata and entries use the common server reader');
|
|
|
|
console.log('clientLazyLoading: HTML export and its ZIP writer are action-loaded');
|