From 577b731b22607a062ce2344f5f5193455625aacb Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 25 Nov 2024 12:29:59 +0100 Subject: [PATCH 1/2] :bug: Fix import format detection and error handling --- frontend/src/app/main/ui/dashboard/import.scss | 3 +++ frontend/src/app/worker/import.cljs | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/ui/dashboard/import.scss b/frontend/src/app/main/ui/dashboard/import.scss index fbcad58fe..257134dc4 100644 --- a/frontend/src/app/main/ui/dashboard/import.scss +++ b/frontend/src/app/main/ui/dashboard/import.scss @@ -64,6 +64,7 @@ } .file-entry { + display: flex; .file-name { @include flexRow; .file-icon { @@ -114,6 +115,8 @@ } .error-message, .progress-message { + display: flex; + align-items: center; height: $s-32; color: var(--modal-text-foreground-color); } diff --git a/frontend/src/app/worker/import.cljs b/frontend/src/app/worker/import.cljs index 0083a6475..ebeb67daa 100644 --- a/frontend/src/app/worker/import.cljs +++ b/frontend/src/app/worker/import.cljs @@ -799,7 +799,8 @@ (rx/merge-map (fn [body] (let [mtype (parse-mtype body)] - (if (= "application/zip" mtype) + (cond + (= "application/zip" mtype) (->> (uz/load body) (rx/merge-map read-zip-manifest) (rx/map @@ -808,7 +809,13 @@ (let [manifest (decode-manifest manifest)] (assoc file :type :binfile-v3 :files (:files manifest))) (assoc file :type :legacy-zip :body body))))) - (rx/of (assoc file :type :binfile-v1)))))) + + (= "application/octet-stream" mtype) + (rx/of (assoc file :type :binfile-v1)) + + :else + (rx/of (assoc file :type :unknown)))))) + (rx/share))] (->> (rx/merge @@ -837,9 +844,10 @@ (assoc :status :success)))))))) (->> stream - (rx/filter (fn [data] (= "other" (:type data)))) + (rx/filter (fn [data] (= :unknown (:type data)))) (rx/map (fn [_] {:uri (:uri file) + :status :error :error (tr "dashboard.import.analyze-error")})))) (rx/catch (fn [cause] From e1c9691567e0de1d26faa9f9c93fb724947b1c8e Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 25 Nov 2024 12:44:10 +0100 Subject: [PATCH 2/2] :sparkles: Improve scss compilation error handling Don't stop watch scss process on compilation error --- frontend/scripts/_helpers.js | 1 + frontend/scripts/watch.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/scripts/_helpers.js b/frontend/scripts/_helpers.js index c7671a361..12ab0552c 100644 --- a/frontend/scripts/_helpers.js +++ b/frontend/scripts/_helpers.js @@ -508,6 +508,7 @@ export async function compileStyles() { const start = process.hrtime(); log.info("init: compile styles"); + let result = await compileSassAll(worker); result = concatSass(result); diff --git a/frontend/scripts/watch.js b/frontend/scripts/watch.js index 99ced7b70..0e1d68f43 100644 --- a/frontend/scripts/watch.js +++ b/frontend/scripts/watch.js @@ -24,15 +24,22 @@ async function compileSassAll() { async function compileSass(path) { const start = process.hrtime(); log.info("changed:", path); - const result = await h.compileSass(worker, path, { modules: true }); - sass.index[result.outputPath] = result.css; - const output = h.concatSass(sass); + try { + const result = await h.compileSass(worker, path, { modules: true }); + sass.index[result.outputPath] = result.css; - await fs.writeFile("./resources/public/css/main.css", output); + const output = h.concatSass(sass); - const end = process.hrtime(start); - log.info("done:", `(${ppt(end)})`); + await fs.writeFile("./resources/public/css/main.css", output); + + const end = process.hrtime(start); + log.info("done:", `(${ppt(end)})`); + } catch (cause) { + console.error(cause); + const end = process.hrtime(start); + log.error("error:", `(${ppt(end)})`); + } } await fs.mkdir("./resources/public/css/", { recursive: true });