fix: initialization steps should wait on tar.gz promise to continue

This commit is contained in:
2025-03-24 02:01:03 -07:00
parent f0237eb488
commit fab2bc636a

View File

@@ -851,28 +851,31 @@ async function initialize()
set cwd to the folder where the xmltv.1.xml file is located set cwd to the folder where the xmltv.1.xml file is located
*/ */
tar.c( const tarFiles = [];
await tar.c(
{ {
gzip: true, gzip: true,
cwd: path.resolve( __dirname ), cwd: path.resolve( __dirname ),
mtime: new Date(), noPax: true,
strict: false, onWriteEntry( entry )
portable: true, {
jobs: 2, Log.debug( `tar.gz: adding`, chalk.yellow( ` ${ entry.path } ` ), chalk.white( `` ), chalk.grey( `${ entry.stat.mode.toString( 8 ) }` ) );
maxReadSize: 48 * 1024 * 1024, entry.path = entry.path.toLowerCase();
tarFiles.push([ entry.path, entry.stat.mode.toString( 8 ) ]);
},
onwarn: ( code, message, data ) => onwarn: ( code, message, data ) =>
{ {
Log.warn( `Tar.gz warning:`, chalk.white( `` ), chalk.grey( `[${ code }] ${ message }` ) ); Log.warn( `tar.gz warning:`, chalk.white( `` ), chalk.grey( `[${ code }] ${ message }` ) );
} }
}, },
[`${ envFileXML }`] [`${ envFileXML }`]
).pipe( fs.createWriteStream( `${ envFileTAR }` ) ); )
.pipe( fs.createWriteStream( `${ envFileTAR }` ) )
.on( 'finish', () =>
{
urls = fs.readFileSync( FILE_URL, 'utf-8' ).split( '\n' ).filter( Boolean ); urls = fs.readFileSync( FILE_URL, 'utf-8' ).split( '\n' ).filter( Boolean );
if ( urls.length === 0 ) if ( urls.length === 0 )
{
throw new Error( `No valid URLs found in ${ FILE_URL }` ); throw new Error( `No valid URLs found in ${ FILE_URL }` );
}
/* /*
Calculate Sizes Calculate Sizes
@@ -887,6 +890,11 @@ async function initialize()
FILE_TAR_MODIFIED = getFileModified( FILE_TAR ); FILE_TAR_MODIFIED = getFileModified( FILE_TAR );
Log.info( `Initializing Complete` ); Log.info( `Initializing Complete` );
})
.on( 'error', ( err ) =>
{
Log.error( `Could not create tar:`, chalk.white( `` ), chalk.grey( `${ err }` ) );
});
} }
catch ( error ) catch ( error )
{ {