Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 77049b8

Browse files
committed
Merge pull request #100 from Microsoft/use-appsupport-dir
Use Application Support Directory
2 parents bffcba8 + b059fd7 commit 77049b8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

CodePush.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
+ (NSURL *)bundleURLForResource:(NSString *)resourceName
2121
withExtension:(NSString *)resourceExtension;
2222

23-
+ (NSString *)getDocumentsDirectory;
23+
+ (NSString *)getApplicationSupportDirectory;
2424

2525
@end
2626

CodePush.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
6262
}
6363
}
6464

65-
+ (NSString *)getDocumentsDirectory
65+
+ (NSString *)getApplicationSupportDirectory
6666
{
67-
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
68-
return documentsDirectory;
67+
NSString *applicationSupportDirectory = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0];
68+
return applicationSupportDirectory;
6969
}
7070

7171
// Private API methods

CodePushPackage.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ @implementation CodePushPackage
1414

1515
+ (NSString *)getCodePushPath
1616
{
17-
return [[CodePush getDocumentsDirectory] stringByAppendingPathComponent:@"CodePush"];
17+
return [[CodePush getApplicationSupportDirectory] stringByAppendingPathComponent:@"CodePush"];
1818
}
1919

2020
+ (NSString *)getDownloadFilePath
@@ -290,6 +290,22 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
290290
}
291291

292292
if (relativeBundlePath) {
293+
NSString *absoluteBundlePath = [newPackageFolderPath stringByAppendingPathComponent:relativeBundlePath];
294+
NSDictionary *bundleFileAttributes = [[[NSFileManager defaultManager] attributesOfItemAtPath:absoluteBundlePath error:&error] mutableCopy];
295+
if (error) {
296+
failCallback(error);
297+
return;
298+
}
299+
300+
[bundleFileAttributes setValue:[NSDate date] forKey:NSFileModificationDate];
301+
[[NSFileManager defaultManager] setAttributes:bundleFileAttributes
302+
ofItemAtPath:absoluteBundlePath
303+
error:&error];
304+
if (error) {
305+
failCallback(error);
306+
return;
307+
}
308+
293309
[mutableUpdatePackage setValue:relativeBundlePath forKey:RelativeBundlePathKey];
294310
} else {
295311
error = [[NSError alloc] initWithDomain:CodePushErrorDomain

0 commit comments

Comments
 (0)