mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 23:20:46 +00:00
- Add "write after end" and "no response" patterns to the shared isSessionError() in errors.ts - Replace inline duplicate in useSftpModalSession with an import of the shared function - Remove stale isSessionError from useCallback dependency array
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
export const isSessionError = (err: unknown): boolean => {
|
|
if (!(err instanceof Error)) return false;
|
|
const msg = err.message.toLowerCase();
|
|
return (
|
|
msg.includes("session not found") ||
|
|
msg.includes("sftp session") ||
|
|
msg.includes("session lost") ||
|
|
msg.includes("channel not ready") ||
|
|
msg.includes("readdir is not a function") ||
|
|
msg.includes("not found") ||
|
|
msg.includes("closed") ||
|
|
msg.includes("connection reset") ||
|
|
msg.includes("write after end") ||
|
|
msg.includes("no response") ||
|
|
msg.includes("not connected") ||
|
|
msg.includes("client disconnected")
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Check if an error message indicates a fatal error that should stop the entire upload.
|
|
* This includes session errors AND target directory deletion errors.
|
|
*/
|
|
export const isFatalUploadError = (errorMessage: string): boolean => {
|
|
const msg = errorMessage.toLowerCase();
|
|
return (
|
|
// Session-related errors
|
|
msg.includes("session not found") ||
|
|
msg.includes("sftp session") ||
|
|
msg.includes("session lost") ||
|
|
msg.includes("channel not ready") ||
|
|
msg.includes("readdir is not a function") ||
|
|
msg.includes("connection") ||
|
|
msg.includes("disconnected") ||
|
|
msg.includes("not connected") ||
|
|
// Target directory was deleted during upload
|
|
msg.includes("no such file") ||
|
|
msg.includes("enoent") ||
|
|
msg.includes("does not exist") ||
|
|
msg.includes("write stream error") ||
|
|
// Directory was removed
|
|
msg.includes("directory not found") ||
|
|
msg.includes("not a directory")
|
|
);
|
|
};
|