sshfs icon indicating copy to clipboard operation
sshfs copied to clipboard

Set cachable to false

Open benrutter opened this issue 8 months ago • 0 comments

Closes issue #42

At the moment, because SSHFS is considered cachable, creating a new filesystem doesn't create a new connection, and maintains the old one.

That's probably not a good fit for SFTP connections, since they're likely to timeout and be closed off after a while, so almost any long running process using SSHFS is eventually going to hit an issue where the filesystem continues to reference a closed off connection, and the cache needs to be manually cleared.

To fix that, I've just set "cachable" to False here, so that creating a new filesystem would also bring in a new connection.

Honestly, I don't have the knowledge to know the full implications of this, but my main thoughts are:

  • Does this mean it's worth adding in something to clean up / close the connection when the SSHFS object goes out of memory? (otherwise there are potentially open but unusable connections floating around)
  • Is there a case where you'd want it to be cachable? In which case, the "cachable" setting could theoretically be put behind an __init__ argument? (my guess is that'd cause some kind of side effects nobody is expecting though)

benrutter avatar May 01 '25 15:05 benrutter