mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-22 00:17:49 +00:00

* chore: reload folder * chore: reload folder * chore: init sync * chore: update tables * chore: update database * chore: load row * chore: update * chore: reload row * test: fit test * chore: retry * chore: support batch fetch * chore: enable sync * chore: sync switch * chore: sync switch * chore: migration user data * chore: migrate data * chore: migrate folder * chore: save user email * chore: refresh user profile * chore: fix test * chore: delete translation files * test: clippy format
69 lines
2.0 KiB
Dart
69 lines
2.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:appflowy/env/env.dart';
|
|
import 'package:appflowy_backend/appflowy_backend.dart';
|
|
import 'package:appflowy_backend/env_serde.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 Directory? directory;
|
|
|
|
@override
|
|
LaunchTaskType get type => LaunchTaskType.dataProcessing;
|
|
|
|
@override
|
|
Future<void> initialize(LaunchContext context) async {
|
|
final dir = directory ?? await appFlowyApplicationDataDirectory();
|
|
|
|
final env = getAppFlowyEnv();
|
|
context.getIt<FlowySDK>().setEnv(env);
|
|
await context.getIt<FlowySDK>().init(dir);
|
|
}
|
|
}
|
|
|
|
AppFlowyEnv getAppFlowyEnv() {
|
|
final postgresConfig = PostgresConfiguration(
|
|
url: Env.supabaseDb,
|
|
password: Env.supabaseDbPassword,
|
|
port: int.parse(Env.supabaseDbPort),
|
|
user_name: Env.supabaseDbUser,
|
|
);
|
|
|
|
final supabaseConfig = SupabaseConfiguration(
|
|
enable_sync: Env.enableSupabaseSync,
|
|
url: Env.supabaseUrl,
|
|
key: Env.supabaseKey,
|
|
jwt_secret: Env.supabaseJwtSecret,
|
|
postgres_config: postgresConfig,
|
|
);
|
|
|
|
return AppFlowyEnv(
|
|
supabase_config: supabaseConfig,
|
|
);
|
|
}
|
|
|
|
/// The default directory to store the user data. The directory can be
|
|
/// customized by the user via the [ApplicationDataStorage]
|
|
Future<Directory> appFlowyApplicationDataDirectory() async {
|
|
switch (integrationEnv()) {
|
|
case IntegrationMode.develop:
|
|
final Directory documentsDir = await getApplicationSupportDirectory()
|
|
..create();
|
|
return Directory(path.join(documentsDir.path, 'data_dev')).create();
|
|
case IntegrationMode.release:
|
|
final Directory documentsDir = await getApplicationSupportDirectory();
|
|
return Directory(path.join(documentsDir.path, 'data')).create();
|
|
case IntegrationMode.unitTest:
|
|
case IntegrationMode.integrationTest:
|
|
return Directory(path.join(Directory.current.path, '.sandbox'));
|
|
}
|
|
}
|