mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 06:50:43 -05:00
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.
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
// This script removes the contents of the locations directory and then decompresses
|
|
// the locations database from a 7z archive.
|
|
|
|
const Seven = require("node-7z");
|
|
const path = require("node:path");
|
|
const fs = require("fs-extra");
|
|
const { path7za } = require("7zip-bin");
|
|
|
|
const archivePath = path.resolve(__dirname, "../assets/compressed/database/locations.7z");
|
|
const databaseDir = path.resolve(__dirname, "../assets/database/locations");
|
|
|
|
(async () => {
|
|
try {
|
|
const archiveExists = await fs.pathExists(archivePath);
|
|
if (!archiveExists) {
|
|
console.error("Error: Archive file does not exist:", archivePath);
|
|
process.exit(1);
|
|
}
|
|
|
|
const locationsDir = path.join(databaseDir, "locations");
|
|
if (await fs.pathExists(locationsDir)) {
|
|
await fs.remove(locationsDir);
|
|
console.log("Existing locations directory removed.");
|
|
}
|
|
|
|
let hadError = false;
|
|
|
|
const myStream = Seven.extractFull(archivePath, databaseDir, {
|
|
$bin: path7za,
|
|
overwrite: "a",
|
|
});
|
|
|
|
myStream.on("end", () => {
|
|
if (!hadError) {
|
|
console.log("Decompression completed successfully.");
|
|
}
|
|
});
|
|
|
|
myStream.on("error", (err) => {
|
|
hadError = true;
|
|
console.error(`Error decompressing locations: ${err}`);
|
|
});
|
|
} catch (err) {
|
|
console.error(`Error during decompression: ${err}`);
|
|
process.exit(1);
|
|
}
|
|
})();
|