mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
#25 fix sftp rm
This commit is contained in:
@@ -18,6 +18,7 @@ import '../../../data/provider/sftp_download.dart';
|
|||||||
import '../../../data/res/path.dart';
|
import '../../../data/res/path.dart';
|
||||||
import '../../../data/store/private_key.dart';
|
import '../../../data/store/private_key.dart';
|
||||||
import '../../../locator.dart';
|
import '../../../locator.dart';
|
||||||
|
import '../../widget/center_loading.dart';
|
||||||
import '../../widget/fade_in.dart';
|
import '../../widget/fade_in.dart';
|
||||||
import '../../widget/two_line_text.dart';
|
import '../../widget/two_line_text.dart';
|
||||||
import 'downloading.dart';
|
import 'downloading.dart';
|
||||||
@@ -299,9 +300,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
final prePath = _status.path!.path;
|
final remotePath = _getRemotePath(name);
|
||||||
final remotePath =
|
|
||||||
prePath + (prePath.endsWith('/') ? '' : '/') + name.filename;
|
|
||||||
final local = '${(await sftpDir).path}$remotePath';
|
final local = '${(await sftpDir).path}$remotePath';
|
||||||
final pubKeyId = widget.spi.pubKeyId;
|
final pubKeyId = widget.spi.pubKeyId;
|
||||||
|
|
||||||
@@ -330,7 +329,8 @@ class _SFTPPageState extends State<SFTPPage> {
|
|||||||
showRoundDialog(
|
showRoundDialog(
|
||||||
context,
|
context,
|
||||||
_s.attention,
|
_s.attention,
|
||||||
Text('${_s.sureDelete(file.filename)}\n${isDir ? _s.sureDirEmpty : ''}'),
|
Text(
|
||||||
|
'${_s.sureDelete(file.filename)}${isDir ? '\n${_s.sureDirEmpty}' : ''}'),
|
||||||
[
|
[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
@@ -338,12 +338,32 @@ class _SFTPPageState extends State<SFTPPage> {
|
|||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
showRoundDialog(context, 'Waiting...', centerSizedLoading, [],
|
||||||
|
barrierDismiss: false);
|
||||||
|
final remotePath = _getRemotePath(file);
|
||||||
|
try {
|
||||||
if (file.attr.isDirectory) {
|
if (file.attr.isDirectory) {
|
||||||
await _status.client!.rmdir(file.filename);
|
await _status.client!.rmdir(remotePath);
|
||||||
} else {
|
} else {
|
||||||
await _status.client!.remove(file.filename);
|
await _status.client!.remove(remotePath);
|
||||||
}
|
}
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
} catch (e) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
showRoundDialog(
|
||||||
|
context,
|
||||||
|
_s.attention,
|
||||||
|
Text(e.toString()),
|
||||||
|
[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: Text(_s.ok),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
listDir();
|
listDir();
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -495,6 +515,11 @@ class _SFTPPageState extends State<SFTPPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getRemotePath(SftpName name) {
|
||||||
|
final prePath = _status.path!.path;
|
||||||
|
return prePath + (prePath.endsWith('/') ? '' : '/') + name.filename;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> listDir({String? path, SSHClient? client}) async {
|
Future<void> listDir({String? path, SSHClient? client}) async {
|
||||||
if (_status.isBusy) {
|
if (_status.isBusy) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user