Skip to content

Commit

Permalink
fix: linux crashpad handler path
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Nov 22, 2024
1 parent 25fc225 commit 5c70b02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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:ffi';
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 @@ class SentryNative with SentryNativeSafeInvoker implements SentryNativeBinding {
static String dynamicLibraryDirectory = '';

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

SentryNative(this.options);

Expand Down Expand Up @@ -396,3 +397,19 @@ extension on List<dynamic> {
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

0 comments on commit 5c70b02

Please sign in to comment.