Skip to content

Commit

Permalink
Merge pull request #1843 from Scille/fix-fuse-open-flags
Browse files Browse the repository at this point in the history
Change fuse_operations open method flag mask + add test on open
  • Loading branch information
touilleMan authored Sep 10, 2021
2 parents 904db7c + 1a57a10 commit 8624581
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions newsfragments/1836.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug where some text editor could still edit files in a workspace as reader
2 changes: 1 addition & 1 deletion parsec/core/mountpoint/fuse_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def create(self, path: FsPath, mode: int):

def open(self, path: FsPath, flags: int = 0):
# Filter file status and file creation flags
write_mode = flags in (os.O_WRONLY, os.O_RDWR)
write_mode = (flags % 4) in (os.O_WRONLY, os.O_RDWR)
_, fd = self.fs_access.file_open(path, write_mode=write_mode)
return fd

Expand Down
8 changes: 8 additions & 0 deletions tests/core/mountpoint/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ async def assert_cannot_write(mountpoint_manager, new_role):
with pytest.raises(expected_error) as ctx:
await bar_path.unlink()

def sync_open():
for flag in (os.O_WRONLY, os.O_RDWR, os.O_RDWR | os.O_APPEND, os.O_WRONLY | os.O_EXCL):
with pytest.raises(expected_error) as ctx:
os.open(foo_path, flag)
assert ctx.value.errno == expected_errno

await trio.to_thread.run_sync(sync_open)

async with mountpoint_manager_factory(
alice_user_fs, event_bus, base_mountpoint
) as mountpoint_manager:
Expand Down

0 comments on commit 8624581

Please sign in to comment.