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

Make SourceBundle writer deterministic #778

Merged
merged 2 commits into from
Mar 28, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Fixes**:

- PPDB files report `has_sources() = true` even when they only contain source links ([#774](https://github.com/getsentry/symbolic/pull/774))
- Make SourceBundle writer deterministic ([#778](https://github.com/getsentry/symbolic/pull/778))

## 12.1.1

Expand Down
14 changes: 12 additions & 2 deletions symbolic-debuginfo/src/sourcebundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,16 @@ where
collect_il2cpp: bool,
}

fn default_file_options() -> FileOptions {
// TODO: should we maybe acknowledge that its the year 2023 and switch to zstd eventually?
// Though it obviously needs to be supported across the whole platform,
// which does not seem to be the case for Python?

// Depending on `zip` crate feature flags, it might default to the current time.
// Using an explicit `DateTime::default` gives us a deterministic `1980-01-01T00:00:00`.
FileOptions::default().last_modified_time(zip::DateTime::default())
}

impl<W> SourceBundleWriter<W>
where
W: Seek + Write,
Expand Down Expand Up @@ -1125,7 +1135,7 @@ where
let unique_path = self.unique_path(full_path);

self.writer
.start_file(unique_path.clone(), FileOptions::default())
.start_file(unique_path.clone(), default_file_options())
.map_err(|e| SourceBundleError::new(SourceBundleErrorKind::WriteFailed, e))?;
std::io::copy(&mut file, &mut self.writer)
.map_err(|e| SourceBundleError::new(SourceBundleErrorKind::WriteFailed, e))?;
Expand Down Expand Up @@ -1285,7 +1295,7 @@ where
/// Flushes the manifest file to the bundle.
fn write_manifest(&mut self) -> Result<(), SourceBundleError> {
self.writer
.start_file(MANIFEST_PATH, FileOptions::default())
.start_file(MANIFEST_PATH, default_file_options())
.map_err(|e| SourceBundleError::new(SourceBundleErrorKind::WriteFailed, e))?;

serde_json::to_writer(&mut self.writer, &self.manifest)
Expand Down