mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 15:49:36 +08:00
Merge pull request #100 from Microsoft/use-appsupport-dir
Use Application Support Directory
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
+ (NSURL *)bundleURLForResource:(NSString *)resourceName
|
||||
withExtension:(NSString *)resourceExtension;
|
||||
|
||||
+ (NSString *)getDocumentsDirectory;
|
||||
+ (NSString *)getApplicationSupportDirectory;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ static NSString *const PendingUpdateRollbackTimeoutKey = @"rollbackTimeout";
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *)getDocumentsDirectory
|
||||
+ (NSString *)getApplicationSupportDirectory
|
||||
{
|
||||
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
return documentsDirectory;
|
||||
NSString *applicationSupportDirectory = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
return applicationSupportDirectory;
|
||||
}
|
||||
|
||||
// Private API methods
|
||||
|
||||
@@ -14,7 +14,7 @@ NSString * const UnzippedFolderName = @"unzipped";
|
||||
|
||||
+ (NSString *)getCodePushPath
|
||||
{
|
||||
return [[CodePush getDocumentsDirectory] stringByAppendingPathComponent:@"CodePush"];
|
||||
return [[CodePush getApplicationSupportDirectory] stringByAppendingPathComponent:@"CodePush"];
|
||||
}
|
||||
|
||||
+ (NSString *)getDownloadFilePath
|
||||
@@ -290,6 +290,22 @@ NSString * const UnzippedFolderName = @"unzipped";
|
||||
}
|
||||
|
||||
if (relativeBundlePath) {
|
||||
NSString *absoluteBundlePath = [newPackageFolderPath stringByAppendingPathComponent:relativeBundlePath];
|
||||
NSDictionary *bundleFileAttributes = [[[NSFileManager defaultManager] attributesOfItemAtPath:absoluteBundlePath error:&error] mutableCopy];
|
||||
if (error) {
|
||||
failCallback(error);
|
||||
return;
|
||||
}
|
||||
|
||||
[bundleFileAttributes setValue:[NSDate date] forKey:NSFileModificationDate];
|
||||
[[NSFileManager defaultManager] setAttributes:bundleFileAttributes
|
||||
ofItemAtPath:absoluteBundlePath
|
||||
error:&error];
|
||||
if (error) {
|
||||
failCallback(error);
|
||||
return;
|
||||
}
|
||||
|
||||
[mutableUpdatePackage setValue:relativeBundlePath forKey:RelativeBundlePathKey];
|
||||
} else {
|
||||
error = [[NSError alloc] initWithDomain:CodePushErrorDomain
|
||||
|
||||
Reference in New Issue
Block a user