mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 07:32:54 +00:00
When reopening the SFTP modal via drag-and-drop, the session effect's initialization IIFE runs async (ensureSftp + listSftp ~0.5s). During this window, dependency changes (e.g. loadFiles recreation from files.length change by the layout effect clearing stale cache) can re-trigger the session effect. Since initializedRef is already true, the effect falls through to loadFiles(currentPath) with the OLD path. If this loadFiles resolves before the IIFE, loading transitions to false prematurely, causing the auto-upload to snapshot the stale currentPathRef and upload to the wrong directory. Add an initializingRef flag that is set when the initialization IIFE starts and cleared in its finally block. The fallthrough loadFiles call is skipped while initializingRef is true, ensuring only the IIFE's completion triggers the loading transition that the auto-upload effect relies on. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>