mirror of
https://github.com/beetbox/beets.git
synced 2026-01-10 18:07:00 +01:00
Catch all errors when loading state file.
A crash during the multi-threaded import process may leave the pickled state invalid (see #913). We recover from all these errors.
This commit is contained in:
parent
132fad847b
commit
225ce62a33
3 changed files with 12 additions and 1 deletions
|
|
@ -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 {}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
-----------------------
|
||||
|
|
|
|||
|
|
@ -1197,6 +1197,13 @@ class IncrementalImportTest(unittest.TestCase, TestHelper):
|
|||
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__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue