Skip to content

Commit

Permalink
feat: Log when file not added to source bundle (#2146)
Browse files Browse the repository at this point in the history
When a file has an invalid (non-UTF-8) encoding, it is skipped from being added to source bundles. Previously, the file was silently skipped. Now, we log when we skip a file.

The logs are emitted at the info level, which is hidden by default (default log level is warn). To see these logs, users will need to set the log level, for example by passing --log-level=info.

Fixes #2135
Fixes #2147
  • Loading branch information
szokeasaurusrex authored Sep 9, 2024
1 parent a069c2f commit 9d4548f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
sha1_smol = { version = "1.0.0", features = ["serde"] }
sourcemap = { version = "7.0.1", features = ["ram_bundle"] }
symbolic = { version = "12.10.1", features = ["debuginfo-serde", "il2cpp"] }
symbolic = { version = "12.11.0", features = ["debuginfo-serde", "il2cpp"] }
thiserror = "1.0.38"
url = "2.3.1"
username = "0.2.0"
Expand Down
14 changes: 8 additions & 6 deletions src/commands/debug_files/bundle_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};

use anyhow::Result;
use clap::{Arg, ArgAction, ArgMatches, Command};
use log::warn;
use log::{info, warn};
use symbolic::debuginfo::sourcebundle::SourceBundleWriter;

use crate::utils::dif::DifFile;
Expand Down Expand Up @@ -100,11 +100,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
// Resolve source files from the object and write their contents into the archive. Skip to
// upload this bundle if no source could be written. This can happen if there is no file or
// line information in the object file, or if none of the files could be resolved.
let written = writer.write_object_with_filter(
&object,
&filename.to_string_lossy(),
filter_bad_sources,
)?;
let written = writer
.with_skipped_file_callback(|skipped_info| info!("{skipped_info}"))
.write_object_with_filter(
&object,
&filename.to_string_lossy(),
filter_bad_sources,
)?;

if !written {
eprintln!("skipped {orig_path} (no files found)");
Expand Down
5 changes: 3 additions & 2 deletions src/utils/dif_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,9 @@ fn create_source_bundles<'a>(
// Resolve source files from the object and write their contents into the archive. Skip to
// upload this bundle if no source could be written. This can happen if there is no file or
// line information in the object file, or if none of the files could be resolved.
let written =
writer.write_object_with_filter(object, dif.file_name(), filter_bad_sources)?;
let written = writer
.with_skipped_file_callback(|skipped_info| info!("{skipped_info}"))
.write_object_with_filter(object, dif.file_name(), filter_bad_sources)?;
if !written {
debug!("No sources found for {}", name);
continue;
Expand Down

0 comments on commit 9d4548f

Please sign in to comment.