mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-09 20:01:23 +00:00
fileutil: docstrings for non-obvious usage restrictions on methods of EncryptedTemporaryFile.
This commit is contained in:
parent
05022dca36
commit
752897450d
@ -144,17 +144,23 @@ class EncryptedTemporaryFile:
|
||||
return offset
|
||||
|
||||
def read(self, size=-1):
|
||||
"""A read must not follow a write, or vice-versa, without an intervening seek."""
|
||||
index = self.file.tell()
|
||||
ciphertext = self.file.read(size)
|
||||
plaintext = self._crypt(index, ciphertext)
|
||||
return plaintext
|
||||
|
||||
def write(self, plaintext):
|
||||
"""A read must not follow a write, or vice-versa, without an intervening seek.
|
||||
If seeking and then writing causes a 'hole' in the file, the contents of the
|
||||
hole are unspecified."""
|
||||
index = self.file.tell()
|
||||
ciphertext = self._crypt(index, plaintext)
|
||||
self.file.write(ciphertext)
|
||||
|
||||
def truncate(self, newsize):
|
||||
"""Truncate or extend the file to 'newsize'. If it is extended, the contents after the
|
||||
old end-of-file are unspecified. The file position after this operation is unspecified."""
|
||||
self.file.truncate(newsize)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user