fix: handle filesystem errors during lora and upscaler cache scan (#1920) - #2064
Merged
leejet merged 3 commits intoSep 27, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1920.
Problem
In
refresh_lora_cacheandrefresh_upscaler_cache(examples/server/runtime.cpp), directory traversal checked entries using unguardedentry.is_regular_file(),entry.file_size(), and unhandled directory iteration.When the directory contains restricted entries, broken symlinks, special mounts (e.g.
/proc/1/map_filesinside Docker containers or systemd overlays),entry.is_regular_file()throws an uncaughtstd::filesystem::filesystem_error(Operation not permitted/Permission denied).This escaped to the HTTP server handler, causing
/sdcpp/v1/capabilitiesand/sdcpp/v1/img_gento fail with500 Internal Server Errorand breaking the WebUI.Additionally, the runtime stage of the Dockerfiles did not set
WORKDIR, defaulting to/where--lora-model-dir .scanned the entire Linux root filesystem.Fix
examples/server/runtime.cpp:std::error_codeoverloads foris_regular_file,file_size,last_write_time, andabsolute.fs::directory_options::skip_permission_deniedfor upscalers directory iteration as well.try ... catch (const std::exception& e)with warning logs so an inaccessible entry or directory never crashes the request handler or returns a 500.docker/Dockerfile*:WORKDIR /sd.cppin the runtime stage of all Dockerfiles so the working directory defaults to/sd.cpprather than container root/.Fixes #1920