opt.: container asks pwd repeatly

This commit is contained in:
lollipopkit
2024-03-08 02:14:06 -06:00
parent 2ddc29f45e
commit 519ca23556
2 changed files with 8 additions and 5 deletions

View File

@@ -70,13 +70,16 @@ class ContainerProvider extends ChangeNotifier {
return false; return false;
} }
Future<void> refresh() async { Future<void> refresh({bool isAuto = false}) async {
var raw = '';
final sudo = final sudo =
await _requiresSudo() && Stores.setting.containerTrySudo.fetch(); await _requiresSudo() && Stores.setting.containerTrySudo.fetch();
/// If sudo is required and auto refresh is enabled, skip the refresh.
/// Or this will ask for pwd again and again.
if (sudo && isAuto) return;
final includeStats = Stores.setting.containerParseStat.fetch(); final includeStats = Stores.setting.containerParseStat.fetch();
var raw = '';
final code = await client?.execWithPwd( final code = await client?.execWithPwd(
_wrap(ContainerCmdType.execAll( _wrap(ContainerCmdType.execAll(
type, type,
@@ -264,7 +267,7 @@ enum ContainerCmdType {
bool includeStats = false, bool includeStats = false,
}) { }) {
return ContainerCmdType.values return ContainerCmdType.values
.map((e) => e.exec(type, sudo: sudo)) .map((e) => e.exec(type, sudo: sudo, includeStats: includeStats))
.join(' && echo $seperator && '); .join(' && echo $seperator && ');
} }
} }

View File

@@ -592,7 +592,7 @@ class _ContainerPageState extends State<ContainerPage> {
Duration(seconds: Stores.setting.serverStatusUpdateInterval.fetch()), Duration(seconds: Stores.setting.serverStatusUpdateInterval.fetch()),
(timer) { (timer) {
if (mounted) { if (mounted) {
_container.refresh(); _container.refresh(isAuto: true);
} else { } else {
timer.cancel(); timer.cancel();
} }