From f3c42fa972f355bfdc59afb37874647473f8eaec Mon Sep 17 00:00:00 2001 From: charlie Date: Thu, 10 Apr 2025 17:05:36 +0800 Subject: [PATCH] fix(electron): invalid copy file for the file based graph --- src/main/frontend/handler/editor.cljs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index cc23104456..9b8b4ecc86 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -1435,16 +1435,18 @@ (string/replace #"^[.\/\\]*assets[\/\\]+" "")) dir (or (:dir matched-alias) repo-dir)] (if (util/electron?) - (let [from (not-empty (.-path file))] - (js/console.debug "Debug: Copy Asset #" dir file-rpath from) - (-> (js/window.apis.copyFileToAssets dir file-rpath from) - (p/then - (fn [dest] - [file-rpath - (if (string? dest) (js/File. #js[] dest) file) - (path/path-join dir file-rpath) - matched-alias])) - (p/catch #(js/console.error "Debug: Copy Asset Error#" %)))) + (do (js/console.debug "Debug: Copy Asset #" dir file-rpath) + (-> (if-let [from (not-empty (.-path file))] + (js/window.apis.copyFileToAssets dir file-rpath from) + (p/let [content (.arrayBuffer file)] + (fs/write-file! repo repo-dir file-rpath content {:skip-compare? true}))) + (p/then + (fn [dest] + [file-rpath + (if (string? dest) (js/File. #js[] dest) file) + (path/path-join dir file-rpath) + matched-alias])) + (p/catch #(js/console.error "Debug: Copy Asset Error#" %)))) (-> (p/do! (js/console.debug "Debug: Writing Asset #" dir file-rpath)