Do not crash if there is no disk, just return nil instance
Summary: This should not affect prod as flipper (also called sonar) should only be an internal debug product but i needed to fix it to start the app. Reviewed By: jknoxville Differential Revision: D10156590 fbshipit-source-id: 84a76e5cbe2f4bbe89627895efcfb7e6cdadae13
This commit is contained in:
committed by
Facebook Github Bot
parent
44fea6b9bc
commit
145b94b47d
@@ -36,7 +36,12 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
static FlipperClient *sharedClient = nil;
|
static FlipperClient *sharedClient = nil;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
sharedClient = [[self alloc] init];
|
try {
|
||||||
|
sharedClient = [[self alloc] init];
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
// fail.
|
||||||
|
sharedClient = nil;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return sharedClient;
|
return sharedClient;
|
||||||
}
|
}
|
||||||
@@ -52,9 +57,9 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
|
|
||||||
NSFileManager *manager = [NSFileManager defaultManager];
|
NSFileManager *manager = [NSFileManager defaultManager];
|
||||||
|
|
||||||
if ([manager fileExistsAtPath:privateAppDirectory isDirectory:NULL] == NO) {
|
if ([manager fileExistsAtPath:privateAppDirectory isDirectory:NULL] == NO &&
|
||||||
//TODO: Handle errors properly
|
![manager createDirectoryAtPath:privateAppDirectory withIntermediateDirectories:YES attributes:nil error:nil]) {
|
||||||
[manager createDirectoryAtPath:privateAppDirectory withIntermediateDirectories:YES attributes:nil error:nil];
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_OS_SIMULATOR
|
#if TARGET_OS_SIMULATOR
|
||||||
@@ -62,20 +67,25 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const std::string UNKNOWN = std::string("unknown");
|
static const std::string UNKNOWN = std::string("unknown");
|
||||||
facebook::flipper::FlipperClient::init({
|
try {
|
||||||
{
|
facebook::flipper::FlipperClient::init({
|
||||||
"localhost",
|
{
|
||||||
"iOS",
|
"localhost",
|
||||||
[deviceName UTF8String],
|
"iOS",
|
||||||
UNKNOWN,
|
[deviceName UTF8String],
|
||||||
[appName UTF8String] ?: UNKNOWN,
|
UNKNOWN,
|
||||||
[appId UTF8String] ?: UNKNOWN,
|
[appName UTF8String] ?: UNKNOWN,
|
||||||
[privateAppDirectory UTF8String],
|
[appId UTF8String] ?: UNKNOWN,
|
||||||
},
|
[privateAppDirectory UTF8String],
|
||||||
sonarThread.getEventBase(),
|
},
|
||||||
connectionThread.getEventBase()
|
sonarThread.getEventBase(),
|
||||||
});
|
connectionThread.getEventBase()
|
||||||
_cppClient = facebook::flipper::FlipperClient::instance();
|
});
|
||||||
|
_cppClient = facebook::flipper::FlipperClient::instance();
|
||||||
|
} catch (const std::system_error &e) {
|
||||||
|
// Probably ran out of disk space.
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user