Move checkSomeDiskSpaceAvailable to Swift

This change should have no user impact.
This commit is contained in:
Evan Hahn 2022-07-27 11:46:24 -05:00 committed by Evan Hahn
parent 8a13595143
commit 5db672b039
2 changed files with 15 additions and 13 deletions

View File

@ -244,19 +244,6 @@ static void uncaughtExceptionHandler(NSException *exception)
return YES;
}
- (BOOL)checkSomeDiskSpaceAvailable
{
NSString *tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSUUID new].UUIDString];
BOOL succeededCreatingDir = [OWSFileSystem ensureDirectoryExists:tempDir];
// Best effort at deleting temp dir, which shouldn't ever fail
if (succeededCreatingDir && ![OWSFileSystem deleteFile:tempDir]) {
OWSFailDebug(@"Failed to delete temp dir used for checking disk space!");
}
return succeededCreatingDir;
}
- (BOOL)launchToHomeScreen:(NSDictionary *_Nullable)launchOptions instrumentsMonitorId:(unsigned long long)monitorId
{
[self setupNSEInteroperation];

View File

@ -16,6 +16,21 @@ enum LaunchFailure: UInt {
}
extension AppDelegate {
@objc(checkSomeDiskSpaceAvailable)
func checkSomeDiskSpaceAvailable() -> Bool {
let tempDir = URL(fileURLWithPath: NSTemporaryDirectory())
.appendingPathComponent(UUID().uuidString)
.path
let succeededCreatingDir = OWSFileSystem.ensureDirectoryExists(tempDir)
// Best effort at deleting temp dir, which shouldn't ever fail
if succeededCreatingDir && !OWSFileSystem.deleteFile(tempDir) {
owsFailDebug("Failed to delete temp dir used for checking disk space!")
}
return succeededCreatingDir
}
@objc(getActionSheetForLaunchFailure:fromViewController:onContinue:)
func getActionSheet(for launchFailure: LaunchFailure,
from viewController: UIViewController,