Make file operations unbuffered

This commit is contained in:
R. Richard 2019-06-25 11:31:27 +02:00 committed by Kristóf Tóth
parent 494761d2a7
commit d8e2f8a92a
1 changed files with 4 additions and 4 deletions

View File

@ -65,13 +65,13 @@ class FileManager: # pylint: disable=too-many-instance-attributes
@property
def file_contents(self):
with open(self._filepath(self.filename), 'r', errors='surrogateescape') as ifile:
return ifile.read()
with open(self._filepath(self.filename), 'rb', buffering=0) as ifile:
return ifile.read().decode(errors='surrogateescape')
@file_contents.setter
def file_contents(self, value):
with open(self._filepath(self.filename), 'w', errors='surrogateescape') as ofile:
ofile.write(value)
with open(self._filepath(self.filename), 'wb', buffering=0) as ofile:
ofile.write(value.encode())
def _is_in_allowed_dir(self, path):
return any(