From ee186a0d301cc677675f1b50d8cbcaca9e14e5d6 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 31 Jan 2010 15:54:12 +0000 Subject: [PATCH] * morituri/common/accurip.py: The AccuRip cache dir could exist without the file; handle that case. --- ChangeLog | 6 ++++++ morituri/common/accurip.py | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7711202..7c3ef82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-31 Thomas Vander Stichele + + * morituri/common/accurip.py: + The AccuRip cache dir could exist without the file; handle that + case. + 2009-12-28 Thomas Vander Stichele * morituri/common/program.py: diff --git a/morituri/common/accurip.py b/morituri/common/accurip.py index 7e6e7c1..babd452 100644 --- a/morituri/common/accurip.py +++ b/morituri/common/accurip.py @@ -20,6 +20,7 @@ # You should have received a copy of the GNU General Public License # along with morituri. If not, see . +import errno import os import struct import urlparse @@ -75,7 +76,14 @@ class AccuCache(log.Loggable): def _cache(self, url, data): path = self._getPath(url) - os.makedirs(os.path.dirname(path)) + try: + os.makedirs(os.path.dirname(path)) + except OSError, e: + self.debug('Could not make dir %s: %r' % ( + path, log.getExceptionMessage(e))) + if e.errno != errno.EEXIST: + raise + handle = open(path, 'wb') handle.write(data) handle.close()