fix: allow blocking IO for setAppLogsPath to avoid DCHECK (#23111)

* fix: let setAppLogsPath write to disk on UI thread

Otherwise, the DCHECK in thread_restrictions will fire.

* scope the io allowance more tightly

* oops, scope it tightly in the mac version too
This commit is contained in:
loc 2020-04-21 12:28:01 -07:00 committed by GitHub
parent 07654c47ec
commit cd0dda0125
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -21,7 +21,10 @@ void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
thrower.ThrowError("Path must be absolute");
return;
}
base::PathService::Override(DIR_APP_LOGS, custom_path.value());
{
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::PathService::Override(DIR_APP_LOGS, custom_path.value());
}
} else {
NSString* bundle_name =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
@ -29,8 +32,11 @@ void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
[NSString stringWithFormat:@"Library/Logs/%@", bundle_name];
NSString* library_path =
[NSHomeDirectory() stringByAppendingPathComponent:logs_path];
base::PathService::Override(DIR_APP_LOGS,
base::FilePath([library_path UTF8String]));
{
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::PathService::Override(DIR_APP_LOGS,
base::FilePath([library_path UTF8String]));
}
}
}