From 76bb18324eed7edb88c9e51e450a4606c0dde487 Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 15 Apr 2026 14:17:49 +0200 Subject: [PATCH 1/7] add eos_installer_version query param when url includes images cloud url, version & images url are in a .env --- app/.env | 2 ++ app/app.settings.js | 6 ++++ .../controller/utils/http-fetcher.class.js | 28 +++++++++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 app/.env create mode 100644 app/app.settings.js diff --git a/app/.env b/app/.env new file mode 100644 index 0000000..fff10f7 --- /dev/null +++ b/app/.env @@ -0,0 +1,2 @@ +VITE_IMAGES_CLOUD=images.ecloud.global +VITE_APP_VERSION=0.14 diff --git a/app/app.settings.js b/app/app.settings.js new file mode 100644 index 0000000..326e70c --- /dev/null +++ b/app/app.settings.js @@ -0,0 +1,6 @@ +/** + * Application settings loaded from environment variables + */ + +export const IMAGES_CLOUD = import.meta.env.VITE_IMAGES_CLOUD; +export const APP_VERSION = import.meta.env.VITE_APP_VERSION; diff --git a/app/src/controller/utils/http-fetcher.class.js b/app/src/controller/utils/http-fetcher.class.js index 777ac90..1fae176 100644 --- a/app/src/controller/utils/http-fetcher.class.js +++ b/app/src/controller/utils/http-fetcher.class.js @@ -1,5 +1,6 @@ import ky from "ky"; import { createSHA256 } from "hash-wasm"; +import { IMAGES_CLOUD, APP_VERSION } from "../../../app.settings.js"; const SHA256_CHUNK_SIZE = 16 * 1024 * 1024; // 16 MB const DOWNLOAD_CHUNK_SIZE = 16 * 1024 * 1024; // 16 MB @@ -19,12 +20,13 @@ export class HttpFetcher { const contentLength = await this.getContentLength(path); const totalChunks = Math.ceil(contentLength / DOWNLOAD_CHUNK_SIZE); const buffers = []; + const urlObj = this.formatUrl(path); for (let i = 0; i < totalChunks; i++) { const start = i * DOWNLOAD_CHUNK_SIZE; const end = Math.min(start + DOWNLOAD_CHUNK_SIZE - 1, contentLength - 1); try { - const response = await ky.get(path, { + const response = await ky.get(urlObj, { headers: { Range: `bytes=${start}-${end}` }, }); if (!response.ok) { @@ -51,7 +53,8 @@ export class HttpFetcher { * @returns {Promise} Parsed lowercase SHA-256 hash. */ async fetchChecksum(url) { - const res = await ky.get(url); + const urlObj = this.formatUrl(url); + const res = await ky.get(urlObj); if (!res.ok) { throw new Error(`Cannot fetch checksum (${res.status})`); } @@ -90,7 +93,26 @@ export class HttpFetcher { * @returns {Promise} Content length in bytes. */ async getContentLength(url) { - const response = await ky.head(url); + const urlObj = this.formatUrl(url); + const response = await ky.head(urlObj); return parseInt(response.headers.get("content-length"), 10); } + + /** + * Formats a URL with optional query parameters. + * + * @param {string} url Base URL. + * @param {Object} opts Query parameters as key-value pairs. + * @returns {URL} Formatted URL object. + */ + formatUrl(url, opts = {}) { + const urlObj = new URL(url); + for (const [key, value] of Object.entries(opts)) { + urlObj.searchParams.set(key, String(value)); + } + if (url.includes(IMAGES_CLOUD)) { + urlObj.searchParams.set("eos_installer_version", APP_VERSION); + } + return urlObj; + } } -- GitLab From 2ff5da9359ade398eb7e508adbc7d3882c265ce6 Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 15 Apr 2026 14:22:26 +0200 Subject: [PATCH 2/7] renaming confusing variable --- app/src/controller/utils/http-fetcher.class.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/controller/utils/http-fetcher.class.js b/app/src/controller/utils/http-fetcher.class.js index 1fae176..fd492b3 100644 --- a/app/src/controller/utils/http-fetcher.class.js +++ b/app/src/controller/utils/http-fetcher.class.js @@ -12,15 +12,15 @@ export class HttpFetcher { /** * Downloads a file in sequential Range chunks and returns a Blob. * - * @param {string} path File URL to download. + * @param {string} url File URL to download. * @param {(loaded:number,total:number)=>void} onProgress Progress callback. * @returns {Promise} Downloaded file blob. */ - async download(path, onProgress) { - const contentLength = await this.getContentLength(path); + async download(url, onProgress) { + const contentLength = await this.getContentLength(url); const totalChunks = Math.ceil(contentLength / DOWNLOAD_CHUNK_SIZE); const buffers = []; - const urlObj = this.formatUrl(path); + const urlObj = this.formatUrl(url); for (let i = 0; i < totalChunks; i++) { const start = i * DOWNLOAD_CHUNK_SIZE; -- GitLab From 388dd9d244a6a6ba7b8aa9291ce0289865c4cf16 Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 15 Apr 2026 14:35:21 +0200 Subject: [PATCH 3/7] lint error --- app/src/controller/utils/http-fetcher.class.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/controller/utils/http-fetcher.class.js b/app/src/controller/utils/http-fetcher.class.js index fd492b3..32f579a 100644 --- a/app/src/controller/utils/http-fetcher.class.js +++ b/app/src/controller/utils/http-fetcher.class.js @@ -98,7 +98,7 @@ export class HttpFetcher { return parseInt(response.headers.get("content-length"), 10); } - /** + /** * Formats a URL with optional query parameters. * * @param {string} url Base URL. -- GitLab From 2f8810bbc3b0c50b5f1b80df64599e751ec75bf3 Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 15 Apr 2026 16:54:07 +0200 Subject: [PATCH 4/7] update .env when there is a bump to a new version --- scripts/version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/version.sh b/scripts/version.sh index 687cc02..47d3092 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -6,7 +6,7 @@ function bump() { cd $ROOT_DIR local old=$1 local new=$2 - sed -i 's!'$old'!'$new'!g' app/index.html app/package.json + sed -i 's!'$old'!'$new'!g' app/index.html app/package.json app/.env cd $ROOT_DIR/app npm install exit 0 -- GitLab From 94ab08fcaf2f41a300cbdf90d6afbe3cb2732d26 Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 15 Apr 2026 17:05:38 +0200 Subject: [PATCH 5/7] remove condition to add eos_version query param in fetch url --- app/.env | 1 - app/src/controller/utils/http-fetcher.class.js | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/.env b/app/.env index fff10f7..7db0087 100644 --- a/app/.env +++ b/app/.env @@ -1,2 +1 @@ -VITE_IMAGES_CLOUD=images.ecloud.global VITE_APP_VERSION=0.14 diff --git a/app/src/controller/utils/http-fetcher.class.js b/app/src/controller/utils/http-fetcher.class.js index 32f579a..94d03fd 100644 --- a/app/src/controller/utils/http-fetcher.class.js +++ b/app/src/controller/utils/http-fetcher.class.js @@ -1,6 +1,6 @@ import ky from "ky"; import { createSHA256 } from "hash-wasm"; -import { IMAGES_CLOUD, APP_VERSION } from "../../../app.settings.js"; +import { APP_VERSION } from "../../../app.settings.js"; const SHA256_CHUNK_SIZE = 16 * 1024 * 1024; // 16 MB const DOWNLOAD_CHUNK_SIZE = 16 * 1024 * 1024; // 16 MB @@ -110,9 +110,7 @@ export class HttpFetcher { for (const [key, value] of Object.entries(opts)) { urlObj.searchParams.set(key, String(value)); } - if (url.includes(IMAGES_CLOUD)) { - urlObj.searchParams.set("eos_installer_version", APP_VERSION); - } + urlObj.searchParams.set("eos_installer_version", APP_VERSION); return urlObj; } } -- GitLab From 9297203b6d2636738f3f0747dafa7ef9c4f2cf31 Mon Sep 17 00:00:00 2001 From: Paula Date: Thu, 16 Apr 2026 11:00:48 +0200 Subject: [PATCH 6/7] remove IMAGES_CLOUD from app/app.settings.js --- app/app.settings.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/app.settings.js b/app/app.settings.js index 326e70c..9a37a7f 100644 --- a/app/app.settings.js +++ b/app/app.settings.js @@ -1,6 +1,4 @@ /** * Application settings loaded from environment variables */ - -export const IMAGES_CLOUD = import.meta.env.VITE_IMAGES_CLOUD; export const APP_VERSION = import.meta.env.VITE_APP_VERSION; -- GitLab From 877ececa3029577fd2bec46b39015eb716cc80c5 Mon Sep 17 00:00:00 2001 From: Paula Date: Thu, 16 Apr 2026 16:34:40 +0200 Subject: [PATCH 7/7] remove .env & update version directly in sources --- app/.env | 1 - app/app.settings.js | 2 +- scripts/version.sh | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 app/.env diff --git a/app/.env b/app/.env deleted file mode 100644 index 7db0087..0000000 --- a/app/.env +++ /dev/null @@ -1 +0,0 @@ -VITE_APP_VERSION=0.14 diff --git a/app/app.settings.js b/app/app.settings.js index 9a37a7f..bd08239 100644 --- a/app/app.settings.js +++ b/app/app.settings.js @@ -1,4 +1,4 @@ /** * Application settings loaded from environment variables */ -export const APP_VERSION = import.meta.env.VITE_APP_VERSION; +export const APP_VERSION = "0.14"; diff --git a/scripts/version.sh b/scripts/version.sh index 47d3092..7cc2cab 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -6,7 +6,7 @@ function bump() { cd $ROOT_DIR local old=$1 local new=$2 - sed -i 's!'$old'!'$new'!g' app/index.html app/package.json app/.env + sed -i 's!'$old'!'$new'!g' app/index.html app/package.json app/app.settings.js cd $ROOT_DIR/app npm install exit 0 -- GitLab