(sourceZip: string, files: string[], code?: string)
| 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); |
no test coverage detected