add crc32 checksum generation of original file
clean up log statements
This commit is contained in:
@@ -347,6 +347,15 @@ function formatFileSize(bytes) {
|
|||||||
// FILE OPERATIONS
|
// FILE OPERATIONS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
async function calculateFileCrc32(filePath) {
|
||||||
|
try {
|
||||||
|
const buffer = await fs.readFile(filePath);
|
||||||
|
return (crc32.buf(buffer) >>> 0).toString(16).toUpperCase().padStart(8, '0');
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to calculate CRC32: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read and parse the input JSON file
|
* Read and parse the input JSON file
|
||||||
*/
|
*/
|
||||||
@@ -437,6 +446,16 @@ async function saveBackup(outputPath, data) {
|
|||||||
return backupPath;
|
return backupPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create CRC32 checksum file for integrity verification
|
||||||
|
*/
|
||||||
|
async function createCrc32Checksum(outputPath, inputPath) {
|
||||||
|
const fileCrc32 = await calculateFileCrc32(inputPath);
|
||||||
|
const checksumPath = path.join(outputPath, `crc32.txt`);
|
||||||
|
await fs.writeFile(checksumPath, `${fileCrc32}\n`, 'utf-8');
|
||||||
|
return { checksumPath, fileCrc32 };
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// PROPERTY PROCESSING
|
// PROPERTY PROCESSING
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -669,6 +688,12 @@ async function main() {
|
|||||||
console.log(`\n📂 Creating output: ${outputPath}`);
|
console.log(`\n📂 Creating output: ${outputPath}`);
|
||||||
await createOutputDirectory(outputPath, allowOverwrite, cleanExisting);
|
await createOutputDirectory(outputPath, allowOverwrite, cleanExisting);
|
||||||
|
|
||||||
|
// Create CRC32 checksum file for integrity verification
|
||||||
|
console.log(`\n🐾 Creating checksum file...`);
|
||||||
|
const crc32 = await createCrc32Checksum(outputPath, inputPath);
|
||||||
|
console.log(`\n Checksum file: ${crc32.checksumPath}`);
|
||||||
|
//console.log(` CRC32: ${crc32.fileCrc32}`);
|
||||||
|
|
||||||
// Process each root property
|
// Process each root property
|
||||||
console.log('\n⚙️ Processing properties:\n');
|
console.log('\n⚙️ Processing properties:\n');
|
||||||
const processedProperties = [];
|
const processedProperties = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user