mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: NAS disk amount
This commit is contained in:
@@ -41,7 +41,8 @@ class Disk {
|
||||
}
|
||||
try {
|
||||
final dev = vals[0];
|
||||
if (!dev.startsWith('/dev')) continue;
|
||||
// Some NAS may have mounted path like this `//192.168.1.2/`
|
||||
if (!_shouldCalc(dev)) continue;
|
||||
list.add(Disk(
|
||||
dev: dev,
|
||||
mount: vals[5],
|
||||
@@ -161,7 +162,7 @@ class DiskUsage {
|
||||
var used = BigInt.zero;
|
||||
var size = BigInt.zero;
|
||||
for (var disk in disks) {
|
||||
if (!disk.dev.startsWith('/dev')) continue;
|
||||
if (!_shouldCalc(disk.dev)) continue;
|
||||
if (devs.contains(disk.dev)) continue;
|
||||
devs.add(disk.dev);
|
||||
used += disk.used;
|
||||
@@ -170,3 +171,9 @@ class DiskUsage {
|
||||
return DiskUsage(used: used, size: size);
|
||||
}
|
||||
}
|
||||
|
||||
bool _shouldCalc(String dev) {
|
||||
if (dev.startsWith('/dev')) return true;
|
||||
if (dev.startsWith('//')) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,20 +48,31 @@ class ServerPrivateInfo {
|
||||
this.jumpId,
|
||||
}) : id = '$user@$ip:$port';
|
||||
|
||||
ServerPrivateInfo.fromJson(Map<String, dynamic> json)
|
||||
: ip = json["ip"].toString(),
|
||||
port = json["port"] ?? 22,
|
||||
user = json["user"]?.toString() ?? 'root',
|
||||
id =
|
||||
'${json["user"]?.toString() ?? "root"}@${json["ip"].toString()}:${json["port"] ?? 22}',
|
||||
name = json["name"]?.toString() ??
|
||||
'${json["user"]?.toString() ?? 'root'}@${json["ip"].toString()}:${json["port"] ?? 22}',
|
||||
pwd = json["authorization"]?.toString(),
|
||||
keyId = json["pubKeyId"]?.toString(),
|
||||
tags = json["tags"]?.cast<String>(),
|
||||
alterUrl = json["alterUrl"]?.toString(),
|
||||
autoConnect = json["autoConnect"],
|
||||
jumpId = json["jumpId"];
|
||||
static ServerPrivateInfo fromJson(Map<String, dynamic> json) {
|
||||
final ip = json["ip"] as String? ?? '';
|
||||
final port = json["port"] as int? ?? 22;
|
||||
final user = json["user"] as String? ?? 'root';
|
||||
final name = json["name"] as String? ?? '';
|
||||
final pwd = json["authorization"] as String?;
|
||||
final keyId = json["pubKeyId"] as String?;
|
||||
final tags = (json["tags"] as List?)?.cast<String>();
|
||||
final alterUrl = json["alterUrl"] as String?;
|
||||
final autoConnect = json["autoConnect"] as bool?;
|
||||
final jumpId = json["jumpId"] as String?;
|
||||
|
||||
return ServerPrivateInfo(
|
||||
name: name,
|
||||
ip: ip,
|
||||
port: port,
|
||||
user: user,
|
||||
pwd: pwd,
|
||||
keyId: keyId,
|
||||
tags: tags,
|
||||
alterUrl: alterUrl,
|
||||
autoConnect: autoConnect,
|
||||
jumpId: jumpId,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
|
||||
Reference in New Issue
Block a user