From bbd4546fe4a28fbc3ca49e60f06fe4ca5b6a2064 Mon Sep 17 00:00:00 2001 From: bwarsaw <> Date: Tue, 31 May 2005 22:38:44 +0000 Subject: Fixes for SF #949117. update_qfiles(): Catch and ignore OSErrors when trying to listdir() a non-directory. dequeue(): Catch EOFErrors that can occur if a zero-length qfile is encountered. --- bin/update | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/update b/bin/update index 3ecc304f..0c54fa2a 100755 --- a/bin/update +++ b/bin/update @@ -1,6 +1,6 @@ #! @PYTHON@ # -# Copyright (C) 1998-2004 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2005 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -431,16 +431,21 @@ def update_qfiles(): # The files in qfiles/bad can't possibly be pickles continue sb = Switchboard(dirpath) - for filename in os.listdir(dirpath): - filepath = os.path.join(dirpath, filename) - filebase, ext = os.path.splitext(filepath) - # Handle the .db metadata files as part of the handling of the - # .pck or .msg message files. - if ext not in ('.pck', '.msg'): - continue - msg, data = dequeue(filebase) - if msg is not None and data is not None: - sb.enqueue(msg, data) + try: + for filename in os.listdir(dirpath): + filepath = os.path.join(dirpath, filename) + filebase, ext = os.path.splitext(filepath) + # Handle the .db metadata files as part of the handling of the + # .pck or .msg message files. + if ext not in ('.pck', '.msg'): + continue + msg, data = dequeue(filebase) + if msg is not None and data is not None: + sb.enqueue(msg, data) + except EnvironmentError, e: + if e.errno <> errno.ENOTDIR: + raise + print _('Warning! Not a directory: %(dirpath)s') @@ -521,6 +526,10 @@ def dequeue(filebase): else: os.unlink(msgfile) msg = data = None + except EOFError: + # For some reason the pckfile was empty. Just delete it. + print _('Warning! Deleting empty .pck file: %(pckfile)s') + os.unlink(pckfile) finally: if msgfp: msgfp.close() -- cgit v1.2.3