Fix orphaned crash reports.

The path NSCachesDirectory may change across app updates and sometimes
even across app launches. As a result, the Config-XXX files may end up
with an outdated path to the associated minidump file.

Change-Id: I0befde26b2ac406c154ce7c7e9be0063ee99892d
Bug:850379
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1592561
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
John Z Wu 2019-05-13 12:49:43 -07:00 committed by Mark Mentovai
parent b2831dbed1
commit d930308bbb

View File

@ -161,6 +161,7 @@ class Breakpad {
NSArray *CrashReportsToUpload(); NSArray *CrashReportsToUpload();
NSString *NextCrashReportToUpload(); NSString *NextCrashReportToUpload();
NSDictionary *NextCrashReportConfiguration(); NSDictionary *NextCrashReportConfiguration();
NSDictionary *FixedUpCrashReportConfiguration(NSDictionary *configuration);
NSDate *DateOfMostRecentCrashReport(); NSDate *DateOfMostRecentCrashReport();
void UploadNextReport(NSDictionary *server_parameters); void UploadNextReport(NSDictionary *server_parameters);
void UploadReportWithConfiguration(NSDictionary *configuration, void UploadReportWithConfiguration(NSDictionary *configuration,
@ -466,7 +467,18 @@ NSString *Breakpad::NextCrashReportToUpload() {
//============================================================================= //=============================================================================
NSDictionary *Breakpad::NextCrashReportConfiguration() { NSDictionary *Breakpad::NextCrashReportConfiguration() {
return [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()]; NSDictionary *configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()];
return FixedUpCrashReportConfiguration(configuration);
}
//=============================================================================
NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configuration) {
NSMutableDictionary *fixedConfiguration = [[configuration mutableCopy] autorelease];
// kReporterMinidumpDirectoryKey can become stale because the app's data container path includes
// an UUID that is not guaranteed to stay the same over time.
[fixedConfiguration setObject:KeyValue(@BREAKPAD_DUMP_DIRECTORY)
forKey:@kReporterMinidumpDirectoryKey];
return fixedConfiguration;
} }
//============================================================================= //=============================================================================