mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: multi process
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:toolbox/data/model/app/error.dart';
|
||||
@@ -120,6 +121,6 @@ Future<SSHClient> genClient(
|
||||
return SSHClient(
|
||||
socket,
|
||||
username: spi.user,
|
||||
identities: await compute(loadIndentity, privateKey),
|
||||
identities: await Computer.shared.start(loadIndentity, privateKey),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:icloud_storage/icloud_storage.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/data/model/app/backup.dart';
|
||||
@@ -204,7 +204,7 @@ abstract final class ICloud {
|
||||
return;
|
||||
}
|
||||
final dlFile = await File(await Paths.bak).readAsString();
|
||||
final dlBak = await compute(Backup.fromJsonString, dlFile);
|
||||
final dlBak = await Computer.shared.start(Backup.fromJsonString, dlFile);
|
||||
final restore = await dlBak.restore();
|
||||
switch (restore) {
|
||||
case true:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/data/model/app/backup.dart';
|
||||
import 'package:toolbox/data/model/app/error.dart';
|
||||
@@ -101,7 +101,7 @@ abstract final class Webdav {
|
||||
await backup();
|
||||
return;
|
||||
}
|
||||
final dlFile = await compute(
|
||||
final dlFile = await Computer.shared.start(
|
||||
(message) async {
|
||||
try {
|
||||
final file = await File(message).readAsString();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/utils/platform/path.dart';
|
||||
import 'package:toolbox/data/model/app/shell_func.dart';
|
||||
@@ -378,7 +378,7 @@ class ServerProvider extends ChangeNotifier {
|
||||
segments: segments,
|
||||
system: systemType,
|
||||
);
|
||||
s.status = await compute(getStatus, req);
|
||||
s.status = await Computer.shared.start(getStatus, req);
|
||||
} catch (e, trace) {
|
||||
TryLimiter.inc(sid);
|
||||
s.status.err = 'Parse failed: $e\n\n$raw';
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:toolbox/core/build_mode.dart';
|
||||
import 'package:toolbox/core/channel/bg_run.dart';
|
||||
import 'package:toolbox/core/utils/sync/icloud.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
@@ -77,6 +79,11 @@ Future<void> _initApp() async {
|
||||
// Base of all data.
|
||||
await _initDb();
|
||||
await setupLocator();
|
||||
Computer.shared.turnOn(
|
||||
// Plus 1 to avoid 0.
|
||||
workersCount: (Stores.server.box.keys.length / 3).round() + 1,
|
||||
verbose: !BuildMode.isRelease,
|
||||
);
|
||||
_setupLogger();
|
||||
_setupProviders();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
@@ -206,7 +206,7 @@ class BackupPage extends StatelessWidget {
|
||||
|
||||
try {
|
||||
context.showLoadingDialog();
|
||||
final backup = await compute(Backup.fromJsonString, text.trim());
|
||||
final backup = await Computer.shared.start(Backup.fromJsonString, text.trim());
|
||||
if (backupFormatVersion != backup.version) {
|
||||
context.showSnackBar(l10n.backupVersionNotMatch);
|
||||
return;
|
||||
@@ -283,7 +283,7 @@ class BackupPage extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
final dlFile = await File(fileName).readAsString();
|
||||
final dlBak = await compute(Backup.fromJsonString, dlFile);
|
||||
final dlBak = await Computer.shared.start(Backup.fromJsonString, dlFile);
|
||||
await dlBak.restore(force: true);
|
||||
webdavLoading.value = false;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:code_text_field/code_text_field.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_highlight/theme_map.dart';
|
||||
import 'package:flutter_highlight/themes/a11y-light.dart';
|
||||
@@ -76,7 +76,7 @@ class _EditorPageState extends State<EditorPage> {
|
||||
|
||||
Future<void> _setupCtrl() async {
|
||||
if (widget.path != null) {
|
||||
final code = await compute(
|
||||
final code = await Computer.shared.start(
|
||||
(path) async => await File(path).readAsString(),
|
||||
widget.path!,
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
@@ -134,7 +134,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
_loading = UIs.centerSizedLoading;
|
||||
});
|
||||
try {
|
||||
final decrypted = await compute(decyptPem, [key, pwd]);
|
||||
final decrypted = await Computer.shared.start(decyptPem, [key, pwd]);
|
||||
final pki = PrivateKeyInfo(id: name, key: decrypted);
|
||||
if (widget.pki != null) {
|
||||
Pros.key.update(widget.pki!, pki);
|
||||
|
||||
@@ -202,6 +202,15 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.18.0"
|
||||
computer:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: b0819c8a939e1fa6858f1a0e12ee8122db0df390
|
||||
url: "https://github.com/lollipopkit/dart_computer"
|
||||
source: git
|
||||
version: "3.2.1"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -67,6 +67,10 @@ dependencies:
|
||||
window_manager: ^0.3.7
|
||||
flutter_displaymode: ^0.6.0
|
||||
flutter_markdown: ^0.6.18+2
|
||||
computer:
|
||||
git:
|
||||
ref: master
|
||||
url: https://github.com/lollipopkit/dart_computer
|
||||
|
||||
dev_dependencies:
|
||||
flutter_native_splash: ^2.1.6
|
||||
|
||||
Reference in New Issue
Block a user