From 0eef9bf2f3405be1a10c3ba44690b297734d3e56 Mon Sep 17 00:00:00 2001 From: kamaji Date: Sat, 7 Feb 2026 15:27:26 -0600 Subject: [PATCH] Fix gallery rename applying to wrong files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After renaming a file, loadDirectory() was called which rebuilt the galleryImages array in new alphabetical order. The gallery index didn't change, so it now pointed to a different file — subsequent renames hit the wrong file. Fix: only update local state during the gallery session, defer the file list refresh to when the gallery closes. Co-Authored-By: Claude Opus 4.6 --- app/static/js/filebrowser.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/static/js/filebrowser.js b/app/static/js/filebrowser.js index 9559c32..1bffa18 100644 --- a/app/static/js/filebrowser.js +++ b/app/static/js/filebrowser.js @@ -291,6 +291,9 @@ const FileBrowser = { const img = document.getElementById('gallery-image'); if (img.src && img.src.startsWith('blob:')) URL.revokeObjectURL(img.src); img.src = ''; + + // Refresh file list to reflect any renames + this.loadDirectory(this.currentPath); }, async displayGalleryImage(index) { @@ -474,9 +477,6 @@ const FileBrowser = { this.closeRenameModal(); this.showGalleryToast('File renamed', 'success'); - - // Refresh the file list in the background - this.loadDirectory(this.currentPath); } catch (error) { console.error('Error renaming file:', error); errorEl.textContent = error.message;