legendary icon indicating copy to clipboard operation
legendary copied to clipboard

Fix: Handle non-existent paths in case_insensitive_file_search

Open DealsBeam opened this issue 1 month ago • 1 comments

The case_insensitive_file_search function in legendary/lfs/wine_helpers.py did not correctly handle cases where the parent directory of the provided path does not exist. This could lead to the function returning an invalid path, which could cause errors in other parts of the application.

This commit fixes the issue by adding a check to ensure the parent directory exists before proceeding with the file search. If the parent directory does not exist, the function will now return None.

A new test case has been added to verify this fix.

DealsBeam avatar Nov 01 '25 12:11 DealsBeam

The function handles non-existent paths fine. Specifically, this will cause the function to short-circuit & just return the rest of the path as-is.

Returning None from a function annotated with -> str is incorrect. Any linter will warn you about this (AI may not)

I assume you've opened this PR because you're experiencing an issue. Please detail that issue (in an actual GH Issue), we can then look into the proper fix for it

CommandMC avatar Nov 01 '25 13:11 CommandMC