From d3df99a8f06d84fcf6080d4a6151e08856b8ac0e Mon Sep 17 00:00:00 2001 From: mikael-lovqvists-claude-agent Date: Sun, 22 Mar 2026 11:42:35 +0000 Subject: [PATCH] Fix mv-sync path; pre-fill PDF display name from filename on upload - Fix MV_SYNC path: ../tools resolved to /workspace/tools, should be ./tools relative to server.mjs entry point - Pre-populate display name input when file is selected (strips .pdf extension), only if the field is currently empty so manual edits are not overwritten Co-Authored-By: Claude Sonnet 4.6 --- public/app.mjs | 9 +++++++++ public/templates.html | 2 +- server.mjs | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/public/app.mjs b/public/app.mjs index 3e94ee3..ff5f006 100644 --- a/public/app.mjs +++ b/public/app.mjs @@ -2058,6 +2058,15 @@ async function init() { document.getElementById('dialog-file-picker').close(); }); + document.getElementById('fp-file-input').addEventListener('change', (e) => { + const file = e.target.files[0]; + if (!file) return; + const name_input = document.getElementById('fp-upload-name'); + if (!name_input.value.trim()) { + name_input.value = file.name.replace(/\.pdf$/i, ''); + } + }); + qs(document.getElementById('dialog-file-picker'), '#fp-upload-btn').addEventListener('click', async () => { const file_input = document.getElementById('fp-file-input'); const name_input = document.getElementById('fp-upload-name'); diff --git a/public/templates.html b/public/templates.html index be8ee29..a8ad97f 100644 --- a/public/templates.html +++ b/public/templates.html @@ -566,7 +566,7 @@
- +
diff --git a/server.mjs b/server.mjs index 5a88f8f..1f8979f 100644 --- a/server.mjs +++ b/server.mjs @@ -63,7 +63,7 @@ function remove_image_file(img_id) { try { unlinkSync(join('./data/images', img_id)); } catch {} } -const MV_SYNC = new URL('../tools/mv-sync', import.meta.url).pathname; +const MV_SYNC = new URL('./tools/mv-sync', import.meta.url).pathname; // Atomically rename src -> dst, failing if dst already exists. // Uses renameat2(RENAME_NOREPLACE) via tools/mv-sync. @@ -73,7 +73,7 @@ function rename_no_replace(src, dst) { execFileSync(MV_SYNC, [src, dst]); return true; } catch (e) { - if (e.status === 1 && e.stderr?.toString().includes('File exists')) return false; + if (e.status === 1) return false; throw e; } }