Page MenuHomePhabricator

D4180.diff
No OneTemporary

D4180.diff

diff --git a/native/ios/Comm/AppDelegate.mm b/native/ios/Comm/AppDelegate.mm
--- a/native/ios/Comm/AppDelegate.mm
+++ b/native/ios/Comm/AppDelegate.mm
@@ -234,22 +234,18 @@
- (void)attemptDatabaseInitialization {
std::string sqliteFilePath =
std::string([[Tools getSQLiteFilePath] UTF8String]);
-
- // Previous versions of Comm app used to keep SQLite database at location
- // that was specific to the app. Now that we share SQLite database with
- // NotificationService extension we need to keep the database in place
- // defined by App Groups. The code below is a migration fired if user
- // upgrades from version using app-specific path to newer that uses
- // App Groups.
- NSString *appSpecificSQLiteFilePath = [Tools getAppSpecificSQLiteFilePath];
- if ([NSFileManager.defaultManager
- fileExistsAtPath:appSpecificSQLiteFilePath] &&
+ // Previous Comm versions used app group location for SQLite
+ // database, so that NotificationService was able to acces it directly.
+ // Unfortunately it caused errores related to system locks. The code
+ // below re-migrates SQLite from app group to app specific location
+ // on devices where previous Comm version was installed.
+ NSString *appGroupSQLiteFilePath = [Tools getAppGroupSQLiteFilePath];
+ if ([NSFileManager.defaultManager fileExistsAtPath:appGroupSQLiteFilePath] &&
std::rename(
- std::string([appSpecificSQLiteFilePath UTF8String]).c_str(),
+ std::string([appGroupSQLiteFilePath UTF8String]).c_str(),
sqliteFilePath.c_str())) {
throw std::runtime_error(
- "Failed to move SQLite database from app-specific to app group "
- "location");
+ "Failed to move SQLite database from app group to default location");
}
comm::SQLiteQueryExecutor::initialize(sqliteFilePath);
}
diff --git a/native/ios/Comm/Tools.h b/native/ios/Comm/Tools.h
--- a/native/ios/Comm/Tools.h
+++ b/native/ios/Comm/Tools.h
@@ -3,6 +3,6 @@
#import <UIKit/UIKit.h>
@interface Tools : NSObject
-+ (NSString *)getAppSpecificSQLiteFilePath;
+ (NSString *)getSQLiteFilePath;
++ (NSString *)getAppGroupSQLiteFilePath;
@end
diff --git a/native/ios/Comm/Tools.mm b/native/ios/Comm/Tools.mm
--- a/native/ios/Comm/Tools.mm
+++ b/native/ios/Comm/Tools.mm
@@ -5,16 +5,6 @@
@implementation Tools
+ (NSString *)getSQLiteFilePath {
- NSURL *groupUrl = [NSFileManager.defaultManager
- containerURLForSecurityApplicationGroupIdentifier:@"group.app.comm"];
- if (groupUrl == nil) {
- throw std::runtime_error(
- "Failed to resolve database path - could not find groupUrl");
- }
- return [groupUrl URLByAppendingPathComponent:@"comm.sqlite"].path;
-}
-
-+ (NSString *)getAppSpecificSQLiteFilePath {
NSError *err = nil;
NSURL *documentsUrl =
[NSFileManager.defaultManager URLForDirectory:NSDocumentDirectory
@@ -32,4 +22,14 @@
return [documentsUrl URLByAppendingPathComponent:@"comm.sqlite"].path;
}
++ (NSString *)getAppGroupSQLiteFilePath {
+ NSURL *groupUrl = [NSFileManager.defaultManager
+ containerURLForSecurityApplicationGroupIdentifier:@"group.app.comm"];
+ if (groupUrl == nil) {
+ throw std::runtime_error(
+ "Failed to resolve database path - could not find groupUrl");
+ }
+ return [groupUrl URLByAppendingPathComponent:@"comm.sqlite"].path;
+}
+
@end

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 6:47 AM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578839
Default Alt Text
D4180.diff (3 KB)

Event Timeline