Skip to content

Commit

Permalink
do not shadow the scope of newFilePath;
Browse files Browse the repository at this point in the history
  • Loading branch information
EllAchE committed Mar 20, 2024
1 parent 6f66b8f commit d788dc0
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/zst_decompressor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ const decompressAndAnalyze = async (file, start = 0) => {

// const base_path = `/Users/bennyrubanov/Coding_Projects/chessanalysis/data/${file.replace(
// base_path used to enumerate where new files should go
const base_path = path.resolve(__dirname, '..', 'data', file.replace('.zst', ''));
const base_path = path.resolve(
__dirname,
'..',
'..',
'data',
file.replace('.zst', '')
);
// for use in decompressionStreamFromFile
const compressedFilePath = path.resolve(__dirname, '..', 'data');
const compressedFilePath = path.resolve(__dirname, '..', '..', 'data');

// Create a new file path
const newFilePath = `${base_path}_${randomUUID()}`;
let newFilePath = `${base_path}_${randomUUID()}`;
filesProduced.add(newFilePath);

// Create a new writable strxeam
Expand All @@ -117,7 +123,9 @@ const decompressAndAnalyze = async (file, start = 0) => {
`${compressedFilePath}/${file}`,
(err, result) => {
if (err) return reject(err);
console.log(`Decompressing file located at ${compressedFilePath}/${file}`);
console.log(
`Decompressing file located at ${compressedFilePath}/${file}`
);

let fileLength = 0;
let batch_files_total_decompressed_size = 0;
Expand Down Expand Up @@ -147,12 +155,12 @@ const decompressAndAnalyze = async (file, start = 0) => {
console.log(
`Total number of chunks decompressed so far: ${total_chunk_counter}`
);

// Increment the file counter
file_counter++;

// Create a new file path
const newFilePath = `${base_path}_${randomUUID()}`;
newFilePath = `${base_path}_${randomUUID()}`;
filesProduced.add(newFilePath);

// Switch to a new file
Expand Down Expand Up @@ -240,6 +248,6 @@ module.exports = processFiles;
// run if main
if (require.main === module) {
// List of all the database files you want to analyze (these need to be downloaded and in data folder)
const files = ['lichess_db_standard_rated_2013-01.pgn.zst' /*...*/];
const files = ['lichess_db_standard_rated_2013-02.pgn.zst' /*...*/];
processFiles(files);
}

0 comments on commit d788dc0

Please sign in to comment.