@revopush/react-native-code-push 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -197,16 +197,24 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
197
197
  return AssetsFolderName;
198
198
  }
199
199
 
200
+ + (NSString *)cacheKeyForBinaryAtURL:(NSURL *)binaryBundleUrl
201
+ {
202
+ NSString *bundleModifiedDate = [self modifiedDateStringOfFileAtURL:binaryBundleUrl];
203
+ return [NSString stringWithFormat:@"%@:%@",
204
+ [[NSBundle mainBundle] bundlePath],
205
+ bundleModifiedDate ?: @"unknown"];
206
+ }
207
+
200
208
  + (NSString *)getHashForBinaryContents:(NSURL *)binaryBundleUrl
201
209
  error:(NSError **)error
202
210
  {
203
211
  // Get the cached hash from user preferences if it exists.
204
- NSString *binaryModifiedDate = [self modifiedDateStringOfFileAtURL:binaryBundleUrl];
212
+ NSString *binaryCacheKey = [self cacheKeyForBinaryAtURL:binaryBundleUrl];
205
213
  NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
206
214
  NSMutableDictionary *binaryHashDictionary = [preferences objectForKey:BinaryHashKey];
207
215
  NSString *binaryHash = nil;
208
216
  if (binaryHashDictionary != nil) {
209
- binaryHash = [binaryHashDictionary objectForKey:binaryModifiedDate];
217
+ binaryHash = [binaryHashDictionary objectForKey:binaryCacheKey];
210
218
  if (binaryHash == nil) {
211
219
  [preferences removeObjectForKey:BinaryHashKey];
212
220
  [preferences synchronize];
@@ -237,9 +245,7 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
237
245
 
238
246
  binaryHash = [self computeFinalHashFromManifest:manifest error:error];
239
247
 
240
- // Cache the hash in user preferences. This assumes that the modified date for the
241
- // JS bundle changes every time a new bundle is generated by the packager.
242
- [binaryHashDictionary setObject:binaryHash forKey:binaryModifiedDate];
248
+ [binaryHashDictionary setObject:binaryHash forKey:binaryCacheKey];
243
249
  [preferences setObject:binaryHashDictionary forKey:BinaryHashKey];
244
250
  [preferences synchronize];
245
251
  return binaryHash;
@@ -255,11 +261,10 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
255
261
  NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
256
262
  NSMutableDictionary *assetsHashDictionary = [preferences objectForKey:BinaryAssetsHashKey];
257
263
 
258
- NSString *assetsModifiedDate = [self modifiedDateStringOfFileAtURL:
259
- [NSURL fileURLWithPath:assetsPath isDirectory:YES]];
264
+ NSString *assetsCacheKey = [self cacheKeyForBinaryAtURL:[CodePush binaryBundleURL]];
260
265
 
261
266
  if (assetsHashDictionary != nil) {
262
- NSString *cached = [assetsHashDictionary objectForKey:assetsModifiedDate];
267
+ NSString *cached = [assetsHashDictionary objectForKey:assetsCacheKey];
263
268
  if (cached != nil) {
264
269
  return cached;
265
270
  } else {
@@ -285,7 +290,7 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
285
290
  return nil;
286
291
  }
287
292
 
288
- [assetsHashDictionary setObject:assetsHash forKey:assetsModifiedDate];
293
+ [assetsHashDictionary setObject:assetsHash forKey:assetsCacheKey];
289
294
  [preferences setObject:assetsHashDictionary forKey:BinaryAssetsHashKey];
290
295
  [preferences synchronize];
291
296
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revopush/react-native-code-push",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "CodePush.js",
6
6
  "typings": "typings/react-native-code-push.d.ts",