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

fix(ingestion): use lossy conversion when source doesn't produce valid utf8 #240

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/television-channels/src/channels/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn get_raw_aliases(shell: &str) -> Vec<String> {
.arg("alias")
.output()
.expect("failed to execute process");
let aliases = String::from_utf8(output.stdout).unwrap();
let aliases = String::from_utf8_lossy(&output.stdout);
aliases.lines().map(ToString::to_string).collect()
}

Expand Down
2 changes: 1 addition & 1 deletion crates/television-channels/src/channels/cable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn load_candidates(command: String, injector: Injector<String>) {
.output()
.expect("failed to execute process");

let decoded_output = String::from_utf8(output.stdout).unwrap();
let decoded_output = String::from_utf8_lossy(&output.stdout);
debug!("Decoded output: {:?}", decoded_output);

for line in decoded_output.lines().collect::<HashSet<_>>() {
Expand Down
10 changes: 4 additions & 6 deletions crates/television-previewers/src/previewers/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,10 @@ pub fn try_preview(
.expect("failed to execute process");

if output.status.success() {
let content = String::from_utf8(output.stdout)
.unwrap_or(String::from("Failed to read output\n"));
let content = String::from_utf8_lossy(&output.stdout);
let preview = Arc::new(Preview::new(
entry.name.clone(),
PreviewContent::AnsiText(content),
PreviewContent::AnsiText(content.to_string()),
None,
false,
));
Expand All @@ -173,11 +172,10 @@ pub fn try_preview(
let mut tp = last_previewed.lock();
*tp = preview.stale().into();
} else {
let content = String::from_utf8(output.stderr)
.unwrap_or(String::from("Failed to read error\n"));
let content = String::from_utf8_lossy(&output.stderr);
let preview = Arc::new(Preview::new(
entry.name.clone(),
PreviewContent::AnsiText(content),
PreviewContent::AnsiText(content.to_string()),
None,
false,
));
Expand Down
Loading