mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-21 16:11:56 +00:00
47 lines
1.4 KiB
Dart
47 lines
1.4 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:appflowy_backend/appflowy_backend.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:path/path.dart' as path;
|
|
|
|
import '../startup.dart';
|
|
|
|
class InitRustSDKTask extends LaunchTask {
|
|
const InitRustSDKTask({
|
|
this.directory,
|
|
});
|
|
|
|
// Customize the RustSDK initialization path
|
|
final Future<Directory>? directory;
|
|
|
|
@override
|
|
LaunchTaskType get type => LaunchTaskType.dataProcessing;
|
|
|
|
@override
|
|
Future<void> initialize(LaunchContext context) async {
|
|
// use the custom directory
|
|
if (directory != null) {
|
|
return directory!.then((directory) async {
|
|
await context.getIt<FlowySDK>().init(directory);
|
|
});
|
|
} else {
|
|
return appFlowyDocumentDirectory().then((directory) async {
|
|
await context.getIt<FlowySDK>().init(directory);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
Future<Directory> appFlowyDocumentDirectory() async {
|
|
switch (integrationEnv()) {
|
|
case IntegrationMode.develop:
|
|
Directory documentsDir = await getApplicationDocumentsDirectory();
|
|
return Directory(path.join(documentsDir.path, 'data_dev')).create();
|
|
case IntegrationMode.release:
|
|
Directory documentsDir = await getApplicationDocumentsDirectory();
|
|
return Directory(path.join(documentsDir.path, 'data')).create();
|
|
case IntegrationMode.test:
|
|
return Directory(path.join(Directory.current.path, '.sandbox'));
|
|
}
|
|
}
|