mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-22 16:10:50 +00:00
fix(sftp): sync reconnect host on tab reuse and home-fallback stale paths
Update lastConnectedHost when auto-connect reselects an existing tab, and always try the detected home directory when a remembered start path fails.
This commit is contained in:
1 parent
7538dd0b9f
commit
8a95fa1eda
3 files changed
+17
-1
No files matched your search
@@ -627,8 +627,9 @@ export const useSftpConnections = ({
|
||||
dirCacheRef.current.delete(provisionalCacheKey);
|
||||
}
|
||||
// Fall back to homeDir, then "/", chaining attempts.
|
||||
// Remembered/reconnect paths can be stale even when shared cache is gone.
|
||||
let fallbackSucceeded = false;
|
||||
if (sharedHostCache && startPath !== homeDir) {
|
||||
if (startPath !== homeDir) {
|
||||
try {
|
||||
startPath = homeDir;
|
||||
files = await listRemoteFiles(sftpId, startPath, filenameEncoding);
|
||||
|
||||
@@ -160,6 +160,15 @@ export const useSftpState = (
|
||||
right: null,
|
||||
});
|
||||
|
||||
// Keep reconnect metadata in sync when auto-connect reuses an existing tab
|
||||
// without calling connect() (selectTab alone does not update this ref).
|
||||
const setLastConnectedHost = useCallback((
|
||||
side: "left" | "right",
|
||||
host: Host | "local" | null,
|
||||
) => {
|
||||
lastConnectedHostRef.current[side] = host;
|
||||
}, []);
|
||||
|
||||
const handleSessionError = useSftpSessionErrors({
|
||||
getActivePane,
|
||||
leftTabsRef,
|
||||
@@ -418,6 +427,7 @@ export const useSftpState = (
|
||||
resolveConflict: resolveAnyConflict,
|
||||
getSftpIdForConnection,
|
||||
getConnectionCacheKey,
|
||||
setLastConnectedHost,
|
||||
reportSessionError: handleSessionError,
|
||||
rejectHostKeyVerification,
|
||||
acceptHostKeyVerification,
|
||||
@@ -480,6 +490,7 @@ export const useSftpState = (
|
||||
resolveConflict: resolveAnyConflict,
|
||||
getSftpIdForConnection,
|
||||
getConnectionCacheKey,
|
||||
setLastConnectedHost,
|
||||
reportSessionError: handleSessionError,
|
||||
rejectHostKeyVerification,
|
||||
acceptHostKeyVerification,
|
||||
@@ -556,6 +567,7 @@ export const useSftpState = (
|
||||
resolveConflict: (...args: Parameters<typeof resolveAnyConflict>) => methodsRef.current.resolveConflict(...args),
|
||||
getSftpIdForConnection: (...args: Parameters<typeof getSftpIdForConnection>) => methodsRef.current.getSftpIdForConnection(...args),
|
||||
getConnectionCacheKey: (...args: Parameters<typeof getConnectionCacheKey>) => methodsRef.current.getConnectionCacheKey(...args),
|
||||
setLastConnectedHost: (...args: Parameters<typeof setLastConnectedHost>) => methodsRef.current.setLastConnectedHost(...args),
|
||||
reportSessionError: (...args: Parameters<typeof handleSessionError>) => methodsRef.current.reportSessionError(...args),
|
||||
rejectHostKeyVerification: () => methodsRef.current.rejectHostKeyVerification(),
|
||||
acceptHostKeyVerification: () => methodsRef.current.acceptHostKeyVerification(),
|
||||
|
||||
Reference in new issue
Block a user