Skip to content

Commit

Permalink
Fixes a crash for resumed images with long keys (#383)
Browse files Browse the repository at this point in the history
* Fixes a crash for resumed images with long keys

Keys that are long would get their key hashed. This meant that when en/decoding
the object, it wouldn't be recognized as an object that needed to be un/archived.

* Add changelog entry
  • Loading branch information
garrettmoon authored Jun 29, 2017
1 parent fce52ea commit a9e8ea2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [fixed] Fixes a deadlock with canceling processor tasks [#374](https://github.com/pinterest/PINRemoteImage/pull/374) [zachwaugh](https://github.com/zachwaugh)
- [fixed] Fixes a deadlock in the retry system. [garrettmoon](https://github.com/garrettmoon)
- [fixed] Fixes a threadsafety issue in accessing callbacks. [garrettmoon](https://github.com/garrettmoon)
- [fixed] Fixes a crash with resumed downloads when a key is long. [garrettmoon](https://github.com/garrettmoon)
- [new] PINRemoteImageManager now respects the request timeout value of session configuration. [garrettmoon](https://github.com/garrettmoon)
- [new] Updated to latest PINCache beta 5. [garrettmoon](https://github.com/garrettmoon)
- [new] Added support for getting NSURLResponse from a PINRemoteImageManagerResult object. [garrettmoon](https://github.com/garrettmoon)
Expand Down
7 changes: 4 additions & 3 deletions Source/Classes/PINRemoteImageManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -1517,9 +1517,6 @@ - (NSString *)cacheKeyForURL:(NSURL *)url processorKey:(NSString *)processorKey
if (processorKey.length > 0) {
cacheKey = [cacheKey stringByAppendingFormat:@"-<%@>", processorKey];
}
if (resume) {
cacheKey = [PINRemoteImageCacheKeyResumePrefix stringByAppendingString:cacheKey];
}

//PINDiskCache uses this key as the filename of the file written to disk
//Due to the current filesystem used in Darwin, this name must be limited to 255 chars.
Expand All @@ -1542,6 +1539,10 @@ - (NSString *)cacheKeyForURL:(NSURL *)url processorKey:(NSString *)processorKey
}
cacheKey = [hexString copy];
}
//The resume key must not be hashed, it is used to decide whether or not to decode from the disk cache.
if (resume) {
cacheKey = [PINRemoteImageCacheKeyResumePrefix stringByAppendingString:cacheKey];
}

return cacheKey;
}
Expand Down

0 comments on commit a9e8ea2

Please sign in to comment.