Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Vienna/Sources/Application/AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ - (void)installScriptsFolderWatcher {
-(void)applicationDidFinishLaunching:(NSNotification *)aNot
{
// Initialize the database
if ((db = [Database sharedManager]) == nil) {
db = Database.sharedManager;
if (!db || ![db loadDatabaseStore]) {
[NSApp terminate:nil];
return;
}
Expand Down Expand Up @@ -954,7 +955,7 @@ -(void)initSortMenu
NSMenu * sortSubmenu = [NSMenu new];

// Add the fields which are sortable to the menu.
for (Field * field in [db arrayOfFields]) {
for (Field *field in db.fields) {
if (field.customizationOptions & VNAFieldCustomizationSorting) {
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:field.displayName
action:@selector(changeSortColumn:)
Expand Down Expand Up @@ -985,7 +986,7 @@ -(void)initSortMenu
-(void)initColumnsMenu
{
NSMenu * columnsSubMenu = [NSMenu new];
for (Field * field in [db arrayOfFields]) {
for (Field *field in db.fields) {
if (field.customizationOptions & VNAFieldCustomizationVisibility) {
NSMenuItem *menuItem =
[[NSMenuItem alloc] initWithTitle:field.displayName
Expand Down
19 changes: 17 additions & 2 deletions Vienna/Sources/Database/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ extern NSNotificationName const VNADatabaseDidDeleteFolderNotification;

@property (class, readonly, nonatomic) Database *sharedManager NS_SWIFT_NAME(shared);

/**
Loads the database store.

This method performs these operations in order:
1. Retrieve and create if necessary the database path.
2. Load the database queue and ask if necessary to relocate the database.
3. Perform a SQLite3 `quick_check` and alert if issues are found.
4. Depending on the database version:
- perform a database migration,
- alert that the database is too old or
- set up an initial database.
@return `YES` if the database is loaded and has the current version or `NO`
if any of the operations failed.
*/
- (BOOL)loadDatabaseStore;

@property(nonatomic) Folder * trashFolder;
@property(nonatomic) Folder * searchFolder;
@property (copy, nonatomic) NSString *searchString;
Expand All @@ -55,8 +71,7 @@ extern NSNotificationName const VNADatabaseDidDeleteFolderNotification;
-(void)close;

// Fields functions
-(void)addField:(NSString *)name type:(NSInteger)type sqlField:(NSString *)sqlField visible:(BOOL)visible width:(NSInteger)width;
-(NSArray *)arrayOfFields;
@property (readonly, nonatomic) NSArray<Field *> *fields;
-(Field *)fieldByName:(NSString *)name;

// Folder functions
Expand Down
Loading