mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-09 02:17:16 +00:00
Make file operations unbuffered
This commit is contained in:
parent
494761d2a7
commit
d8e2f8a92a
@ -65,13 +65,13 @@ class FileManager: # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def file_contents(self):
|
def file_contents(self):
|
||||||
with open(self._filepath(self.filename), 'r', errors='surrogateescape') as ifile:
|
with open(self._filepath(self.filename), 'rb', buffering=0) as ifile:
|
||||||
return ifile.read()
|
return ifile.read().decode(errors='surrogateescape')
|
||||||
|
|
||||||
@file_contents.setter
|
@file_contents.setter
|
||||||
def file_contents(self, value):
|
def file_contents(self, value):
|
||||||
with open(self._filepath(self.filename), 'w', errors='surrogateescape') as ofile:
|
with open(self._filepath(self.filename), 'wb', buffering=0) as ofile:
|
||||||
ofile.write(value)
|
ofile.write(value.encode())
|
||||||
|
|
||||||
def _is_in_allowed_dir(self, path):
|
def _is_in_allowed_dir(self, path):
|
||||||
return any(
|
return any(
|
||||||
|
Loading…
Reference in New Issue
Block a user