mattcasters commented on issue #7797:
URL: https://github.com/apache/hop/issues/7797#issuecomment-5202319314

   ## Root cause analysis
   
   Hard to reproduce because several conditions must line up: selection 
elsewhere, folders already expanded once, and (sometimes) a stale VFS directory 
listing.
   
   ### 1. Scoped F5 only refreshed the last selected folder (primary)
   
   After [#7426](https://github.com/apache/hop/pull/7426) / 
[#7364](https://github.com/apache/hop/issues/7364), toolbar refresh / F5 
preferred **scoped refresh** of `lastSelectedFolderPath` whenever anything had 
been selected in the tree (folder, or parent of a selected file).
   
   So if you were looking at `pipelines/` while a pipeline wrote under 
`output/`, F5 only re-listed `pipelines/`. New folders/files elsewhere never 
entered the SWT tree.
   
   ```text
   refresh()
     → treeModel.clear()
     → if lastSelectedFolderPath set → refreshSelectedFolder()  // only one 
folder
     → else refreshEntireTree()
   ```
   
   That matches “even the refresh button doesn’t bring them to light.”
   
   ### 2. Lazy `loaded` flag never re-scanned already-loaded folders
   
   Once a folder had been expanded, `TreeItemFolder.loaded = true` and 
`ensureFolderLoaded()` returned without calling VFS again:
   
   ```text
   if (tif.loaded && !hasOnlyLazyDummyChild(item)) {
     return; // never re-lists from disk
   }
   ```
   
   Typical intermittent scenario:
   
   1. Expand folder `A` once → children snapshotted in the tree.
   2. Pipeline creates `A/new-folder/` or new files under `A`.
   3. Selection is elsewhere → F5 only refreshes the selected folder.
   4. Looking at `A` again (or collapse/expand) does **not** re-read the 
filesystem.
   
   Empty folders that were already loaded with zero children are worse: no 
expand icon, nothing ever reloads until that path is scoped-refreshed or the 
whole tree is rebuilt.
   
   ### 3. Commons VFS children cache (contributing)
   
   Hop uses `SoftRefFilesCache` + `CacheStrategy.ON_RESOLVE`. 
`AbstractFileObject.getChildren()` caches child names until 
`FileObject.refresh()`. External writes (pipelines, other processes) that do 
not go through the same `FileObject` graph leave listings dependent on that 
cache/refresh path. Explorer never called `refresh()` before listing.
   
   ### 4. Filter index (`ExplorerTreeModel`) — secondary
   
   The in-memory filter model (#7783) is cleared on `refresh()`; while 
filtering, F5 re-indexes. Secondary to the UI tree issue above, but the fix 
also forces fresh VFS lists when building that model.
   
   ### Fix (PR)
   
   - Toolbar F5 = **hard refresh** of the entire tree (filter index cleared; 
expand state restored via `TreeMemory`).
   - `listChildrenFresh()`: `HopVfs.getFileObject` + `FileObject.refresh()` + 
`getChildren()` for tree and filter walks.
   - Context menu **Refresh folder** keeps cheap scoped refresh for intentional 
single-folder updates.
   - Path equality helper for mixed `\`/`/` (Windows).
   
   PR: will link shortly after open.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to