Skip to content

Commit 3cc5b48

Browse files
authored
Seek by offset before write for fuse (#891)
* Added test for seek read/write on fuse
1 parent 55c1f30 commit 3cc5b48

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

fsspec/fuse.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def read(self, path, size, offset, fh):
8282
def write(self, path, data, offset, fh):
8383
logger.debug("write %s", (path, offset))
8484
f = self.cache[fh]
85+
f.seek(offset)
8586
f.write(data)
8687
return len(data)
8788

fsspec/tests/test_fuse.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,18 @@ def test_chmod(mount_local):
124124
assert cp.stdout == b""
125125
assert set(os.listdir(source_dir)) == set(["text", "new"])
126126
assert open(mount_dir / "new").read() == "test"
127+
128+
129+
def test_seek_rw(mount_local):
130+
source_dir, mount_dir = mount_local
131+
fh = open(mount_dir / "text", "w")
132+
fh.write("teST")
133+
fh.seek(2)
134+
fh.write("st")
135+
fh.close()
136+
137+
fh = open(mount_dir / "text", "r")
138+
assert fh.read() == "test"
139+
fh.seek(2)
140+
assert fh.read() == "st"
141+
fh.close()

0 commit comments

Comments
 (0)