mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-25 01:50:56 +00:00

* chore: move to latest appflowy collab version * chore: filter mapping * chore: remove mutex folder * chore: cleanup borrow checker issues * chore: fixed flowy user crate compilation errors * chore: removed parking lot crate * chore: adjusting non locking approach * chore: remove with folder method * chore: fix folder manager * chore: fixed workspace database compilation errors * chore: initialize database plugins * chore: fix locks in flowy core * chore: remove supabase * chore: async traits * chore: add mutexes in dart ffi * chore: post rebase fixes * chore: remove supabase dart code * chore: fix deadlock * chore: fix page_id is empty * chore: use data source to init collab * chore: fix user awareness test * chore: fix database deadlock * fix: initialize user awareness * chore: fix open workspace test * chore: fix import csv * chore: fix update row meta deadlock * chore: fix document size test * fix: timestamp set/get type convert * fix: calculation * chore: revert Arc to Rc * chore: attach plugin to database and database row * chore: async get row * chore: clippy * chore: fix tauri build * chore: clippy * fix: duplicate view deadlock * chore: fmt * chore: tauri build --------- Co-authored-by: nathan <nathan@appflowy.io>
87 lines
2.7 KiB
Dart
87 lines
2.7 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:appflowy/env/backend_env.dart';
|
|
import 'package:appflowy/env/cloud_env.dart';
|
|
import 'package:appflowy/user/application/auth/device_id.dart';
|
|
import 'package:appflowy_backend/appflowy_backend.dart';
|
|
import 'package:flutter/foundation.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.customApplicationPath,
|
|
});
|
|
|
|
// Customize the RustSDK initialization path
|
|
final Directory? customApplicationPath;
|
|
|
|
@override
|
|
LaunchTaskType get type => LaunchTaskType.dataProcessing;
|
|
|
|
@override
|
|
Future<void> initialize(LaunchContext context) async {
|
|
final root = await getApplicationSupportDirectory();
|
|
final applicationPath = await appFlowyApplicationDataDirectory();
|
|
final dir = customApplicationPath ?? applicationPath;
|
|
final deviceId = await getDeviceId();
|
|
|
|
debugPrint('application path: ${applicationPath.path}');
|
|
// Pass the environment variables to the Rust SDK
|
|
final env = _makeAppFlowyConfiguration(
|
|
root.path,
|
|
context.config.version,
|
|
dir.path,
|
|
applicationPath.path,
|
|
deviceId,
|
|
rustEnvs: context.config.rustEnvs,
|
|
);
|
|
await context.getIt<FlowySDK>().init(jsonEncode(env.toJson()));
|
|
}
|
|
|
|
@override
|
|
Future<void> dispose() async {}
|
|
}
|
|
|
|
AppFlowyConfiguration _makeAppFlowyConfiguration(
|
|
String root,
|
|
String appVersion,
|
|
String customAppPath,
|
|
String originAppPath,
|
|
String deviceId, {
|
|
required Map<String, String> rustEnvs,
|
|
}) {
|
|
final env = getIt<AppFlowyCloudSharedEnv>();
|
|
return AppFlowyConfiguration(
|
|
root: root,
|
|
app_version: appVersion,
|
|
custom_app_path: customAppPath,
|
|
origin_app_path: originAppPath,
|
|
device_id: deviceId,
|
|
platform: Platform.operatingSystem,
|
|
authenticator_type: env.authenticatorType.value,
|
|
appflowy_cloud_config: env.appflowyCloudConfig,
|
|
envs: rustEnvs,
|
|
);
|
|
}
|
|
|
|
/// The default directory to store the user data. The directory can be
|
|
/// customized by the user via the [ApplicationDataStorage]
|
|
Future<Directory> appFlowyApplicationDataDirectory() async {
|
|
switch (integrationMode()) {
|
|
case IntegrationMode.develop:
|
|
final Directory documentsDir = await getApplicationSupportDirectory()
|
|
.then((directory) => directory.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'));
|
|
}
|
|
}
|