Fixing adsb enrichment
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import {cfg} from './config.mjs';
|
||||
import Database from 'better-sqlite3';
|
||||
import {createWriteStream, existsSync, mkdirSync} from 'fs';
|
||||
import {readFile, rm} from 'fs/promises';
|
||||
import {resolve, dirname} from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
import {pipeline} from 'stream/promises';
|
||||
import {createGunzip} from 'zlib';
|
||||
import AdmZip from 'adm-zip';
|
||||
import * as fs from 'node:fs';
|
||||
|
||||
const DIR = dirname(fileURLToPath(import.meta.url));
|
||||
const DATA = resolve(DIR, '../data');
|
||||
@@ -33,7 +33,7 @@ async function downloadTypes() {
|
||||
const gunzip = createGunzip();
|
||||
const chunks = [];
|
||||
await new Promise((res, rej) => {
|
||||
const gz = require('fs').createReadStream(TY_GZ);
|
||||
const gz = fs.createReadStream(TY_GZ);
|
||||
gz.pipe(gunzip);
|
||||
gunzip.on('data', c => chunks.push(c));
|
||||
gunzip.on('end', res);
|
||||
@@ -105,10 +105,8 @@ export async function initAircraftDb() {
|
||||
}
|
||||
|
||||
console.log('✈️ Downloading aircraft DB...');
|
||||
const [, types] = await Promise.all([
|
||||
importAircraftDb(),
|
||||
downloadTypes().then(t => importTypes(t))
|
||||
]);
|
||||
await Promise.all([importAircraftDb(), downloadTypes().then(t => importTypes(t))]);
|
||||
await Promise.all([fs.promises.rm(DB_ZIP), fs.promises.rm(TY_GZ),]);
|
||||
}
|
||||
|
||||
const lookupAircraft = (icao) =>
|
||||
@@ -133,7 +131,7 @@ export function enrichAircraft(a) {
|
||||
}
|
||||
|
||||
export async function getShapes() {
|
||||
return JSON.parse(await readFile(SHAPES_PATH, 'utf8'));
|
||||
return JSON.parse(await fs.promises.readFile(SHAPES_PATH, 'utf8'));
|
||||
}
|
||||
|
||||
export async function getADSB() {
|
||||
|
||||
Reference in New Issue
Block a user