Follow-up to #889 (merged), from my review there.
#889 drops the #886 lookup memories on !rehash. But the dashboard's Folders and Lists pages change the library without a rehash: apply_folder_changes() / apply_list_changes() (webserver.py) call library.save_folders() / save_lists() and return, and library.folders() -> lists() -> load_lists() reads the file on every call, so the new roots are live on the next request. A path remembered under the removed folder is still on disk, passes the memory's own existence check, and is then refused by is_safe_path() against the new roots: Error: Invalid path. for a file the new configuration serves, until LOOKUP_HIT_TTL_SECONDS (5 min) passes. Reproduced through the real request path by changing library.folders the way the page's save does.
Fix: check a remembered path against the current roots where it is used - the same is_safe_path() check the request makes afterwards - and fall back to the folder memory and then the scan when it is outside them. That covers the dashboard, a hand-edited lists.json, and a scan still in flight across a rehash that records its hit after the forget. #889's rehash call stays (it also frees the memory). test_a_path_from_a_root_that_is_gone_is_refused_rather_than_served asserts the bug itself, so it flips to "served, even without a forget".
Follow-up to #889 (merged), from my review there.
#889 drops the #886 lookup memories on
!rehash. But the dashboard's Folders and Lists pages change the library without a rehash:apply_folder_changes()/apply_list_changes()(webserver.py) calllibrary.save_folders()/save_lists()and return, andlibrary.folders()->lists()->load_lists()reads the file on every call, so the new roots are live on the next request. A path remembered under the removed folder is still on disk, passes the memory's own existence check, and is then refused byis_safe_path()against the new roots:Error: Invalid path.for a file the new configuration serves, untilLOOKUP_HIT_TTL_SECONDS(5 min) passes. Reproduced through the real request path by changinglibrary.foldersthe way the page's save does.Fix: check a remembered path against the current roots where it is used - the same
is_safe_path()check the request makes afterwards - and fall back to the folder memory and then the scan when it is outside them. That covers the dashboard, a hand-editedlists.json, and a scan still in flight across a rehash that records its hit after the forget. #889's rehash call stays (it also frees the memory).test_a_path_from_a_root_that_is_gone_is_refused_rather_than_servedasserts the bug itself, so it flips to "served, even without a forget".