fix: constantly write script by sftp

This commit is contained in:
lollipopkit
2023-10-27 22:13:45 +08:00
parent 92bb653e81
commit c3ca5725a4
9 changed files with 37 additions and 41 deletions

View File

@@ -3,7 +3,6 @@ import 'package:plain_notification_token/plain_notification_token.dart';
import 'package:toolbox/core/utils/platform/base.dart';
import 'package:toolbox/data/res/provider.dart';
Future<String?> pickOneFile() async {
Pros.app.moveBg = false;
final result = await FilePicker.platform.pickFiles(type: FileType.any);

View File

@@ -10,7 +10,7 @@ class Server implements TagPickable {
SSHClient? client;
ServerState state;
/// Whether is generating client.
/// Whether is generating client.
/// Use this to avoid reconnecting if last connect try not finished.
bool isGenerating = false;

View File

@@ -78,14 +78,12 @@ class SftpReqStatus {
case int:
size = event;
break;
case Exception:
error = event;
break;
case Duration:
spentTime = event;
break;
default:
error = Exception('unknown event: $event');
error = Exception('sftp worker event: $event');
dispose();
}
notifyListeners();
}

View File

@@ -267,7 +267,7 @@ class ServerProvider extends ChangeNotifier {
final time1 = DateTime.now();
try {
try {
if (s.isGenerating) return;
s.isGenerating = true;
s.client = await genClient(
@@ -323,6 +323,7 @@ class ServerProvider extends ChangeNotifier {
s.status.failedInfo = e.toString();
_setServerState(s, ServerState.failed);
Loggers.app.warning('Write script to ${spi.name} failed', e);
return;
} finally {
await file.delete();
}

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 607;
static const String engine = "3.13.7";
static const String buildAt = "2023-10-22 14:20:27";
static const int modifications = 4;
static const int build = 611;
static const String engine = "3.13.8";
static const String buildAt = "2023-10-27 20:42:26";
static const int modifications = 7;
static const int script = 22;
}

View File

@@ -4,4 +4,4 @@ class RebuildNodes {
const RebuildNodes._();
static final app = RebuildNode();
}
}

View File

@@ -208,11 +208,9 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
if (!Stores.setting.recordHistory.fetch()) {
return [];
}
return List<String>.from(
Stores.history.sftpGoPath.all.where(
(element) => element.contains(val.text),
),
);
return Stores.history.sftpGoPath.all.cast<String>().where(
(element) => element.contains(val.text),
);
},
fieldViewBuilder: (_, controller, node, __) {
return Input(