Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Fixed bug in the handling of cache when reloadData == YES #421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion MKNetworkKit/MKNetworkEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ -(void) enqueueOperation:(MKNetworkOperation*) operation forceReload:(BOOL) forc
if(cachedData) {
dispatch_async(dispatch_get_main_queue(), ^{
// Jump back to the original thread here since setCachedData updates the main thread
[operation setCachedData:cachedData];
[operation setCachedData:cachedData notifyObservers: !forceReload];
});

if(!forceReload) {
Expand Down
2 changes: 1 addition & 1 deletion MKNetworkKit/MKNetworkOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ typedef enum {
// internal methods called by MKNetworkEngine only.
// Don't touch
-(BOOL) isCacheable;
-(void) setCachedData:(NSData*) cachedData;
-(void) setCachedData:(NSData*) cachedData notifyObservers: (BOOL) notify;
-(void) setCacheHandler:(MKNKResponseBlock) cacheHandler;
-(void) updateHandlersFromOperation:(MKNetworkOperation*) operation;
-(void) updateOperationBasedOnPreviousHeaders:(NSMutableDictionary*) headers;
Expand Down
5 changes: 3 additions & 2 deletions MKNetworkKit/MKNetworkOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,11 @@ -(void) updateHandlersFromOperation:(MKNetworkOperation*) operation {
[self.downloadStreams addObjectsFromArray:operation.downloadStreams];
}

-(void) setCachedData:(NSData*) cachedData {
-(void) setCachedData:(NSData*) cachedData notifyObservers: (BOOL) notify {

self.cachedResponse = cachedData;
[self operationSucceeded];
if (notify)
[self operationSucceeded];
}

-(void) updateOperationBasedOnPreviousHeaders:(NSMutableDictionary*) headers {
Expand Down