14
14
* limitations under the License.
15
15
*/
16
16
17
- #import " GULHeartbeatDateStorage.h"
17
+ #import < GoogleUtilities/ GULHeartbeatDateStorage.h>
18
18
#import < GoogleUtilities/GULSecureCoding.h>
19
19
20
20
@interface GULHeartbeatDateStorage ()
@@ -56,7 +56,8 @@ + (NSURL *)directoryPathURL {
56
56
* @param directoryPathURL The path to the directory which needs to be created.
57
57
* @param fileCoordinator The fileCoordinator object to coordinate writes to the directory.
58
58
*/
59
- + (void )checkAndCreateDirectory : (NSURL *)directoryPathURL fileCoordinator : (NSFileCoordinator *)fileCoordinator {
59
+ + (void )checkAndCreateDirectory : (NSURL *)directoryPathURL
60
+ fileCoordinator : (NSFileCoordinator *)fileCoordinator {
60
61
NSError *fileCoordinatorError = nil ;
61
62
[fileCoordinator
62
63
coordinateWritingItemAtURL: directoryPathURL
@@ -67,11 +68,10 @@ + (void)checkAndCreateDirectory:(NSURL *)directoryPathURL fileCoordinator:(NSFil
67
68
if (![writingDirectoryURL checkResourceIsReachableAndReturnError: &error]) {
68
69
// If fail creating the Application Support directory, log warning.
69
70
NSError *error;
70
- [[NSFileManager defaultManager ]
71
- createDirectoryAtURL: writingDirectoryURL
72
- withIntermediateDirectories: YES
73
- attributes: nil
74
- error: &error];
71
+ [[NSFileManager defaultManager ] createDirectoryAtURL: writingDirectoryURL
72
+ withIntermediateDirectories: YES
73
+ attributes: nil
74
+ error: &error];
75
75
}
76
76
}];
77
77
}
@@ -84,9 +84,9 @@ - (nullable NSMutableDictionary *)heartbeatDictionaryWithFileURL:(NSURL *)readin
84
84
dict = [NSMutableDictionary dictionary ];
85
85
} else {
86
86
dict = [GULSecureCoding
87
- unarchivedObjectOfClasses: [NSSet setWithArray: @[ NSDictionary .class, NSDate .class ]]
88
- fromData: objectData
89
- error: &error];
87
+ unarchivedObjectOfClasses: [NSSet setWithArray: @[ NSDictionary .class, NSDate .class ]]
88
+ fromData: objectData
89
+ error: &error];
90
90
if (dict == nil || error != nil ) {
91
91
dict = [NSMutableDictionary dictionary ];
92
92
}
@@ -109,20 +109,20 @@ - (nullable NSDate *)heartbeatDateForTag:(NSString *)tag {
109
109
- (BOOL )setHearbeatDate : (NSDate *)date forTag : (NSString *)tag {
110
110
NSError *error;
111
111
__block BOOL isSuccess = false ;
112
- [self .fileCoordinator
113
- coordinateReadingItemAtURL: self .fileURL
114
- options: 0
115
- writingItemAtURL: self .fileURL
116
- options: 0
117
- error: &error
118
- byAccessor: ^( NSURL *readingURL, NSURL *writingURL) {
119
- NSMutableDictionary *dictionary = [self heartbeatDictionaryWithFileURL: readingURL];
120
- dictionary[tag] = date;
121
- NSError *error;
122
- isSuccess = [self writeDictionary: dictionary
123
- forWritingURL: writingURL
124
- error: &error];
125
- }];
112
+ [self .fileCoordinator coordinateReadingItemAtURL: self .fileURL
113
+ options: 0
114
+ writingItemAtURL: self .fileURL
115
+ options: 0
116
+ error: &error
117
+ byAccessor: ^( NSURL *readingURL, NSURL *writingURL) {
118
+ NSMutableDictionary *dictionary =
119
+ [self heartbeatDictionaryWithFileURL: readingURL];
120
+ dictionary[tag] = date;
121
+ NSError *error;
122
+ isSuccess = [self writeDictionary: dictionary
123
+ forWritingURL: writingURL
124
+ error: &error];
125
+ }];
126
126
return isSuccess;
127
127
}
128
128
0 commit comments