2024-05-08 05:03:49 -04:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
2024-10-03 05:54:29 -04:00
|
|
|
import 'package:vaani/main.dart';
|
2024-08-23 04:21:46 -04:00
|
|
|
import 'package:vaani/settings/constants.dart';
|
2024-05-08 05:03:49 -04:00
|
|
|
|
|
|
|
|
import 'register_models.dart';
|
|
|
|
|
|
2024-10-03 05:54:29 -04:00
|
|
|
// does the initial setup of the storage
|
2024-05-08 05:03:49 -04:00
|
|
|
Future initStorage() async {
|
|
|
|
|
final dir = await getApplicationDocumentsDirectory();
|
|
|
|
|
|
2024-08-23 04:21:46 -04:00
|
|
|
// use vaani as the directory for hive
|
2024-10-03 05:54:29 -04:00
|
|
|
final storageDir = Directory(
|
|
|
|
|
p.join(
|
|
|
|
|
dir.path,
|
2024-05-12 05:38:30 -04:00
|
|
|
AppMetadata.appNameLowerCase,
|
2024-05-08 05:03:49 -04:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await storageDir.create(recursive: true);
|
|
|
|
|
|
|
|
|
|
Hive.defaultDirectory = storageDir.path;
|
2024-10-03 05:54:29 -04:00
|
|
|
appLogger.config('Hive storage directory init: ${Hive.defaultDirectory}');
|
2024-05-08 05:03:49 -04:00
|
|
|
|
|
|
|
|
await registerModels();
|
|
|
|
|
}
|