Skip to content

Commit

Permalink
Merge pull request #1086 from BranchMetrics/SDK-1106-remove-initializ…
Browse files Browse the repository at this point in the history
…e-use

SDK-1106 remove initialize use
  • Loading branch information
echo-branch authored Feb 9, 2021
2 parents f731020 + 52e52d2 commit 96e68df
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 76 deletions.
38 changes: 0 additions & 38 deletions Branch-SDK/BNCPreferenceHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -872,50 +872,12 @@ - (NSInteger)readIntegerFromDefaults:(NSString *)key {

#pragma mark - Preferences File URL

+ (NSString *)prefsFile_deprecated {
NSString * path =
[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
firstObject]
stringByAppendingPathComponent:BRANCH_PREFS_FILE];
return path;
}

+ (NSURL* _Nonnull) URLForPrefsFile {
NSURL *URL = BNCURLForBranchDirectory();
URL = [URL URLByAppendingPathComponent:BRANCH_PREFS_FILE isDirectory:NO];
return URL;
}

+ (void) moveOldPrefsFile {
NSString* oldPath = self.prefsFile_deprecated;
NSURL *oldURL = (oldPath) ? [NSURL fileURLWithPath:self.prefsFile_deprecated] : nil;
NSURL *newURL = [self URLForPrefsFile];

if (!oldURL || !newURL) { return; }

NSError *error = nil;
[[NSFileManager defaultManager]
moveItemAtURL:oldURL
toURL:newURL
error:&error];

if (error && error.code != NSFileNoSuchFileError) {
if (error.code == NSFileWriteFileExistsError) {
[[NSFileManager defaultManager]
removeItemAtURL:oldURL
error:&error];
} else {
BNCLogError([NSString stringWithFormat:@"Can't move prefs file: %@.", error]);
}
}
}

+ (void) initialize {
if (self == [BNCPreferenceHelper self]) {
[self moveOldPrefsFile];
}
}

@end

#pragma mark - BNCURLForBranchDirectory
Expand Down
37 changes: 0 additions & 37 deletions Branch-SDK/BNCServerRequestQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -365,49 +365,12 @@ + (NSString *)exceptionString:(NSException *)exception {
[exception.callStackSymbols componentsJoinedByString:@"\n\t"]];
}

+ (NSString *)queueFile_deprecated {
NSString *path =
[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
firstObject]
stringByAppendingPathComponent:BRANCH_QUEUE_FILE];
return path;
}

+ (NSURL* _Nonnull) URLForQueueFile {
NSURL *URL = BNCURLForBranchDirectory();
URL = [URL URLByAppendingPathComponent:BRANCH_QUEUE_FILE isDirectory:NO];
return URL;
}

+ (void) moveOldQueueFile {
NSURL *oldURL = [NSURL fileURLWithPath:self.queueFile_deprecated];
NSURL *newURL = [self URLForQueueFile];

if (!oldURL || !newURL) { return; }

NSError *error = nil;
[[NSFileManager defaultManager]
moveItemAtURL:oldURL
toURL:newURL
error:&error];

if (error && error.code != NSFileNoSuchFileError) {
if (error.code == NSFileWriteFileExistsError) {
[[NSFileManager defaultManager]
removeItemAtURL:oldURL
error:&error];
} else {
BNCLogError([NSString stringWithFormat:@"Failed to move the queue file: %@.", error]);
}
}
}

+ (void) initialize {
if (self == [BNCServerRequestQueue self]) {
[self moveOldQueueFile];
}
}

#pragma mark - Shared Method

+ (id)getInstance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ - (void)testCollectUserAgent {
[expectation fulfill];
}];

[self waitForExpectationsWithTimeout:2.0 handler:^(NSError * _Nullable error) {
[self waitForExpectationsWithTimeout:4.0 handler:^(NSError * _Nullable error) {

}];
}
Expand Down

0 comments on commit 96e68df

Please sign in to comment.