Skip to content

Commit

Permalink
fix: Crash with screenshot is reported twice (#2134)
Browse files Browse the repository at this point in the history
Fix a bug where crashes with screenshots were reported twice.
  • Loading branch information
brustolin committed Sep 9, 2022
1 parent 28016b4 commit 45ed684
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Fixes

- Can't find app image when swizzling (#2124)
- Crash with screenshot is reported twice (#2134)

## 7.24.1

Expand Down
2 changes: 1 addition & 1 deletion Sources/SentryCrash/Recording/SentryCrashReportStore.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ getReportCount()
}
struct dirent *ent;
while ((ent = readdir(dir)) != NULL) {
if (getReportIDFromFilename(ent->d_name) > 0) {
if (ent->d_type != DT_DIR && getReportIDFromFilename(ent->d_name) > 0) {
count++;
}
}
Expand Down
20 changes: 20 additions & 0 deletions Tests/SentryTests/SentryCrash/SentryCrashReportStore_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ - (void)testCrashReportCount1
[self expectHasReportCount:1];
}

- (void)testCrashReportCount1_WithAttachments
{
[self prepareReportStoreWithPathEnd:@"testCrashReportCount1"];
NSString *reportContents = @"Testing";

char crashReportPath[SentryCrashCRS_MAX_PATH_LENGTH];
sentrycrashcrs_getNextCrashReportPath(crashReportPath);
NSString *pathToCrashReport = [NSString stringWithUTF8String:crashReportPath];
NSError *someError;
[NSFileManager.defaultManager
createDirectoryAtPath:[pathToCrashReport stringByDeletingPathExtension]
withIntermediateDirectories:true
attributes:nil
error:&someError];
XCTAssertNil(someError);

[self writeCrashReportWithStringContents:reportContents];
[self expectHasReportCount:1];
}

- (void)testStoresLoadsOneCrashReport
{
[self prepareReportStoreWithPathEnd:@"testStoresLoadsOneCrashReport"];
Expand Down

0 comments on commit 45ed684

Please sign in to comment.