From 2eeb55c1d82e5b8a2a8d76ffa11bf6e8418b2868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Thu, 15 Jan 2026 13:46:53 +0800 Subject: [PATCH] fix --- lib/data/model/sftp/req.dart | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/data/model/sftp/req.dart b/lib/data/model/sftp/req.dart index fdd9decb..3688ebe4 100644 --- a/lib/data/model/sftp/req.dart +++ b/lib/data/model/sftp/req.dart @@ -16,29 +16,11 @@ class SftpReq { privateKey = getPrivateKey(keyId); } if (spi.jumpChainIds != null || spi.jumpId != null) { - final chain = []; + // Use resolveMergedJumpChain to recursively expand nested hop chains + final chain = resolveMergedJumpChain(spi); final keys = []; - final visited = {spi.id.isNotEmpty ? spi.id : spi.oldId}; - - final hopIds = spi.jumpChainIds ?? (spi.jumpId == null ? const [] : [spi.jumpId!]); - for (final hopId in hopIds) { - final hopSpi = Stores.server.box.get(hopId); - if (hopSpi == null) { - throw SSHErr( - type: SSHErrType.connect, - message: 'Jump server not found: $hopId', - ); - } - final hopKey = hopSpi.id.isNotEmpty ? hopSpi.id : hopSpi.oldId; - if (!visited.add(hopKey)) { - throw SSHErr( - type: SSHErrType.connect, - message: 'Jump loop detected while building SFTP chain: ${hopSpi.name}', - ); - } - - chain.add(hopSpi); - keys.add(hopSpi.keyId != null ? getPrivateKey(hopSpi.keyId!) : null); + for (final hop in chain) { + keys.add(hop.keyId != null ? getPrivateKey(hop.keyId!) : null); } // Always set when a jump is configured so the isolate won't fallback to Stores.