fsspec / fsspec/sshfs

Use sftp RENAME instead of copy and delete in case of moving a file

Open
#40 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

effort-small enhancement p2-medium
Dominant language
Python
Stars
89
Forks
21
PR merge metrics
No merged PRs in 30d

Description

Hello,
I use fsspec to have a single api to work with multiple different storage backend.
I ran into some issues with the sftp implementation because the move method is used and fails with the error : asyncssh.misc.ChannelOpenError: Session request failed trying to do a cp command here https://github.com/fsspec/sshfs/blob/main/sshfs/spec.py#L162

From what I understand the cp command is not always (rarely ?) possible on sftp protocol and the posix_rename is not always supported either.
Would it be possible to replace this to copy and then remove the file by a sftp rename ?
In my case, that did fix the issue and this is the approach used for example in the fs.sshfs implementation. (https://github.com/althonos/fs.sshfs/blob/master/fs/sshfs/sshfs.py#L279)
And it seems quite easy since the rename is already implemented in asyncssh.
I could do a PR about it is an acceptable change.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sshfs/spec.py at the move implementation linked in the issue, and review how asyncssh exposes rename. Verify the move path uses SFTP rename rather than the failing cp command, then run the existing test suite or add coverage for moving a file and confirm the operation succeeds without the session request error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.