Skip to content

[BUGFIX] Fixes the crash when the folder doesn't exist - #294

Merged
treee111 merged 1 commit into
treee111:developfrom
sinancetinkaya:develop
Aug 20, 2026
Merged

[BUGFIX] Fixes the crash when the folder doesn't exist#294
treee111 merged 1 commit into
treee111:developfrom
sinancetinkaya:develop

Conversation

@sinancetinkaya

Copy link
Copy Markdown
Contributor

For some reason if the path doesn't exist, program crashes. To prevent this, the path has to be checked

@treee111
treee111 force-pushed the develop branch 2 times, most recently from 92d489b to 4cb5107 Compare August 20, 2026 13:10
@treee111

Copy link
Copy Markdown
Owner

Branch updated — SUBPROCESS_ENCODING removed, crash fix kept

Thanks for the two fixes in this PR! I've trimmed the branch so only the delete_everything_in_folder crash fix remains.

Why SUBPROCESS_ENCODING was removed

The intent — making the encoding configurable to handle Turkish (cp857) and similar non-UTF-8 Windows locales — is a good instinct, but the constant as written still hardcodes "UTF-8", so it doesn't actually fix the Turkish crash. More importantly, PR #298 (already merged) solved the root problem a different way: adding errors="backslashreplace" to both subprocess.run calls. This tells Python to escape any byte it can't decode as UTF-8 (e.g. \xNN) instead of raising a UnicodeDecodeError, so the program no longer crashes regardless of the system locale.

If a future improvement is wanted to decode the output correctly (rather than escaping bad bytes), the right approach would be to detect the system encoding at runtime:

import locale
encoding = locale.getpreferredencoding(False)  # returns e.g. "cp857" on Turkish Windows

That would be a separate PR on top of the current state.

What was kept

The delete_everything_in_folder crash fix in file_directory_functions.py is clean and still needed — os.listdir() raises FileNotFoundError if the folder doesn't exist, and no other merged PR covers this.

@treee111 treee111 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your PR @sinancetinkaya !

@treee111 treee111 changed the title Fixes the crash when the folder doesn't exist [BUGFIX] Fixes the crash when the folder doesn't exist Aug 20, 2026
@treee111
treee111 merged commit 2eccf21 into treee111:develop Aug 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants