Skip to content

Conversation

@loewenheim
Copy link
Contributor

Prompted by #2107 and #2108.

This matches on the error kind returned by SourceBundleWriter::add_file and silently skips ReadFailed errors, which happen on files that aren't valid UTF8. Errors like this are likely caused by asset files that weren't intended to be included in the bundle anyway. It might also make sense to log that we're skipping the file, though.

@loewenheim loewenheim requested review from Swatinem and szokeasaurusrex and removed request for szokeasaurusrex July 23, 2024 09:33
if let Err(e) = bundle.add_file(bundle_path, file.contents.as_slice(), info) {
if e.kind() == SourceBundleErrorKind::ReadFailed {
// This is a non-UTF8 file; it might be an asset which is not intended for inclusion in the
// sourcebundle. We silently skip it.
Copy link
Member

Choose a reason for hiding this comment

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

Let's add an info log to inform users that we are skipping the file

Copy link
Member

Choose a reason for hiding this comment

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

Ideally with the file path, something like:

skipping file path/to/file because it is not UTF-8 encoded

@loewenheim loewenheim changed the title fix(sourcebundle): Silently skip non-UTF8 files fix(sourcebundle): Skip non-UTF8 files Jul 23, 2024
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Looks good!

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.

4 participants