mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
fix: termux compatibility (#495)
This commit is contained in:
@@ -23,6 +23,7 @@ enum ShellFunc {
|
||||
static const scriptPath = '$scriptDir/$scriptFile';
|
||||
|
||||
static const String installShellCmd = """
|
||||
mkdir -p $scriptDir
|
||||
cat > $scriptPath
|
||||
chmod 744 $scriptPath
|
||||
""";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/data/model/server/time_seq.dart';
|
||||
import 'package:server_box/data/res/status.dart';
|
||||
|
||||
@@ -26,10 +25,16 @@ class Cpus extends TimeSeq<List<SingleCpuCore>> {
|
||||
|
||||
double usedPercent({int coreIdx = 0}) {
|
||||
if (now.length != pre.length) return 0;
|
||||
final idleDelta = now[coreIdx].idle - pre[coreIdx].idle;
|
||||
final totalDelta = now[coreIdx].total - pre[coreIdx].total;
|
||||
final used = idleDelta / totalDelta;
|
||||
return used.isNaN ? 0 : 100 - used * 100;
|
||||
if (now.isEmpty) return 0;
|
||||
try {
|
||||
final idleDelta = now[coreIdx].idle - pre[coreIdx].idle;
|
||||
final totalDelta = now[coreIdx].total - pre[coreIdx].total;
|
||||
final used = idleDelta / totalDelta;
|
||||
return used.isNaN ? 0 : 100 - used * 100;
|
||||
} catch (e, s) {
|
||||
Loggers.app.warning('Cpus.usedPercent()', e, s);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int _coresCount = 0;
|
||||
|
||||
@@ -316,7 +316,7 @@ class ServerProvider extends ChangeNotifier {
|
||||
final scriptRaw = ShellFunc.allScript(spi.custom?.cmds).uint8List;
|
||||
|
||||
try {
|
||||
await s.client?.runForOutput(
|
||||
await s.client!.runForOutput(
|
||||
ShellFunc.installShellCmd,
|
||||
action: (session) async {
|
||||
session.stdin.add(scriptRaw);
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 1030;
|
||||
static const int build = 1032;
|
||||
static const int script = 54;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ abstract final class GithubIds {
|
||||
'liwenjie119',
|
||||
'logce',
|
||||
'h-lyf',
|
||||
'88484396',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user