From c569ddd412fa6468f1ff26fd06b8c510fdf392b4 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 3 Nov 2012 12:16:32 -0700 Subject: [PATCH] human-readable mkdir error --- beets/util/__init__.py | 8 ++++++-- docs/changelog.rst | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 3448d104f..caba758e1 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -95,7 +95,7 @@ class FilesystemError(HumanReadableException): clause = 'while {0} {1} to {2}'.format( self._gerund(), repr(self.paths[0]), repr(self.paths[1]) ) - elif self.verb in ('delete', 'write'): + elif self.verb in ('delete', 'write', 'create'): clause = 'while {0} {1}'.format( self._gerund(), repr(self.paths[0]) ) @@ -185,7 +185,11 @@ def mkdirall(path): """ for ancestor in ancestry(path): if not os.path.isdir(syspath(ancestor)): - os.mkdir(syspath(ancestor)) + try: + os.mkdir(syspath(ancestor)) + except (OSError, IOError) as exc: + raise FilesystemError(exc, 'create', (ancestor,), + traceback.format_exc()) def prune_dirs(path, root=None, clutter=('.DS_Store', 'Thumbs.db')): """If path is an empty directory, then remove it. Recursively remove diff --git a/docs/changelog.rst b/docs/changelog.rst index 12fbea45f..62737a47d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -69,7 +69,8 @@ Changelog * Fix a crash when input is read from a pipe without a specified encoding. * Fix some problem with identifying files on Windows with Unicode directory names in their path. -* Add a human-readable error message when writing files' tags fails. +* Add human-readable error messages when writing files' tags fails or when a + directory can't be created. * Changed plugin loading so that modules can be imported without unintentionally loading the plugins they contain.