mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: cancel sftp mission
This commit is contained in:
@@ -8,21 +8,8 @@ class SftpProvider extends ProviderBase {
|
||||
final List<SftpReqStatus> _status = [];
|
||||
List<SftpReqStatus> get status => _status;
|
||||
|
||||
Iterable<SftpReqStatus> gets({int? id, String? fileName}) {
|
||||
Iterable<SftpReqStatus> found = [];
|
||||
if (id != null) {
|
||||
found = _status.where((e) => e.id == id);
|
||||
}
|
||||
if (fileName != null) {
|
||||
found = found.where((e) => e.req.localPath.split('/').last == fileName);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
SftpReqStatus? get({int? id, String? name}) {
|
||||
final found = gets(id: id, fileName: name);
|
||||
if (found.isEmpty) return null;
|
||||
return found.first;
|
||||
SftpReqStatus? get(int id) {
|
||||
return _status.singleWhere((element) => element.id == id);
|
||||
}
|
||||
|
||||
void add(SftpReq req, {Completer? completer}) {
|
||||
@@ -32,4 +19,19 @@ class SftpProvider extends ProviderBase {
|
||||
req: req,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (final item in _status) {
|
||||
item.worker.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void cancel(int id) {
|
||||
final idx = _status.indexWhere((element) => element.id == id);
|
||||
_status[idx].worker.dispose();
|
||||
_status.removeAt(idx);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user