Skip to content

Commit

Permalink
Attempt to fix crashing bug in temporaryExtractPathWithQueue (#10)
Browse files Browse the repository at this point in the history
Co-authored-by: Mat Gadd <[email protected]>
  • Loading branch information
mat-gadd-bmbl and mat-gadd-bmbl authored Jan 14, 2025
1 parent aa178c1 commit 173069b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions FBControlCore/Applications/FBApplicationBundle+Install.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,25 @@ + (BOOL)isApplicationAtPath:(NSString *)path

+ (FBFutureContext<NSURL *> *)temporaryExtractPathWithQueue:(dispatch_queue_t)queue logger:(id<FBControlCoreLogger>)logger
{
NSURL *temporaryPath = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:NSProcessInfo.processInfo.globallyUniqueString] isDirectory:YES];
return [[FBFuture
onQueue:queue resolve:^{
NSURL *temporaryPathURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:NSProcessInfo.processInfo.globallyUniqueString] isDirectory:YES];
NSError *error = nil;
if (![NSFileManager.defaultManager createDirectoryAtURL:temporaryPath withIntermediateDirectories:YES attributes:nil error:&error]) {
if (![NSFileManager.defaultManager createDirectoryAtURL:temporaryPathURL withIntermediateDirectories:YES attributes:nil error:&error]) {
return [[[FBControlCoreError
describeFormat:@"Could not create temporary directory for IPA extraction %@", temporaryPath]
describeFormat:@"Could not create temporary directory for IPA extraction %@", temporaryPathURL]
causedBy:error]
failFuture];
}
return [FBFuture futureWithResult:temporaryPath];
return [FBFuture futureWithResult:temporaryPathURL];
}]
onQueue:queue contextualTeardown:^(NSString *extractPath, FBFutureState __) {
[logger logFormat:@"Removing extracted directory %@", temporaryPath];
onQueue:queue contextualTeardown:^(NSURL *temporaryPathURL, FBFutureState __) {
[logger logFormat:@"Removing extracted directory %@", temporaryPathURL];
NSError *innerError = nil;
if ([NSFileManager.defaultManager removeItemAtPath:extractPath error:&innerError]) {
[logger logFormat:@"Removed extracted directory %@", temporaryPath];
if ([NSFileManager.defaultManager removeItemAtURL:temporaryPathURL error:&innerError]) {
[logger logFormat:@"Removed extracted directory %@", temporaryPathURL];
} else {
[logger logFormat:@"Failed to remove extracted directory %@ with error %@", temporaryPath, innerError];
[logger logFormat:@"Failed to remove extracted directory %@ with error %@", temporaryPathURL, innerError];
}
}];
}
Expand Down

0 comments on commit 173069b

Please sign in to comment.