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

solve a bug when the 'write' method in an implementation does not ret… #1072

Merged
merged 5 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions fsspec/implementations/tests/test_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def netloc(ssh):
return userpass + netloc


def test_put_file(ssh, tmp_path, root_path):

tmp_file = tmp_path / "a.txt"
with open(tmp_file, mode="w") as fd:
fd.write("blabla")

f = fsspec.get_filesystem_class("sftp")(**ssh)
f.put_file(lpath=tmp_file, rpath=root_path + "a.txt")


def test_simple_with_tar(ssh, netloc, tmp_path, root_path):

files_to_pack = ["a.txt", "b.txt"]
Expand Down
4 changes: 4 additions & 0 deletions fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ def get_file(
while data:
data = f1.read(self.blocksize)
segment_len = outfile.write(data)
if segment_len is None:
segment_len = len(data)
callback.relative_update(segment_len)
if not isfilelike(lpath):
outfile.close()
Expand Down Expand Up @@ -861,6 +863,8 @@ def put_file(self, lpath, rpath, callback=_DEFAULT_CALLBACK, **kwargs):
while f1.tell() < size:
data = f1.read(self.blocksize)
segment_len = f2.write(data)
if segment_len is None:
segment_len = len(data)
callback.relative_update(segment_len)

def put(self, lpath, rpath, recursive=False, callback=_DEFAULT_CALLBACK, **kwargs):
Expand Down