diff --git a/CompanionLib/Utility/FBIDBStorageManager.m b/CompanionLib/Utility/FBIDBStorageManager.m index 0c369f59d..c933f7535 100644 --- a/CompanionLib/Utility/FBIDBStorageManager.m +++ b/CompanionLib/Utility/FBIDBStorageManager.m @@ -155,10 +155,10 @@ - (BOOL)checkArchitecture:(FBBundleDescriptor *)bundle error:(NSError **)error - (FBFuture *)saveBundle:(FBBundleDescriptor *)bundle { - return [self saveBundle:bundle skipSigningBundles:NO]; + return [self saveBundle:bundle usingSymlink:YES skipSigningBundles:NO]; } -- (FBFuture *)saveBundle:(FBBundleDescriptor *)bundle skipSigningBundles:(BOOL)skipSigningBundles +- (FBFuture *)saveBundle:(FBBundleDescriptor *)bundle usingSymlink:(BOOL)useSymlink skipSigningBundles:(BOOL)skipSigningBundles { // Check that the bundle matches the architecture of the target. NSError *error = nil; @@ -172,12 +172,21 @@ - (BOOL)checkArchitecture:(FBBundleDescriptor *)bundle error:(NSError **)error return [FBFuture futureWithError:error]; } - // Copy over bundle NSURL *sourceBundlePath = [NSURL fileURLWithPath:bundle.path]; NSURL *destinationBundlePath = [storageDirectory URLByAppendingPathComponent:sourceBundlePath.lastPathComponent]; - [self.logger logFormat:@"Symlink %@ to %@", bundle.identifier, destinationBundlePath]; - if (![NSFileManager.defaultManager createSymbolicLinkAtURL:destinationBundlePath withDestinationURL:sourceBundlePath error:&error]) { - return [FBFuture futureWithError:error]; + if (useSymlink) { + // Symlink the bundle + [self.logger logFormat:@"Symlink %@ to %@", bundle.identifier, destinationBundlePath]; + if (![NSFileManager.defaultManager createSymbolicLinkAtURL:destinationBundlePath withDestinationURL:sourceBundlePath error:&error]) { + return [FBFuture futureWithError:error]; + } + } else { + // Move the bundle + [self.logger logFormat:@"Moving %@ to %@", bundle.identifier, destinationBundlePath]; + if (![NSFileManager.defaultManager moveItemAtURL:sourceBundlePath toURL:destinationBundlePath error:&error]) { + return [FBFuture futureWithError:error]; + } + [self.logger logFormat:@"Moved %@", bundle.identifier]; } FBInstalledArtifact *artifact = [[FBInstalledArtifact alloc] initWithName:bundle.identifier uuid:bundle.binary.uuid path:destinationBundlePath]; @@ -291,7 +300,7 @@ @implementation FBXCTestBundleStorage } if (xctestBundleURL) { - return [self saveTestBundle:xctestBundleURL skipSigningBundles:skipSigningBundles]; + return [self saveTestBundle:xctestBundleURL usingSymlink:NO skipSigningBundles:skipSigningBundles]; } if (xctestrunURL) { return [self saveTestRun:xctestrunURL]; @@ -305,7 +314,7 @@ @implementation FBXCTestBundleStorage { // save .xctest or .xctestrun if ([filePath.pathExtension isEqualToString:XctestExtension]) { - return [self saveTestBundle:filePath skipSigningBundles:skipSigningBundles]; + return [self saveTestBundle:filePath usingSymlink:YES skipSigningBundles:skipSigningBundles]; } if ([filePath.pathExtension isEqualToString:XctestRunExtension]) { return [self saveTestRun:filePath]; @@ -509,7 +518,7 @@ - (NSURL *)xctestBundleWithID:(NSString *)bundleID error:(NSError **)error return [[FBXCodebuildTestRunDescriptor alloc] initWithURL:xctestrunURL name:testTarget testBundle:testBundle testHostBundle:testHostBundle]; } -- (FBFuture *)saveTestBundle:(NSURL *)testBundleURL skipSigningBundles:(BOOL)skipSigningBundles +- (FBFuture *)saveTestBundle:(NSURL *)testBundleURL usingSymlink:(BOOL)useSymlink skipSigningBundles:(BOOL)skipSigningBundles { // Test Bundles don't always have a bundle id, so fallback to another name if it's not there. NSError *error = nil; @@ -517,7 +526,7 @@ - (NSURL *)xctestBundleWithID:(NSString *)bundleID error:(NSError **)error if (!bundle) { return [FBFuture futureWithError:error]; } - return [self saveBundle:bundle skipSigningBundles:skipSigningBundles]; + return [self saveBundle:bundle usingSymlink:useSymlink skipSigningBundles:skipSigningBundles]; } - (FBFuture *)saveTestRun:(NSURL *)XCTestRunURL