Fix order of operations in SAE setup.

pull/1/head
Matthew Chen 8 years ago
parent 03d1165947
commit 791743a5f0

@ -55,12 +55,14 @@ NS_ASSUME_NONNULL_BEGIN
sharedDataFilePath:(NSString *)newFilePath sharedDataFilePath:(NSString *)newFilePath
exceptionName:(NSString *)exceptionName exceptionName:(NSString *)exceptionName
{ {
DDLogInfo(@"%@ Moving file or directory from: %@ to: %@", self.logTag, oldFilePath, newFilePath);
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:oldFilePath]) { if (![fileManager fileExistsAtPath:oldFilePath]) {
return; return;
} }
if ([fileManager fileExistsAtPath:newFilePath]) { if ([fileManager fileExistsAtPath:newFilePath]) {
OWSFail(@"%@ Can't move file or directory from %@ to %@; destination already exists.", OWSFail(@"%@ Can't move file or directory from: %@ to: %@; destination already exists.",
self.logTag, self.logTag,
oldFilePath, oldFilePath,
newFilePath); newFilePath);
@ -73,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN
BOOL success = [fileManager moveItemAtPath:oldFilePath toPath:newFilePath error:&error]; BOOL success = [fileManager moveItemAtPath:oldFilePath toPath:newFilePath error:&error];
if (!success || error) { if (!success || error) {
NSString *errorDescription = NSString *errorDescription =
[NSString stringWithFormat:@"%@ Could not move file or directory from %@ to %@, error: %@", [NSString stringWithFormat:@"%@ Could not move file or directory from: %@ to: %@, error: %@",
self.logTag, self.logTag,
oldFilePath, oldFilePath,
newFilePath, newFilePath,
@ -81,12 +83,12 @@ NS_ASSUME_NONNULL_BEGIN
OWSFail(@"%@", errorDescription); OWSFail(@"%@", errorDescription);
[NSException raise:exceptionName format:@"%@", errorDescription]; [NSException raise:exceptionName format:@"%@", errorDescription];
} }
DDLogInfo(@"%@ Moving file or directory from %@ to %@ in: %f", DDLogInfo(@"%@ Moved file or directory from: %@ to: %@ in: %f",
self.logTag, self.logTag,
oldFilePath, oldFilePath,
newFilePath, newFilePath,
fabs([startDate timeIntervalSinceNow])); fabs([startDate timeIntervalSinceNow]));
} }
+ (BOOL)ensureDirectoryExists:(NSString *)dirPath + (BOOL)ensureDirectoryExists:(NSString *)dirPath
@ -98,6 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
return YES; return YES;
} else { } else {
DDLogInfo(@"%@ Creating directory at: %@", self.logTag, dirPath);
NSError *error = nil; NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:dirPath [[NSFileManager defaultManager] createDirectoryAtPath:dirPath
withIntermediateDirectories:YES withIntermediateDirectories:YES

@ -39,12 +39,6 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
// We don't need to use DeviceSleepManager in the SAE. // We don't need to use DeviceSleepManager in the SAE.
AppSetup.setupEnvironment({
return NoopCallMessageHandler()
}) {
return NoopNotificationsManager()
}
// TODO: // TODO:
// [UIUtil applySignalAppearence]; // [UIUtil applySignalAppearence];
@ -71,6 +65,12 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
return return
} }
AppSetup.setupEnvironment({
return NoopCallMessageHandler()
}) {
return NoopNotificationsManager()
}
// performUpdateCheck must be invoked after Environment has been initialized because // performUpdateCheck must be invoked after Environment has been initialized because
// upgrade process may depend on Environment. // upgrade process may depend on Environment.
VersionMigrations.performUpdateCheck() VersionMigrations.performUpdateCheck()

Loading…
Cancel
Save