fix broken symlink crash (#157)

This commit is contained in:
Adrian Sampson 2011-04-02 18:03:42 -07:00
parent d4d74dd68b
commit c051df6d91
3 changed files with 13 additions and 1 deletions

3
NEWS
View file

@ -41,7 +41,8 @@
* Fix a bug where some files would be erroneously interpreted as MP4.
* Fix permission bits applied to album art files.
* Fix malformed MusicBrainz queries caused by null characters.
# Fix a bug with old versions of the Monkey's Audio format.
* Fix a bug with old versions of the Monkey's Audio format.
* Fix a crash on broken symbolic links.
* Retry in more cases when MusicBrainz servers are slow/overloaded.
* The old "albumify" plugin for upgrading databases was removed.

View file

@ -495,6 +495,8 @@ class MediaFile(object):
self.mgfile = mutagen.File(path)
except unreadable_exc:
raise UnreadableFileError('Mutagen could not read file')
except IOError:
raise UnreadableFileError('could not read file')
if self.mgfile is None: # Mutagen couldn't guess the type
raise FileTypeError('file type unsupported by Mutagen')

View file

@ -130,6 +130,15 @@ class SafetyTest(unittest.TestCase):
self._exccheck('nothing.xml', beets.mediafile.UnreadableFileError,
"ftyp")
def test_broken_symlink(self):
fn = os.path.join('rsrc', 'brokenlink')
os.symlink('does_not_exist', fn)
try:
self.assertRaises(beets.mediafile.UnreadableFileError,
beets.mediafile.MediaFile, fn)
finally:
os.unlink(fn)
class SideEffectsTest(unittest.TestCase):
def setUp(self):
self.empty = os.path.join('rsrc', 'empty.mp3')