diff --git a/updater/Full_Package_20221104183433-221101-3.zip b/updater/Full_Package_20221104183433-221101-3.zip new file mode 100644 index 0000000..ec3ed4f --- /dev/null +++ b/updater/Full_Package_20221104183433-221101-3.zip @@ -0,0 +1,400 @@ + + + + AeroNav Association - AIRAC Downloads + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+
+ +
+
+
+ +

+ NavData powered by 
+ Aerosoft NavDataPro 

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 ADRIAVATSIM Adria
AFRCVATSSA Africa Control Centre
 AFRXAfrica UIR/FSS Control Stations
CARICaribbean Control
CZEGEdmonton FIR
 CZQQMoncton Gander FIR
CZULFIR de Montréal
 CZVRVancouver FIR
CZWGWinnipeg FIR
CZYZToronto FIR
DGACVATSSA Accra
DNKKVATSSA Kano
 DTTCTunis
EBBUBelux vACC
EDXXVATSIM Germany
 EETTVACC Estonia
EHAADutch VACC
EPWWPolish VACC
EUROEuroCenter vACC
 EVRRvACC Latvia
 EXCXOShanwick & Gander Oceanic
FAXXVATSSA South Africa
FBGRVATSSA Gaborone
FCCCVATSSA Brazzaville
FIMMVATSSA Mauritius
FLFIVATSSA Lusaka
FMMMVATSSA Antananarivo
FNANVATSSA Luanda
FQBEVATSSA Beira
FSSSVATSSA Seychelles
 FTTTN Djamena
FVHFVATSSA Harare
FWLLVATSSA Lilongwe
FYWHVATSSA Windhoek
FZZAVATSSA Kinshasa
GMMMMorocco vACC
GOOOVATSSA Dakar
GOOOOVATSSA Dakar Oceanic
GULFGulf FSS Control Stations
GVSCVATSSA Sal
 HAAANorth East Africa vACC - Addis Ababa
 HECCEgypt vACC
HKNAVATSSA Nairobi
 HSSSNorth East Africa vACC - Khartoum
HTDCVATSSA Dar es Salaam
HUECVATSSA Entebbe
 LBSRvACC Bulgaria
LCCCvACC Cyprus
LEXXvACC Spain
 LFXXFrench vACC
LGGGHellenic vACC
 LHCCvACC Hungary
 LIXXvACC Italy
LKAAPraha
 LLLLVATSIM ISRAEL Division
LOVVVacc Austria
 LPPCPortugal vACC
 LPPOPortugal VACC
LRBBVATSIM ROMANIA
LSASvACC Switzerland
LTXXTurkish vACC
 LZBBVacc Slovakia
MDCSSanto Domingo FIR
 MKJKKingston FIR
MYNANassau FIR
OBBBArabian vACC - Bahrain
 OEJDvACC Saudi Arabia
 OIIXvACC Iran
 OJACJordan vACC
OKACKuwait vACC
 OLBBLebanon vACC
OMAEArabian vACC - U.A.E
OOMMArabian vACC - Oman
OPXXvACC Pakistan
ORBBIraq vACC
 SBXXVATSIM Brasil
SCAVATSIM Scandinavia
 SEFGVATSIM Venezuela
 SMPMParamaribo
 SOOOCayenne
 SPIMLima
 SRMSri Lanka & Maldives vACC
 SYGCGeorgetown
TJZSSan Juan CERAP
TNCFCuracao FIR
 TTZPPiarco FIR
UBBACaucasus ACC - Baku FIR
UDDDCaucasus ACC - Yerevan FIR
UGGGCaucasus ACC - Tbilisi FIR
 UKBVvACC Ukraine
 UMKKKaliningrad FIR
URRVCaucasus ACC - Rostov FIR
 VGFRDhaka vACC
 VNSMVATSIM Nepal vACC
 VXXXIndia vACC
Powered by AeroNav Association.
+
+ + + + + + diff --git a/updater/src/downloader.js b/updater/src/downloader.js new file mode 100644 index 0000000..e69de29 diff --git a/updater/src/index.js b/updater/src/index.js index 47a40b5..d7e311a 100644 --- a/updater/src/index.js +++ b/updater/src/index.js @@ -8,6 +8,7 @@ var DecompressZip = require('decompress-zip'); const { Http2ServerRequest } = require('http2'); const superagent = require('superagent').agent(); const http = require('node:http'); +const { options } = require('superagent'); // Handle creating/removing shortcuts on Windows when installing/uninstalling. // eslint-disable-next-line global-require @@ -93,8 +94,8 @@ const createWindow = () => { .set('Sec-Fetch-Site', 'cross-site') .set('Sec-Fetch-User', '?1'); // Working Download - // download(BrowserWindow.getFocusedWindow(), info.url, info.properties) - // .then(dl => mainWindow.webContents.send("download complete", dl.getSavePath())); + download(BrowserWindow.getFocusedWindow(), info.url, info.properties) + .then(dl => mainWindow.webContents.send("download complete", dl.getSavePath())); }); diff --git a/updater/src/renderer.js b/updater/src/renderer.js index acc586a..b2f9341 100644 --- a/updater/src/renderer.js +++ b/updater/src/renderer.js @@ -1,5 +1,6 @@ const { ipcRenderer, dialog } = require('electron'); const superagent = require('superagent').agent(); +var fs = require('fs'); // Global Variabels let hrefLinks = ""; @@ -168,4 +169,75 @@ const getFiles = async() => { console.log(hrefLinksArray); return hrefLinksArray; +} + + + + + + +// Download idea from https://damieng.com/blog/2017/03/10/downloading-files-with-progress-in-electron/ + +download("https://files.aero-nav.com/EDGG/Full_Package_20221104183433-221101-3.zip", "Full_Package_20221104183433-221101-3.zip", (bytes, percent) => console.log(`Downloaded ${bytes} (${percent})`)); + + +//import fs from "fs"; + +async function download( + sourceUrl, + targetFile, + progressCallback, + length +) { + const request = new Request(sourceUrl, { + headers: new Headers({ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate, br", "DNT": "1", "Connection": "keep-alive", "Referer": "http://files.aero-nav.com/", "Upgrade-Insecure-Requests": "1", "Sec-Fetch-Dest": "document", "Sec-Fetch-Mode": "navigate", "Sec-Fetch-Site": "cross-site", "Sec-Fetch-User": "?1" }), + }); + + + const response = await fetch(request); + if (!response.ok) { + throw Error( + `Unable to download, server returned ${response.status} ${response.statusText}` + ); + } + + const body = response.body; + if (body == null) { + throw Error("No response body"); + } + + const finalLength = + length || parseInt(response.headers.get("Content-Length" || "0"), 10); + const reader = body.getReader(); + const writer = fs.createWriteStream(targetFile); + + await streamWithProgress(finalLength, reader, writer, progressCallback); + writer.end(); +} + +async function streamWithProgress(length, reader, writer, progressCallback) { + let bytesDone = 0; + + while (true) { + const result = await reader.read(); + if (result.done) { + if (progressCallback != null) { + progressCallback(length, 100); + } + return; + } + + const chunk = result.value; + if (chunk == null) { + throw Error("Empty chunk received during download"); + } else { + writer.write(Buffer.from(chunk)); + if (progressCallback != null) { + bytesDone += chunk.byteLength; + const percent = + length === 0 ? null : Math.floor((bytesDone / length) * 100); + progressCallback(bytesDone, percent); + } + } + } } \ No newline at end of file