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: linux crashpad handler path #2443

Merged
merged 2 commits into from
Nov 25, 2024
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
19 changes: 18 additions & 1 deletion flutter/lib/src/native/c/sentry_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'dart:io';
import 'dart:typed_data';

import 'package:collection/collection.dart';
import 'package:ffi/ffi.dart';
import 'package:meta/meta.dart';

Expand Down Expand Up @@ -31,7 +32,7 @@
static String dynamicLibraryDirectory = '';

@visibleForTesting
static String? crashpadPath;
static String? crashpadPath = _getDefaultCrashpadPath();

SentryNative(this.options);

Expand Down Expand Up @@ -396,3 +397,19 @@
return cObject;
}
}

String? _getDefaultCrashpadPath() {
if (Platform.isLinux) {

Check warning on line 402 in flutter/lib/src/native/c/sentry_native.dart

View check run for this annotation

Codecov / codecov/patch

flutter/lib/src/native/c/sentry_native.dart#L401-L402

Added lines #L401 - L402 were not covered by tests
final lastSeparator =
Platform.resolvedExecutable.lastIndexOf(Platform.pathSeparator);
if (lastSeparator >= 0) {
final appDir = Platform.resolvedExecutable.substring(0, lastSeparator);
final candidates = [
'$appDir${Platform.pathSeparator}crashpad_handler',
'$appDir${Platform.pathSeparator}bin/crashpad_handler'
];
return candidates.firstWhereOrNull((path) => File(path).existsSync());

Check warning on line 411 in flutter/lib/src/native/c/sentry_native.dart

View check run for this annotation

Codecov / codecov/patch

flutter/lib/src/native/c/sentry_native.dart#L404-L411

Added lines #L404 - L411 were not covered by tests
}
}
return null;
}
2 changes: 1 addition & 1 deletion flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies:
meta: ^1.3.0
ffi: ^2.0.0
file: '>=6.1.4'
collection: ^1.16.0

dev_dependencies:
build_runner: ^2.4.2
Expand All @@ -36,7 +37,6 @@ dev_dependencies:
mockito: ^5.1.0
yaml: ^3.1.0 # needed for version match (code and pubspec)
flutter_lints: '>=4.0.0'
collection: ^1.16.0
remove_from_coverage: ^2.0.0
flutter_localizations:
sdk: flutter
Expand Down
Loading