From 752897450de27bf46572580bec4b3db25f0541b1 Mon Sep 17 00:00:00 2001 From: david-sarah Date: Fri, 16 Jul 2010 22:46:47 -0700 Subject: [PATCH] fileutil: docstrings for non-obvious usage restrictions on methods of EncryptedTemporaryFile. --- src/allmydata/util/fileutil.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index f671f7ea..cf0cb66a 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -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) -- 2.45.2