Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed Dec 23, 2024
1 parent 9d00f31 commit 43a4e08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/globaleaks_eph_fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ def __getattribute__(self, name):
# For everything else, defer to the default behavior
return super().__getattribute__(name)

def open(self, flags, mode=0o660):
def open(self, flags):
"""
Opens the ephemeral file for reading or writing.
:param mode: 'w' for writing, 'r' for reading.
:return: The file object.
"""
with self.mutex:
self.fd = os.open(self.filepath, os.O_RDWR | os.O_CREAT | os.O_APPEND, mode)
os.chmod(self.filepath, mode)
self.fd = os.open(self.filepath, os.O_RDWR | os.O_CREAT | os.O_APPEND, 0o660)
return self

def write(self, data):
Expand Down Expand Up @@ -210,10 +209,15 @@ def create(self, path, mode):
"""
with self.mutex:
file = EphemeralFile(self.storage_directory)
file.open('w', mode)
file.open('w')
self.files[path] = file
return file.fd

def mknod(self, path, mode, dev):
print(mode)
full_path = self._full_path(path)
return os.mknod(full_path, 0o660 | mode, dev)

def open(self, path, flags):
"""
Opens an existing file.
Expand Down
1 change: 0 additions & 1 deletion tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def test_readdir(self):
@patch("os.chmod")
def test_chmod_success(self, mock_chmod):
self.fs.create(TEST_PATH, 0o660)
mock_chmod.assert_called_with(self.fs.files[TEST_PATH].filepath, 0o660)
self.fs.chmod(TEST_PATH, 0o640)
mock_chmod.assert_called_with(self.fs.files[TEST_PATH].filepath, 0o640)

Expand Down

0 comments on commit 43a4e08

Please sign in to comment.