Skip to content

Commit

Permalink
fix(database): write to LunaSea parent folder on Linux and Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JagandeepBrar committed Apr 4, 2022
1 parent 8f3a7ab commit 6e89796
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"SABnzbd",
"scrollview",
"sksl",
"snapcraft",
"Sonarr",
"stickied",
"subheaders",
Expand Down
16 changes: 13 additions & 3 deletions lib/core/database/database.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:lunasea/core.dart';
export 'package:hive_flutter/hive_flutter.dart';

import '../system/platform.dart';

class Database {
static const String _DATABASE_PATH = 'database';
static const String _DATABASE_LEGACY_PATH = 'database';
static const String _DATABASE_PATH = 'LunaSea/database';

static late _BoxManager alerts;
static late _BoxManager<ExternalModuleHiveObject> externalModules;
Expand All @@ -11,8 +13,16 @@ class Database {
static late _BoxManager lunasea;
static late _BoxManager<ProfileHiveObject> profiles;

String get _databasePath {
final platform = LunaPlatform();
if (platform.isWindows || platform.isLinux)
return _DATABASE_PATH;
else
return _DATABASE_LEGACY_PATH;
}

Future<void> initialize() async {
await Hive.initFlutter(_DATABASE_PATH);
await Hive.initFlutter(_databasePath);

LunaDatabase().registerAdapters();
LunaModule.values.forEach((module) => module.database?.registerAdapters());
Expand Down
1 change: 1 addition & 0 deletions lib/modules/dashboard/core/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../../../core/database/database.dart';
import '../../../core/database/module_database.dart';
import '../../../core/utilities/logger.dart';
import '../../../vendor.dart';
import 'adapters/calendar_starting_day.dart';
import 'adapters/calendar_starting_size.dart';
import 'adapters/calendar_starting_type.dart';
Expand Down

0 comments on commit 6e89796

Please sign in to comment.