Skip to content

Commit fe6b4c9

Browse files
authored
Merge pull request #658 from zapcannon87/master
feat: file prefix
2 parents 3679f66 + 1d1458b commit fe6b4c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+721
-1192
lines changed

AVOS/AVOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
D30B6A1424A09978006ABE09 /* LeanCloudObjc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D30B6A0B24A09978006ABE09 /* LeanCloudObjc.framework */; };
1212
D30B6A1B24A09978006ABE09 /* LeanCloudObjc.h in Headers */ = {isa = PBXBuildFile; fileRef = D30B6A0D24A09978006ABE09 /* LeanCloudObjc.h */; settings = {ATTRIBUTES = (Public, ); }; };
1313
D30B6A2224A09B1F006ABE09 /* UserAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AAC1A5A7A0000C5C6C4 /* UserAgent.h */; };
14-
D30B6A2324A09B1F006ABE09 /* LCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C8419F31A5A79FF00C5C6C4 /* LCConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
1514
D30B6A2424A09B1F006ABE09 /* LCGlobal.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C8419F41A5A79FF00C5C6C4 /* LCGlobal.h */; };
16-
D30B6A2524A09B1F006ABE09 /* LCAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8311CD841C3D25B9007DEFF8 /* LCAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; };
1715
D30B6A2824A09B1F006ABE09 /* LCApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = D3700B782475345C00678B2B /* LCApplication.h */; settings = {ATTRIBUTES = (Public, ); }; };
1816
D30B6A2924A09B1F006ABE09 /* LCApplication_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D3596DAC2480EEED002D2D22 /* LCApplication_Internal.h */; };
1917
D30B6A2A24A09B1F006ABE09 /* LCApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = D3700B792475345C00678B2B /* LCApplication.m */; };
@@ -113,12 +111,12 @@
113111
D30B6A9924A09DF2006ABE09 /* LCUser.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841A9E1A5A7A0000C5C6C4 /* LCUser.h */; settings = {ATTRIBUTES = (Public, ); }; };
114112
D30B6A9A24A09DF2006ABE09 /* LCUser_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AA01A5A7A0000C5C6C4 /* LCUser_Internal.h */; };
115113
D30B6A9B24A09DF2006ABE09 /* LCUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841A9F1A5A7A0000C5C6C4 /* LCUser.m */; };
116-
D30B6A9E24A09E35006ABE09 /* LCErrorUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AA21A5A7A0000C5C6C4 /* LCErrorUtils.h */; };
114+
D30B6A9E24A09E35006ABE09 /* LCErrorUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AA21A5A7A0000C5C6C4 /* LCErrorUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
117115
D30B6A9F24A09E35006ABE09 /* LCErrorUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841AA31A5A7A0000C5C6C4 /* LCErrorUtils.m */; };
118116
D30B6AA024A09E35006ABE09 /* LCHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AA41A5A7A0000C5C6C4 /* LCHelpers.h */; };
119117
D30B6AA124A09E35006ABE09 /* LCLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AA61A5A7A0000C5C6C4 /* LCLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
120118
D30B6AA224A09E35006ABE09 /* LCLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841AA71A5A7A0000C5C6C4 /* LCLogger.m */; };
121-
D30B6AA324A09E35006ABE09 /* LCUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AAA1A5A7A0000C5C6C4 /* LCUtils.h */; };
119+
D30B6AA324A09E35006ABE09 /* LCUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AAA1A5A7A0000C5C6C4 /* LCUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
122120
D30B6AA424A09E35006ABE09 /* LCUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841AAB1A5A7A0000C5C6C4 /* LCUtils.m */; };
123121
D30B6AA524A09E35006ABE09 /* LCDatabaseCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 830E7CFE1B1CB07B005F4B22 /* LCDatabaseCommon.h */; };
124122
D30B6AA624A09E35006ABE09 /* LCDatabaseCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 830E7CF61B1CA2A2005F4B22 /* LCDatabaseCoordinator.h */; };
@@ -304,6 +302,7 @@
304302
D33127D326CBAD6D00BBDE09 /* LCFileTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D33127D226CBAD6D00BBDE09 /* LCFileTestCase.swift */; };
305303
D33127D526CE391500BBDE09 /* LCLeaderboardTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D33127D426CE391500BBDE09 /* LCLeaderboardTestCase.swift */; };
306304
D33127D726CFAC5100BBDE09 /* LCLeaderboard_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D33127D626CFAC5100BBDE09 /* LCLeaderboard_Internal.h */; };
305+
D357146E26D50405009E611C /* LCUtils_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D357146D26D50405009E611C /* LCUtils_Internal.h */; };
307306
D365E42426C3D29F00148DE8 /* LCLeaderboard.h in Headers */ = {isa = PBXBuildFile; fileRef = D365E42226C3D29F00148DE8 /* LCLeaderboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
308307
D365E42526C3D29F00148DE8 /* LCLeaderboard.m in Sources */ = {isa = PBXBuildFile; fileRef = D365E42326C3D29F00148DE8 /* LCLeaderboard.m */; };
309308
D36A095A25BEA75000A4F312 /* IMMessageTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D36A095925BEA75000A4F312 /* IMMessageTestCase.swift */; };
@@ -354,7 +353,6 @@
354353
830EB9FE1C44F3D600BA917F /* LCSaveOption_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCSaveOption_internal.h; sourceTree = "<group>"; };
355354
830F159E1F010F260009B4D0 /* LCIMRecalledMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCIMRecalledMessage.h; sourceTree = "<group>"; };
356355
830F159F1F010F260009B4D0 /* LCIMRecalledMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LCIMRecalledMessage.m; sourceTree = "<group>"; };
357-
8311CD841C3D25B9007DEFF8 /* LCAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCAvailability.h; sourceTree = "<group>"; };
358356
831E29581D882CBB006E502B /* LCIMMessageOption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCIMMessageOption.h; sourceTree = "<group>"; };
359357
831E29591D882CBB006E502B /* LCIMMessageOption.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LCIMMessageOption.m; sourceTree = "<group>"; };
360358
83331D431EB9A25F00CADC9C /* LCCaptcha.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCCaptcha.h; sourceTree = "<group>"; };
@@ -418,7 +416,6 @@
418416
8C8419E01A5A79FF00C5C6C4 /* LCRole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCRole.h; sourceTree = "<group>"; };
419417
8C8419E11A5A79FF00C5C6C4 /* LCRole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LCRole.m; sourceTree = "<group>"; };
420418
8C8419E21A5A79FF00C5C6C4 /* LCRole_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCRole_Internal.h; sourceTree = "<group>"; };
421-
8C8419F31A5A79FF00C5C6C4 /* LCConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCConstants.h; sourceTree = "<group>"; };
422419
8C8419F41A5A79FF00C5C6C4 /* LCGlobal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCGlobal.h; sourceTree = "<group>"; };
423420
8C8419FA1A5A79FF00C5C6C4 /* LCCacheManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCCacheManager.h; sourceTree = "<group>"; };
424421
8C8419FB1A5A79FF00C5C6C4 /* LCCacheManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LCCacheManager.m; sourceTree = "<group>"; };
@@ -557,6 +554,7 @@
557554
D34C417D2483C3FD00CD2459 /* LCRTMConnection_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCRTMConnection_Internal.h; sourceTree = "<group>"; };
558555
D34EBDCC211C20FF0092A538 /* LCRouter_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCRouter_Internal.h; sourceTree = "<group>"; };
559556
D34FD72B2068CFE900B7C11B /* LCLiveQuery_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCLiveQuery_Internal.h; sourceTree = "<group>"; };
557+
D357146D26D50405009E611C /* LCUtils_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCUtils_Internal.h; sourceTree = "<group>"; };
560558
D3596DAC2480EEED002D2D22 /* LCApplication_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCApplication_Internal.h; sourceTree = "<group>"; };
561559
D365E42226C3D29F00148DE8 /* LCLeaderboard.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCLeaderboard.h; sourceTree = "<group>"; };
562560
D365E42326C3D29F00148DE8 /* LCLeaderboard.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LCLeaderboard.m; sourceTree = "<group>"; };
@@ -824,9 +822,7 @@
824822
isa = PBXGroup;
825823
children = (
826824
8C841AAC1A5A7A0000C5C6C4 /* UserAgent.h */,
827-
8C8419F31A5A79FF00C5C6C4 /* LCConstants.h */,
828825
8C8419F41A5A79FF00C5C6C4 /* LCGlobal.h */,
829-
8311CD841C3D25B9007DEFF8 /* LCAvailability.h */,
830826
D3700B782475345C00678B2B /* LCApplication.h */,
831827
D3596DAC2480EEED002D2D22 /* LCApplication_Internal.h */,
832828
D3700B792475345C00678B2B /* LCApplication.m */,
@@ -1045,6 +1041,7 @@
10451041
8C841AA61A5A7A0000C5C6C4 /* LCLogger.h */,
10461042
8C841AA71A5A7A0000C5C6C4 /* LCLogger.m */,
10471043
8C841AAA1A5A7A0000C5C6C4 /* LCUtils.h */,
1044+
D357146D26D50405009E611C /* LCUtils_Internal.h */,
10481045
8C841AAB1A5A7A0000C5C6C4 /* LCUtils.m */,
10491046
830E7CFE1B1CB07B005F4B22 /* LCDatabaseCommon.h */,
10501047
830E7CF61B1CA2A2005F4B22 /* LCDatabaseCoordinator.h */,
@@ -1461,6 +1458,7 @@
14611458
D30B6B0224A09F1F006ABE09 /* LCGPBStruct.pbobjc.h in Headers */,
14621459
D30B6A4824A09CFE006ABE09 /* LCFile_Internal.h in Headers */,
14631460
D30B6ACC24A09ED2006ABE09 /* LCIMConversationQuery.h in Headers */,
1461+
D357146E26D50405009E611C /* LCUtils_Internal.h in Headers */,
14641462
D32AA480263BF2F30044E74E /* Foundation.h in Headers */,
14651463
D30B6B5C24A0A03D006ABE09 /* LCLiveQuery_Internal.h in Headers */,
14661464
D30B6AA124A09E35006ABE09 /* LCLogger.h in Headers */,
@@ -1478,14 +1476,12 @@
14781476
D30B6A6524A09D52006ABE09 /* LCPush_Internal.h in Headers */,
14791477
D30B6A6924A09D62006ABE09 /* LCFriendQuery.h in Headers */,
14801478
D30B6A7424A09D87006ABE09 /* LCRouter_Internal.h in Headers */,
1481-
D30B6A2524A09B1F006ABE09 /* LCAvailability.h in Headers */,
14821479
D30B6AAD24A09E35006ABE09 /* NSDictionary+LCHash.h in Headers */,
14831480
D30B6AE724A09F1E006ABE09 /* LCGPBDescriptor_PackagePrivate.h in Headers */,
14841481
D30B6B4524A09F84006ABE09 /* LCIMImageMessage.h in Headers */,
14851482
D30B6AAA24A09E35006ABE09 /* LCKeyValueSQL.h in Headers */,
14861483
D30B6A8224A09DCA006ABE09 /* LCNetworkReachabilityManager.h in Headers */,
14871484
D30B6B3624A09F79006ABE09 /* LCIMCacheStore.h in Headers */,
1488-
D30B6A2324A09B1F006ABE09 /* LCConstants.h in Headers */,
14891485
D30B6AC624A09ED1006ABE09 /* LCIMConversation.h in Headers */,
14901486
D30B6A9924A09DF2006ABE09 /* LCUser.h in Headers */,
14911487
D30B6AD024A09ED2006ABE09 /* LCIMKeyedConversation_internal.h in Headers */,

