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

fix: Prevent daemonize mode from crashing upload process #1104

Merged
merged 2 commits into from
Jan 21, 2022
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ predicates = "2.0.0"
tempfile = "3.1.0"

[features]
default = ["with_crash_reporting"]
default = []
managed = []
with_crash_reporting = []

Expand Down
3 changes: 1 addition & 2 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ fn setup() {
}
#[cfg(not(feature = "with_crash_reporting"))]
{
static LOGGER: Logger = Logger;
log::set_logger(&Logger);
log::set_logger(&Logger).unwrap();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/commands/react_native_xcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ fn find_node() -> String {
pub fn execute(matches: &ArgMatches<'_>) -> Result<(), Error> {
let config = Config::current();
let (org, project) = config.get_org_and_project(matches)?;
let api = Api::current();
let should_wrap = matches.is_present("force")
|| match env::var("CONFIGURATION") {
Ok(config) => !&config.contains("Debug"),
Expand Down Expand Up @@ -183,6 +182,7 @@ pub fn execute(matches: &ArgMatches<'_>) -> Result<(), Error> {
if !matches.is_present("force_foreground") {
md.may_detach()?;
}
let api = Api::current();
let url = url.trim_end_matches('/');
bundle_file = TempFile::create()?;
bundle_path = bundle_file.path().to_path_buf();
Expand Down Expand Up @@ -282,6 +282,7 @@ pub fn execute(matches: &ArgMatches<'_>) -> Result<(), Error> {
dist
));

let api = Api::current();
let release = api.new_release(
&org,
&NewRelease {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/upload_dif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ pub fn make_app<'a, 'b: 'a>(app: App<'a, 'b>) -> App<'a, 'b> {
}

fn execute_internal(matches: &ArgMatches<'_>, legacy: bool) -> Result<(), Error> {
let api = Api::current();
let config = Config::current();
let (org, project) = config.get_org_and_project(matches)?;

Expand Down Expand Up @@ -298,6 +297,7 @@ fn execute_internal(matches: &ArgMatches<'_>, legacy: bool) -> Result<(), Error>

// Execute the upload
let (uploaded, has_processing_errors) = upload.upload()?;
let api = Api::current();

// Associate the dSYMs with the Info.plist data, if available
if let Some(ref info_plist) = info_plist {
Expand Down
8 changes: 8 additions & 0 deletions src/utils/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ use lazy_static::lazy_static;
use regex::{Captures, Regex};

use crate::config::Config;
#[cfg(not(windows))]
use crate::utils::xcode::launched_from_xcode;

#[cfg(not(windows))]
pub fn run_or_interrupt<F>(f: F)
where
F: FnOnce() + Send + 'static,
{
// See: https://github.com/getsentry/sentry-cli/pull/1104
if launched_from_xcode() {
f();
return;
}

let (tx, rx) = crossbeam_channel::bounded(100);
let mut signals = signal_hook::iterator::Signals::new(&[
signal_hook::consts::SIGTERM,
Expand Down
6 changes: 6 additions & 0 deletions src/utils/xcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ pub fn launched_from_xcode() -> bool {
false
}

/// Returns true if we were invoked from xcode
#[cfg(not(target_os = "macos"))]
pub fn launched_from_xcode() -> bool {
false
}

/// Shows a dialog in xcode and blocks. The dialog will have a title and a
/// message as well as the buttons "Show details" and "Ignore". Returns
/// `true` if the `show details` button has been pressed.
Expand Down