depreciate jszip w/ native zlib compression

This commit is contained in:
Samuel JJ Gosling 2022-10-30 19:44:20 +00:00
parent a628c50b32
commit 2b059eb0f9
219 changed files with 24 additions and 76 deletions

View File

@ -43,7 +43,6 @@
"graphql": "^15.5.1",
"idb": "^6.0.0",
"jspdf": "^1.5.3",
"jszip": "^3.5.0",
"lodash": "^4.17.21",
"node-fetch": "^2.6.1",
"numbro": "^2.3.2",

View File

@ -1,24 +1,14 @@
import fs from 'fs'
import Jszip from 'jszip'
import zlib from 'zlib'
import Web3 from 'web3'
import networkConfig from '../../networkConfig'
const jszip = new Jszip()
export async function download({ name, directory, contentType }) {
const path = `${directory}${name}.zip`.toLowerCase()
const path = `${directory}${name}.gz`.toLowerCase()
const data = fs.readFileSync(path)
const zip = await jszip.loadAsync(data)
const file = zip.file(
path
.replace(directory, '')
.slice(0, -4)
.toLowerCase()
)
const content = await file.async(contentType)
const content = zlib.inflateSync(data)
return content
}

View File

@ -1,33 +1,19 @@
import fs from 'fs'
import Jszip from 'jszip'
const compressionConfig = {
type: "nodebuffer",
compression: "DEFLATE",
compressionOptions: {
level: 9
}
}
const fileConfig = {
binary: true,
compression: "DEFLATE"
}
import zlib from 'zlib'
export async function save(filePath) {
const jszip = new Jszip()
const directories = filePath.split('/')
const fileName = directories[directories.length - 1]
try {
const data = fs.readFileSync(`${filePath}`)
await jszip.file(`${fileName}`, data, fileConfig)
await jszip.generateNodeStream({
...compressionConfig,
streamFiles: true
const payload = await zlib.deflateSync(data, {
level: zlib.constants.Z_BEST_COMPRESSION,
strategy: zlib.constants.Z_FILTERED
})
.pipe(fs.createWriteStream(`${filePath}.zip`))
fs.writeFileSync(`${filePath}.gz`, payload)
return true
} catch (err) {

View File

@ -45,7 +45,7 @@ function createTreeZip(netId) {
treesFolder.forEach((fileName) => {
fileName = `${TREES_PATH}${fileName}`
const isInstanceFile = !fileName.includes('.zip') && fileName.includes(baseFilename)
const isInstanceFile = !fileName.includes('.gz') && fileName.includes(baseFilename)
if (isInstanceFile) {
save(fileName)

View File

@ -123,7 +123,7 @@ class EventService {
const module = await download({
contentType: 'string',
name: `events/${instanceName}.json.zip`
name: `events/${instanceName}.json.gz`
})
if (module) {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
static/tornado.json.gz Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More