AVOS/LeanCloudObjc/Foundation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#import "LCApplication.h"
1313

1414
// Constants
15-
#import "LCAvailability.h"
16-
#import "LCConstants.h"
1715
#import "LCLogger.h"
16+
#import "LCErrorUtils.h"
17+
#import "LCUtils.h"
1818

1919
// Object
2020
#import "LCObject.h"

AVOS/LeanCloudObjcTests/LCFileTestCase.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,27 @@ class LCFileTestCase: BaseTestCase {
3636
XCTAssertTrue(object0.fetch())
3737
XCTAssertTrue(object0[fileFieldKey] is LCFile)
3838
}
39+
40+
/*
41+
func testPathPrefix() {
42+
let prefixKey = "prefix"
43+
let prefixValue = "gamesaves"
44+
let file = LCFile(data: uuid.data(using: .utf8)!)
45+
file.setPathPrefix(prefixValue)
46+
XCTAssertEqual(file.metaData?[prefixKey] as? String, prefixValue)
47+
file.clearPathPrefix()
48+
XCTAssertNil(file.metaData?[prefixKey])
49+
file.setPathPrefix(prefixValue)
50+
expecting { exp in
51+
file.saveInBackground { succeeded, error in
52+
XCTAssertTrue(succeeded)
53+
XCTAssertNil(error)
54+
exp.fulfill()
55+
}
56+
}
57+
XCTAssertEqual(file.metaData?[prefixKey] as? String, prefixValue)
58+
XCTAssertNil(file.object(forKey: prefixKey))
59+
XCTAssertTrue((file.url ?? "").contains("/\(prefixValue)/"))
60+
}
61+
*/
3962
}

