diff --git a/beets/importer.py b/beets/importer.py index 76c90dbea5..ba534b0ea3 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -65,7 +65,7 @@ def _open_state(): try: with open(config['statefile'].as_filename()) as f: return pickle.load(f) - except (IOError, EOFError): + except: return {} diff --git a/docs/changelog.rst b/docs/changelog.rst index 53ed48e0db..0a5ba81ac1 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,10 @@ Changelog This release adds **sorting** to beets queries. See :ref:`query-sort`. +Fixes: + +* Invalid state files don't crash the importer. + 1.3.7 (August 22, 2014) ----------------------- diff --git a/test/test_importer.py b/test/test_importer.py index 80a94833a3..d3d1e686dc 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -1197,6 +1197,13 @@ def test_incremental_item(self): importer.run() self.assertEqual(len(self.lib.items()), 2) + def test_invalid_state_file(self): + importer = self.create_importer() + with open(self.config['statefile'].as_filename(), 'w') as f: + f.write('000') + importer.run() + self.assertEqual(len(self.lib.albums()), 1) + def suite(): return unittest.TestLoader().loadTestsFromName(__name__)