Signal-iOS/SignalServiceKit/src/Storage/YDBStorage.m
Evan Hahn c5a71adc06 Remove rarely-seen YDB onboarding screen
We used to use [YapDatabase] but [removed it in early 2021][1] after a
[migration to GRDB that started in 2019][2].

If you haven't opened the app since before we dropped YDB--in other
words, since early 2021--you'll see the following text on a screen
before you open the app:

> Because you've been inactive for a long period of time, you must
> register again to use Signal.

Tapping "Next" will send you into the normal registration flow.

I think this is a tiny number of users, so I removed this screen and
associated code. This will help simplify future onboarding code.

[1]: 86b8eb08b8
[2]: 2a5683b843
[YapDatabase]: https://github.com/signalapp/YapDatabase
2023-01-31 10:21:46 -08:00

119 lines
3.4 KiB
Objective-C

//
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
#import "YDBStorage.h"
#import "OWSFileSystem.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
static NSString *keychainService = @"TSKeyChainService";
static NSString *keychainDBLegacyPassphrase = @"TSDatabasePass";
static NSString *keychainDBCipherKeySpec = @"OWSDatabaseCipherKeySpec";
#pragma mark -
@implementation YDBStorage
+ (NSString *)legacyDatabaseDirPath
{
return [OWSFileSystem appDocumentDirectoryPath];
}
+ (NSString *)sharedDataDatabaseDirPath
{
return [[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"database"];
}
+ (NSString *)databaseFilename
{
return @"Signal.sqlite";
}
+ (NSString *)databaseFilename_SHM
{
return [self.databaseFilename stringByAppendingString:@"-shm"];
}
+ (NSString *)databaseFilename_WAL
{
return [self.databaseFilename stringByAppendingString:@"-wal"];
}
+ (NSString *)legacyDatabaseFilePath
{
return [self.legacyDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename];
}
+ (NSString *)legacyDatabaseFilePath_SHM
{
return [self.legacyDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_SHM];
}
+ (NSString *)legacyDatabaseFilePath_WAL
{
return [self.legacyDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_WAL];
}
+ (NSString *)sharedDataDatabaseFilePath
{
return [self.sharedDataDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename];
}
+ (NSString *)sharedDataDatabaseFilePath_SHM
{
return [self.sharedDataDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_SHM];
}
+ (NSString *)sharedDataDatabaseFilePath_WAL
{
return [self.sharedDataDatabaseDirPath stringByAppendingPathComponent:self.databaseFilename_WAL];
}
#pragma mark -
+ (void)deleteYDBStorage
{
[self deleteDatabaseFiles];
[self deleteDBKeys];
}
+ (void)deleteDatabaseFiles
{
[OWSFileSystem deleteFileIfExists:self.legacyDatabaseFilePath];
[OWSFileSystem deleteFileIfExists:self.legacyDatabaseFilePath_SHM];
[OWSFileSystem deleteFileIfExists:self.legacyDatabaseFilePath_WAL];
[OWSFileSystem deleteFileIfExists:self.sharedDataDatabaseFilePath];
[OWSFileSystem deleteFileIfExists:self.sharedDataDatabaseFilePath_SHM];
[OWSFileSystem deleteFileIfExists:self.sharedDataDatabaseFilePath_WAL];
// NOTE: It's NOT safe to delete OWSPrimaryStorage.legacyDatabaseDirPath
// which is the app document dir.
[OWSFileSystem deleteContentsOfDirectory:self.sharedDataDatabaseDirPath];
}
#pragma mark - Keychain
+ (void)deleteDBKeys
{
NSError *_Nullable error;
BOOL result = [CurrentAppContext().keychainStorage removeWithService:keychainService
key:keychainDBLegacyPassphrase
error:&error];
if (error || !result) {
OWSFailDebug(@"could not remove legacy passphrase.");
}
result = [CurrentAppContext().keychainStorage removeWithService:keychainService
key:keychainDBCipherKeySpec
error:&error];
if (error || !result) {
OWSFailDebug(@"could not remove cipher key spec.");
}
}
@end
NS_ASSUME_NONNULL_END