MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / zip

Method zip

daemon/src/service/system_file.ts:269–288  ·  view source on GitHub ↗
(sourceZip: string, files: string[], code?: string)

Source from the content-addressed store, hash-verified

267 }
268
269 async zip(sourceZip: string, files: string[], code?: string) {
270 if (!code) code = this.fileCode;
271 if (!this.checkPath(sourceZip)) throw new Error(ERROR_MSG_01);
272 const MAX_ZIP_GB = globalConfiguration.config.maxZipFileSize;
273 const MAX_TOTAL_FIELS_SIZE = 1024 * 1024 * 1024 * MAX_ZIP_GB;
274 const sourceZipPath = this.toAbsolutePath(sourceZip);
275 const filesPath = [];
276 let totalSize = 0;
277 for (const iterator of files) {
278 try {
279 if (this.check(iterator)) {
280 filesPath.push(this.toAbsolutePath(iterator));
281 totalSize += fs.statSync(this.toAbsolutePath(iterator))?.size;
282 }
283 } catch (error: any) {}
284 }
285 if (totalSize > MAX_TOTAL_FIELS_SIZE)
286 throw new Error($t("TXT_CODE_system_file.unzipLimit", { max: MAX_ZIP_GB }));
287 return await compress(sourceZipPath, filesPath, code);
288 }
289
290 async edit(target: string, data?: string) {
291 if (!this.check(target)) throw new Error(ERROR_MSG_01);

Callers 1

file_router.tsFile · 0.80

Calls 6

checkPathMethod · 0.95
toAbsolutePathMethod · 0.95
checkMethod · 0.95
$tFunction · 0.90
compressFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected