diff --git a/.gitignore b/.gitignore index 39277b44..d43bf99e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Don't include any debug bundle generated during a run of Broker or FOSSA CLI. +fossa.broker.debug.tar.gz +fossa.debug.json.gz + # Node isn't used for this actual project, but we have a node test fixture # to make tests run faster. node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index b230e2a4..91abb5f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ +## v0.2.2 + +Bug fix: + +- Broker now copies its debug bundle (generated during `broker fix`) from the system temp location instead of renaming. + This resolves issues preventing debug bundles from being stored for Linux installations where the temporary location + and the home folder are on separate mount points. + ## v0.2.1 Features: diff --git a/Cargo.lock b/Cargo.lock index 31d61d56..2dbf112c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "broker" -version = "0.2.1" +version = "0.2.2" dependencies = [ "aho-corasick 0.7.20", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 7cf4ff14..314b5dc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "broker" -version = "0.2.1" +version = "0.2.2" edition = "2021" description = "The bridge between FOSSA and internal DevOps services" readme = "README.md" diff --git a/src/debug/bundler.rs b/src/debug/bundler.rs index 9b5004ef..ea64bc95 100644 --- a/src/debug/bundler.rs +++ b/src/debug/bundler.rs @@ -1,6 +1,6 @@ //! Trait and implementations used by `bundle` to create debug bundles. -use std::path::Path; +use std::{fs, path::Path}; use error_stack::Result; use libflate::gzip; @@ -50,6 +50,7 @@ impl TarGz { /// /// This bundles the provided debug artifacts using a backing temp file, /// which is moved to a final location with the `finalize` method. + #[tracing::instrument] pub fn new() -> Result { let file = NamedTempFile::new().context(Error::CreateTempFile)?; let encoder = gzip::Encoder::new(file).context(Error::CreateBundler)?; @@ -62,6 +63,7 @@ impl TarGz { impl Bundler for TarGz { type Error = std::io::Error; + #[tracing::instrument(skip_all, fields(path = %path.as_ref().display(), name = %name.as_ref().display()))] fn add_file(&mut self, path: P, name: N) -> std::result::Result<(), Self::Error> where P: AsRef, @@ -70,11 +72,17 @@ impl Bundler for TarGz { self.inner.append_path_with_name(path, name) } + #[tracing::instrument(skip_all, fields(destination = %destination.as_ref().display()))] fn finalize>(self, destination: P) -> std::result::Result { let zip = self.inner.into_inner()?; let handle = zip.finish().into_result()?; handle.as_file().sync_all()?; - handle.persist(&destination)?; + + // `handle.persist` fails if asked to persist across mounts, since internally it uses a rename. + // Instead, just copy the file from temp. + let path = handle.into_temp_path(); + fs::copy(&path, destination.as_ref())?; + Ok(Bundle { location: destination.as_ref().to_path_buf(), })