📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
added some logging and fixed paths
Blue Mouse0f4f2407f980
diff --git a/meta/dbip-sync.js b/meta/dbip-sync.jsindex 905ccd1de..3ca6697cc 100644--- a/meta/dbip-sync.js+++ b/meta/dbip-sync.js@@ -11,11 +11,15 @@ const month = (currentDate.getMonth() + 1).toString().padStart(2, '0')const DOWNLOAD_LINK = `https://download.db-ip.com/free/dbip-city-lite-${year}-${month}.mmdb.gz`const DESTINATION_FILE = 'dbip-city-lite.mmdb'+const ORIGINAL_FILE = 'dbip-city-lite.mmdb.gz'const DESTINATION_FOLDER = path.join(__dirname, '../')-const GEOIP_DB_PATH = path.join(DESTINATION_FOLDER, DESTINATION_FILE)+const GEOIP_DB_PATH = path.join(DESTINATION_FOLDER, ORIGINAL_FILE)+const UNZIPPED_PATH = path.join(DESTINATION_FOLDER, DESTINATION_FILE)// Function to download a filefunction downloadFile(url, destPath) {+ console.log(`Downloading ${url} to ${destPath}...`)+return new Promise((resolve, reject) => {const fileStream = fs.createWriteStream(destPath)@@ -24,15 +28,18 @@ function downloadFile(url, destPath) {fileStream.on('finish', () => {fileStream.close()+ console.log('[OK] Download finished!')resolve()})fileStream.on('error', (error) => {fs.unlinkSync(destPath)+ console.log('[ERROR] Download failed.')reject(error)})}).on('error', (error) => {fs.unlinkSync(destPath)+ console.log('[ERROR] Download failed.')reject(error)})})@@ -42,20 +49,20 @@ function downloadFile(url, destPath) {try {await downloadFile(DOWNLOAD_LINK, GEOIP_DB_PATH)- const unzippedPath = path.join(path.dirname(DESTINATION_FOLDER), DESTINATION_FILE)const gunzip = zlib.createGunzip()const inputStream = fs.createReadStream(GEOIP_DB_PATH)- const outputStream = fs.createWriteStream(unzippedPath)+ const outputStream = fs.createWriteStream(UNZIPPED_PATH)inputStream.pipe(gunzip).pipe(outputStream)outputStream.on('finish', () => {+ console.log('[OK] File unzipped! .gz file removed.')fs.unlinkSync(GEOIP_DB_PATH) // Remove the original .gz file})outputStream.on('error', (error) => {fs.unlinkSync(GEOIP_DB_PATH)- console.error('Error:', error.message)+ console.error('[ERROR] Could not unzip file:', error.message)})} catch (error) {- console.error('Error:', error.message)+ console.error('[ERROR] An error occured:', error.message)}})()