diff options
| author | bwarsaw | 2000-06-23 04:30:10 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-06-23 04:30:10 +0000 |
| commit | c7a89854238d675925e84fd9dae20d69a847c088 (patch) | |
| tree | 817cdd5e84641c2490f47618de4504c344043ec4 | |
| parent | 86edb18139753c933c90b1bf99261c29651f7326 (diff) | |
| download | mailman-c7a89854238d675925e84fd9dae20d69a847c088.tar.gz mailman-c7a89854238d675925e84fd9dae20d69a847c088.tar.zst mailman-c7a89854238d675925e84fd9dae20d69a847c088.zip | |
DumbBTree.__init__(): Rewrote the file opening and unmarshaling code
to be more robust so that if either fail, we end up with an empty
self.dict and self.sorted.
Note that the archiver subprocess will still fail with an exception.
Fixing this will require much more work on the archiver as a whole,
and isn't worth it right now. But this fix averts the problem when
regenerating the archive from scratch using bin/arch, so at least
corrupt archives can be rebuilt.
| -rw-r--r-- | Mailman/Archiver/HyperDatabase.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Mailman/Archiver/HyperDatabase.py b/Mailman/Archiver/HyperDatabase.py index eeed8fde1..a5779a7c7 100644 --- a/Mailman/Archiver/HyperDatabase.py +++ b/Mailman/Archiver/HyperDatabase.py @@ -20,6 +20,7 @@ import os import marshal import string +import errno # # package/project modules @@ -58,12 +59,21 @@ class DumbBTree: self.lockfile = LockFile.LockFile(self.path + ".lock") self.lock() self.__dirty = 0 - if os.path.exists(path): - self.dict = marshal.load(open(path)) - self.__sort(dirty=1) + self.dict = {} + self.sorted = [] + try: + fp = open(path) + try: + self.dict = marshal.load(fp) + finally: + fp.close() + except IOError, e: + if e.errno <> errno.ENOENT: raise + pass + except EOFError: + pass else: - self.dict = {} - self.sorted = [] + self.__sort(dirty=1) def __sort(self, dirty=None): if self.__dirty == 1 or dirty: |
