pkg / sftp

SFTP support for the go.crypto/ssh package
BSD 2-Clause "Simplified" License
1.52k stars 380 forks source link

server: use os.IsNotExist to map sshFxNoSuchFile #382

Closed willnorris closed 4 years ago

willnorris commented 4 years ago

Always use os.IsNotExist to identify any OS specific error types that represent missing files or directories. This resolves an issue on Windows where some system errors (ENOTDIR) were not being identified as 'not found' errors and mapped to sshFxNoSuchFile.

fixes #381

willnorris commented 4 years ago

technically, this means we could also remove the syscall.ENOENT case from inside of translateError, since that is only ever called from statusFromError. I think it could still be reasonable to leave it there, but happy to remove it if you'd like.

puellanivis commented 4 years ago

Up to you, if you want to remove the ENOENT case. Like you say, we should never hit it anymore. But I am going to guess that it’s not actually too much code or binary bloat, so it might be better to keep it around as a just in case backup? 🤷‍♀️

I’m fine either way.

willnorris commented 4 years ago

yeah, I think probably leave it in. 👍 Given what the function is doing... mapping syscall error numbers to ssh error codes, it makes sense for it to have fuller coverage of different error numbers. That keeps it somewhat semantically independent of the statusFromError func.