0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 07:10:44 -05:00
server/project/scripts/databaseCompress.js
Refringe f55861528a
Compress Database Location Files (#954)
Due to LFS storage issues... This PR removes all current LFS files (the
location loot files) and replaces them with a single 7-zip archive. The
archive is stored in LFS, but has decreased in size by roughly 95%.

The location `.json` files are now git-ignored.

There are two new npm commands to aid in working with the archive:
- `npm run database:compress`  
Compresses the JSON files into an archive *which can be committed into
the project*.
- `npm run database:decompress`  
Decompresses the archive into the original JSON files located in the
working directory.

The gulp file that handles builds has been updated to ensure that the
archive files are *always* used when a build is processed, regardless of
if the JSON files are already present in the working directory.
2024-11-28 15:51:53 +00:00

29 lines
765 B
JavaScript

// This script compresses the locations database into a 7z archive.
const Seven = require("node-7z");
const path = require("node:path");
const { path7za } = require("7zip-bin");
const archivePath = path.resolve(__dirname, "../assets/compressed/database/locations.7z");
const locationsDir = path.resolve(__dirname, "../assets/database/locations/*.json");
let hadError = false;
const myStream = Seven.add(archivePath, locationsDir, {
recursive: true,
$bin: path7za,
method: ["0=LZMA2"],
compressionLevel: 9,
});
myStream.on("end", () => {
if (!hadError) {
console.log("Compression completed successfully.");
}
});
myStream.on("error", (err) => {
hadError = true;
console.error(`Error compressing locations: ${err}`);
});