store albums after moving art

This commit is contained in:
Adrian Sampson 2013-08-21 09:25:47 -07:00
parent c2acab510d
commit 9609e41cf8
3 changed files with 23 additions and 18 deletions

View file

@ -1530,6 +1530,7 @@ class Library(object):
album = self.get_album(item)
if album:
album.move_art(copy)
album.store()
# Prune vacated directory.
if not copy:
@ -1739,6 +1740,7 @@ class Album(LibModel):
# Move art.
self.move_art(copy)
self.store()
def item_dir(self):
"""Returns the directory containing the album's first item,

View file

@ -350,7 +350,8 @@ class ArtFileTest(_common.TestCase):
self.assertExists(oldartpath)
self.ai.album = 'different_album'
self.lib.move(self.i)
self.ai.store()
self.lib.move(self.ai.items()[0])
artpath = self.lib.albums()[0].artpath
self.assertTrue('different_album' in artpath)
@ -427,6 +428,7 @@ class RemoveTest(_common.TestCase):
artfile = os.path.join(self.temp_dir, 'testart.jpg')
touch(artfile)
self.ai.set_art(artfile)
self.ai.store()
parent = os.path.dirname(self.i.path)
self.lib.remove(self.i, True)

View file

@ -406,7 +406,7 @@ class ApplyExistingItemsTest(_common.TestCase):
self._apply_asis([self.i])
# Get the item's path and import it again.
item = self.lib.items().next()
item = self.lib.items().get()
new_item = library.Item.from_path(item.path)
self._apply_asis([new_item])
@ -416,7 +416,7 @@ class ApplyExistingItemsTest(_common.TestCase):
def test_apply_existing_album_does_not_duplicate_album(self):
# As above.
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
new_item = library.Item.from_path(item.path)
self._apply_asis([new_item])
@ -425,7 +425,7 @@ class ApplyExistingItemsTest(_common.TestCase):
def test_apply_existing_singleton_does_not_duplicate_album(self):
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
new_item = library.Item.from_path(item.path)
self._apply_asis([new_item], False)
@ -440,7 +440,7 @@ class ApplyExistingItemsTest(_common.TestCase):
self._apply_asis([self.i])
# Import again with new metadata.
item = self.lib.items().next()
item = self.lib.items().get()
new_item = library.Item.from_path(item.path)
new_item.title = 'differentTitle'
self._apply_asis([new_item])
@ -454,12 +454,12 @@ class ApplyExistingItemsTest(_common.TestCase):
config['import']['copy'] = True
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
new_item = library.Item.from_path(item.path)
new_item.title = 'differentTitle'
self._apply_asis([new_item])
item = self.lib.items().next()
item = self.lib.items().get()
self.assertTrue('differentTitle' in item.path)
self.assertExists(item.path)
@ -468,12 +468,12 @@ class ApplyExistingItemsTest(_common.TestCase):
config['import']['copy'] = False
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
new_item = library.Item.from_path(item.path)
new_item.title = 'differentTitle'
self._apply_asis([new_item])
item = self.lib.items().next()
item = self.lib.items().get()
self.assertFalse('differentTitle' in item.path)
self.assertExists(item.path)
@ -481,13 +481,13 @@ class ApplyExistingItemsTest(_common.TestCase):
config['import']['copy'] = True
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
oldpath = item.path
new_item = library.Item.from_path(item.path)
new_item.title = 'differentTitle'
self._apply_asis([new_item])
item = self.lib.items().next()
item = self.lib.items().get()
self.assertNotExists(oldpath)
def test_apply_existing_item_new_metadata_delete_enabled(self):
@ -497,13 +497,13 @@ class ApplyExistingItemsTest(_common.TestCase):
config['import']['delete'] = True # !
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
oldpath = item.path
new_item = library.Item.from_path(item.path)
new_item.title = 'differentTitle'
self._apply_asis([new_item])
item = self.lib.items().next()
item = self.lib.items().get()
self.assertNotExists(oldpath)
self.assertTrue('differentTitle' in item.path)
self.assertExists(item.path)
@ -513,13 +513,13 @@ class ApplyExistingItemsTest(_common.TestCase):
config['import']['copy'] = True
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
oldpath = item.path
new_item = library.Item.from_path(item.path)
self._apply_asis([new_item])
self.assertEqual(len(list(self.lib.items())), 1)
item = self.lib.items().next()
item = self.lib.items().get()
self.assertEqual(oldpath, item.path)
self.assertExists(oldpath)
@ -528,19 +528,19 @@ class ApplyExistingItemsTest(_common.TestCase):
config['import']['delete'] = True # !
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
new_item = library.Item.from_path(item.path)
self._apply_asis([new_item])
self.assertEqual(len(list(self.lib.items())), 1)
item = self.lib.items().next()
item = self.lib.items().get()
self.assertExists(item.path)
def test_same_album_does_not_duplicate(self):
# With the -L flag, exactly the same item (with the same ID)
# is re-imported. This test simulates that situation.
self._apply_asis([self.i])
item = self.lib.items().next()
item = self.lib.items().get()
self._apply_asis([item])
# Should not be duplicated.
@ -704,6 +704,7 @@ class DuplicateCheckTest(_common.TestCase):
def test_duplicate_va_album(self):
self.album.albumartist = 'an album artist'
self.album.store()
res = importer._duplicate_check(self.lib,
self._album_task(False, 'an album artist'))
self.assertTrue(res)