Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Blumberg authored and Lars Blumberg committed Aug 29, 2014
2 parents 317fb78 + f22c7cb commit 707472d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AFCache.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "AFCache"
s.version = "0.9.10.1"
s.version = "0.10"
s.summary = "AFCache is an HTTP disk cache for use on iPhone/iPad and OSX."

s.description = <<-DESC
Expand Down
16 changes: 16 additions & 0 deletions AFCache.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
C7503D49198640AA0032E451 /* AFDownloadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = C7503D45198640AA0032E451 /* AFDownloadOperation.m */; };
E33490CD199E24B200DE6D82 /* NSFileHandle+AFCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E33490CB199E24B200DE6D82 /* NSFileHandle+AFCache.h */; };
E33490CE199E24B200DE6D82 /* NSFileHandle+AFCache.m in Sources */ = {isa = PBXBuildFile; fileRef = E33490CC199E24B200DE6D82 /* NSFileHandle+AFCache.m */; };
E369E20919B0711700EAC9FE /* AFCache+DeprecatedAPI.h in Headers */ = {isa = PBXBuildFile; fileRef = E369E20719B0711700EAC9FE /* AFCache+DeprecatedAPI.h */; };
E369E20A19B0711700EAC9FE /* AFCache+DeprecatedAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = E369E20819B0711700EAC9FE /* AFCache+DeprecatedAPI.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -216,6 +218,8 @@
C7503D45198640AA0032E451 /* AFDownloadOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFDownloadOperation.m; path = src/shared/AFDownloadOperation.m; sourceTree = "<group>"; };
E33490CB199E24B200DE6D82 /* NSFileHandle+AFCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSFileHandle+AFCache.h"; path = "src/shared/NSFileHandle+AFCache.h"; sourceTree = "<group>"; };
E33490CC199E24B200DE6D82 /* NSFileHandle+AFCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSFileHandle+AFCache.m"; path = "src/shared/NSFileHandle+AFCache.m"; sourceTree = "<group>"; };
E369E20719B0711700EAC9FE /* AFCache+DeprecatedAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "AFCache+DeprecatedAPI.h"; path = "src/shared/AFCache+DeprecatedAPI.h"; sourceTree = "<group>"; };
E369E20819B0711700EAC9FE /* AFCache+DeprecatedAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "AFCache+DeprecatedAPI.m"; path = "src/shared/AFCache+DeprecatedAPI.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -408,6 +412,7 @@
05A098ED13C43BA200BC9572 /* shared */ = {
isa = PBXGroup;
children = (
E369E20619B070FB00EAC9FE /* Deprecated */,
E33490CA199E182A00DE6D82 /* Categories */,
05238D15151B6E5C0015D70E /* util */,
05238D14151B6E470015D70E /* core */,
Expand Down Expand Up @@ -540,6 +545,15 @@
name = Categories;
sourceTree = "<group>";
};
E369E20619B070FB00EAC9FE /* Deprecated */ = {
isa = PBXGroup;
children = (
E369E20719B0711700EAC9FE /* AFCache+DeprecatedAPI.h */,
E369E20819B0711700EAC9FE /* AFCache+DeprecatedAPI.m */,
);
name = Deprecated;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand All @@ -558,6 +572,7 @@
C7503D46198640AA0032E451 /* AFDownloadOperation.h in Headers */,
C73C71CC19816F13008EDA23 /* AFRequestConfiguration.h in Headers */,
04007352153242D400335735 /* AFCache+Mimetypes.h in Headers */,
E369E20919B0711700EAC9FE /* AFCache+DeprecatedAPI.h in Headers */,
E33490CD199E24B200DE6D82 /* NSFileHandle+AFCache.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -813,6 +828,7 @@
05C9BAFE132A291B0087CEA1 /* AFCacheableItemInfo.m in Sources */,
05C9BB00132A291B0087CEA1 /* AFPackageInfo.m in Sources */,
05C9BB02132A291B0087CEA1 /* AFURLCache.m in Sources */,
E369E20A19B0711700EAC9FE /* AFCache+DeprecatedAPI.m in Sources */,
C7503D48198640AA0032E451 /* AFDownloadOperation.m in Sources */,
05C9BB05132A291B0087CEA1 /* DateParser.m in Sources */,
05C9BB19132A29370087CEA1 /* AFRegexString.m in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions src/shared/AFCache+DeprecatedAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AFCache+DeprecatedAPI.h
// AFCache
//
// Created by Lars Blumberg on 29.08.14.
// Copyright (c) 2014 Artifacts - Fine Software Development. All rights reserved.
//

#import <AFCache/AFCache.h>
#import <AvailabilityMacros.h>

@interface AFCache (DeprecatedAPI)

- (AFCacheableItem *)cachedObjectForURLSynchroneous: (NSURL *) url DEPRECATED_MSG_ATTRIBUTE("Use cachedObjectForURLSynchronous:");
- (AFCacheableItem *)cachedObjectForURLSynchroneous:(NSURL *)url options: (int)options DEPRECATED_MSG_ATTRIBUTE("Use cachedObjectForURLSynchronous:options:");

@end
21 changes: 21 additions & 0 deletions src/shared/AFCache+DeprecatedAPI.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// AFCache+DeprecatedAPI.m
// AFCache
//
// Created by Lars Blumberg on 29.08.14.
// Copyright (c) 2014 Artifacts - Fine Software Development. All rights reserved.
//

#import "AFCache+DeprecatedAPI.h"

@implementation AFCache (DeprecatedAPI)

- (AFCacheableItem *)cachedObjectForURLSynchroneous: (NSURL *) url {
return [self cachedObjectForURLSynchronous:url];
}

- (AFCacheableItem *)cachedObjectForURLSynchroneous:(NSURL *)url options: (int)options {
return [self cachedObjectForURLSynchronous:url options:options];
}

@end
1 change: 0 additions & 1 deletion src/shared/AFCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ typedef struct NetworkTimeoutIntervals {
- (BOOL)hasCachedItemForURL:(NSURL *)url;
- (AFCacheableItem *)cacheableItemFromCacheStore: (NSURL *) url;
- (unsigned long)diskCacheSize;
- (NSArray*)clientItemsForURL:(NSURL*)url;

/*
* Cancel any asynchronous operations and downloads
Expand Down
16 changes: 9 additions & 7 deletions src/shared/AFCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#import <SystemConfiguration/SCNetworkReachability.h>
#import <MacTypes.h>
#import "AFRegexString.h"
#import "AFCache_Logging.h"
#import "AFDownloadOperation.h"
Expand All @@ -42,7 +43,6 @@
const double kAFCacheInfiniteFileSize = 0.0;
const double kAFCacheArchiveDelay = 30.0; // archive every 30s


extern NSString* const UIApplicationWillResignActiveNotification;

@interface AFCache()
Expand Down Expand Up @@ -853,15 +853,15 @@ - (void)deserializeState {
// Deserialize cacheable item info store
NSString *infoStoreFilename = [_dataPath stringByAppendingPathComponent:kAFCacheExpireInfoDictionaryFilename];
NSDictionary *archivedExpireDates = [NSKeyedUnarchiver unarchiveObjectWithFile: infoStoreFilename];
NSMutableDictionary *cacheItemInfos = [archivedExpireDates objectForKey:kAFCacheInfoStoreCachedObjectsKey];
NSMutableDictionary *cachedItemInfos = [archivedExpireDates objectForKey:kAFCacheInfoStoreCachedObjectsKey];
NSMutableDictionary *urlRedirects = [archivedExpireDates objectForKey:kAFCacheInfoStoreRedirectsKey];
if (cacheItemInfos && urlRedirects) {
_cachedItemInfos = [NSMutableDictionary dictionaryWithDictionary: cacheItemInfos];
if (cachedItemInfos && urlRedirects) {
_cachedItemInfos = [NSMutableDictionary dictionaryWithDictionary:cachedItemInfos];
_urlRedirects = [NSMutableDictionary dictionaryWithDictionary: urlRedirects];
AFLog(@ "Successfully unarchived expires dictionary");
} else {
_urlRedirects = [NSMutableDictionary dictionary];
_cachedItemInfos = [NSMutableDictionary dictionary];
_urlRedirects = [NSMutableDictionary dictionary];
AFLog(@ "Created new expires dictionary");
}

Expand Down Expand Up @@ -1048,7 +1048,8 @@ - (void)removeCacheEntry:(AFCacheableItemInfo*)info fileOnly:(BOOL) fileOnly fal
filePath = [self filePathForFilename:info.filename pathExtension:[info.request.URL pathExtension]];
}
}


// TODO: If file didn't exist, cache item must be removed anyway
if ([[NSFileManager defaultManager] removeItemAtPath: filePath error: &error]) {
if (!fileOnly) {
if (fallbackURL) {
Expand All @@ -1059,7 +1060,7 @@ - (void)removeCacheEntry:(AFCacheableItemInfo*)info fileOnly:(BOOL) fileOnly fal
}
}
} else {
NSLog(@ "Failed to delete file for outdated cache item info %@", info);
AFLog(@ "Failed to delete file for outdated cache item info %@", info);
}
}

Expand Down Expand Up @@ -1212,6 +1213,7 @@ - (AFCacheableItem *)cacheableItemFromCacheStore: (NSURL *) URL {
if (!fileExists) {
// Something went wrong
AFLog(@"Cache info store out of sync for url %@, removing cached file %@.", [URL absoluteString], [self fullPathForCacheableItem:cacheableItem]);
// TODO: The concept is broken here. Why are we going to delete a file that obviously DOES NOT EXIST?
[self removeCacheEntry:cacheableItem.info fileOnly:YES];
cacheableItem = nil;
}
Expand Down

0 comments on commit 707472d

Please sign in to comment.