AVOS/Sources/Foundation/Cache/LCCacheManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
#import <Foundation/Foundation.h>
10-
#import "LCConstants.h"
10+
#import "LCUtils.h"
1111

1212
@interface LCCacheManager : NSObject
1313

AVOS/Sources/Foundation/Cache/LCCacheManager.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "LCErrorUtils.h"
1111
#import "LCUtils.h"
1212
#import "LCPersistenceUtils.h"
13-
13+
#import "LCHelpers.h"
1414

1515
@interface LCCacheManager ()
1616
@property (nonatomic, copy) NSString *diskCachePath;
@@ -53,7 +53,7 @@ - (NSString *)pathForKey:(NSString *)key {
5353
}
5454

5555
- (BOOL)hasCacheForKey:(NSString *)key {
56-
return [[NSFileManager defaultManager] fileExistsAtPath:[self pathForKey:[key LCMD5String]]];
56+
return [[NSFileManager defaultManager] fileExistsAtPath:[self pathForKey:[key _lc_MD5String]]];
5757
}
5858
- (BOOL)hasCacheForMD5Key:(NSString *)key {
5959
return [[NSFileManager defaultManager] fileExistsAtPath:[self pathForKey:key]];
@@ -67,9 +67,9 @@ - (void)getWithKey:(NSString *)key maxCacheAge:(NSTimeInterval)maxCacheAge block
6767
if (maxCacheAge<=0) {
6868
isTooOld=YES;
6969
} else {
70-
diskResult=[LCPersistenceUtils getJSONFromPath:[self pathForKey:[key LCMD5String]]];
70+
diskResult=[LCPersistenceUtils getJSONFromPath:[self pathForKey:[key _lc_MD5String]]];
7171
if (diskResult && maxCacheAge > 0) {
72-
NSDate *lastModified = [LCPersistenceUtils lastModified:[self pathForKey:[key LCMD5String]]];
72+
NSDate *lastModified = [LCPersistenceUtils lastModified:[self pathForKey:[key _lc_MD5String]]];
7373
if ([[NSDate date] timeIntervalSinceDate:lastModified] > maxCacheAge) {
7474
isTooOld = YES;
7575
}
@@ -88,7 +88,7 @@ - (void)getWithKey:(NSString *)key maxCacheAge:(NSTimeInterval)maxCacheAge block
8888

8989
- (void)saveJSON:(id)JSON forKey:(NSString *)key {
9090
dispatch_async(self.cacheQueue, ^{
91-
[LCPersistenceUtils saveJSON:JSON toPath:[self pathForKey:[key LCMD5String]]];
91+
[LCPersistenceUtils saveJSON:JSON toPath:[self pathForKey:[key _lc_MD5String]]];
9292
});
9393
}
9494

@@ -125,7 +125,7 @@ + (BOOL)clearCacheMoreThanDays:(NSInteger)numberOfDays {
125125

126126
- (void)clearCacheForKey:(NSString *)key {
127127
dispatch_sync(self.cacheQueue, ^{
128-
[[NSFileManager defaultManager] removeItemAtPath:[self pathForKey:[key LCMD5String]] error:NULL];
128+
[[NSFileManager defaultManager] removeItemAtPath:[self pathForKey:[key _lc_MD5String]] error:NULL];
129129
});
130130
}
131131

AVOS/Sources/Foundation/Cache/LCPersistenceUtils.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#import "LCPersistenceUtils.h"
1010
#import <TargetConditionals.h>
1111
#import "LCUtils.h"
12+
#import "LCLogger.h"
13+
#import "LCApplication_Internal.h"
1214

1315
#define LCRootDirName @"LeanCloud"
1416
#define LCMessageCacheDirName @"MessageCache"

0 commit comments

Comments
 (0)