Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for + modes to SSHFile #51

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions sshfs/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def __init__(
self.fs = fs
self.loop = fs.loop

# TODO: support r+ / w+ / a+
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isidentical @efiop - if you remember anything about this - it would be helpful

if mode not in {"rb", "wb", "ab"}:
if "t" in mode or "b" not in mode:
raise ValueError(f"Unsupported file mode: {mode}")

self.path = path
Expand Down Expand Up @@ -79,10 +78,13 @@ async def _open_file(self):
_close = _mirror_method("close")

def readable(self):
return "r" in self.mode
return "r" in self.mode or "+" in self.mode

def seekable(self):
return "r" in self.mode or "w" in self.mode

def writable(self):
return not self.readable()
return any(x in self.mode for x in ["a", "w", "+"])

def close(self):
if self._closed:
Expand Down
Loading