Skip to content

Commit

Permalink
fix(ingestion): use lossy conversion when source doesn't produce vali…
Browse files Browse the repository at this point in the history
…d utf8 (#240)

Fixes #233
  • Loading branch information
alexpasmantier authored Jan 7, 2025
1 parent 0624002 commit a2a264c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
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

0 comments on commit a2a264c

Please sign in to comment.