Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash or hangs if filenames contain non-UTF8 characters #6

Open
lparcq opened this issue Apr 16, 2023 · 2 comments
Open

Crash or hangs if filenames contain non-UTF8 characters #6

lparcq opened this issue Apr 16, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@lparcq
Copy link

lparcq commented Apr 16, 2023

When a file name contains non-UTF8 characters in a UTF8 locale (ex: latin1), the command crashes or hangs. I haven't found the conditions that makes it either crash or hang.

When it crashes, the error is:
thread '<unnamed>' panicked at 'called Option::unwrap()on aNone value', /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/diskscan-0.3.0/src/scanner.rs:295:67

@funbiscuit
Copy link
Owner

Thanks for the report.
Condition is exactly at scanner.rs:295 - calling unwrap on Option<&str> which is None. Since filename was not utf8 so to_str() returned None
In this app I everywhere assume that all file paths are well formed utf8 strings which obviously not always the case, but it was good enough assumption at the start (and in my cases that was always correct).
Some refactor needs to be done to switch from String to OsString/PathBuf that will fix the problem.

@funbiscuit funbiscuit added the bug Something isn't working label Apr 16, 2023
@lparcq
Copy link
Author

lparcq commented Apr 23, 2023

Thanks. Maybe just writing an error instead of panicking would be enough and much easier to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants