mirror of
https://github.com/beetbox/beets.git
synced 2026-02-11 09:54:31 +01:00
Item.move() now takes a library as an argument
--HG-- branch : device
This commit is contained in:
parent
c7f98ccde1
commit
628cfbffe2
3 changed files with 9 additions and 9 deletions
|
|
@ -264,7 +264,7 @@ class Item(object):
|
|||
|
||||
#### dealing with files themselves ####
|
||||
|
||||
def move(self, copy=False):
|
||||
def move(self, library, copy=False):
|
||||
"""Move the item to its designated location within the library
|
||||
directory (provided by destination()). Subdirectories are created as
|
||||
needed. If the operation succeeds, the item's path field is updated to
|
||||
|
|
@ -278,7 +278,7 @@ class Item(object):
|
|||
Note that one should almost certainly call store() and library.save()
|
||||
after this method in order to keep on-disk data consistent.
|
||||
"""
|
||||
dest = self.library.destination(self)
|
||||
dest = library.destination(self)
|
||||
|
||||
# Create necessary ancestry for the move. Like os.renames but only
|
||||
# halfway.
|
||||
|
|
@ -685,7 +685,7 @@ class Library(BaseLibrary):
|
|||
#FIXME make a deep copy of the item?
|
||||
item.library = self
|
||||
if copy:
|
||||
item.move(copy=True)
|
||||
item.move(self, copy=True)
|
||||
|
||||
# build essential parts of query
|
||||
columns = ','.join([key for key in item_keys if key != 'id'])
|
||||
|
|
|
|||
2
bts
2
bts
|
|
@ -95,7 +95,7 @@ def tag_album(items, lib):
|
|||
# Change metadata and add to library.
|
||||
autotag.apply_metadata(items, info)
|
||||
for item in items:
|
||||
item.move(True)
|
||||
item.move(lib, True)
|
||||
item.add()
|
||||
item.write()
|
||||
|
||||
|
|
|
|||
|
|
@ -52,23 +52,23 @@ class MoveTest(unittest.TestCase):
|
|||
shutil.rmtree(self.libdir)
|
||||
|
||||
def test_move_arrives(self):
|
||||
self.i.move()
|
||||
self.i.move(self.lib)
|
||||
self.assertTrue(os.path.exists(self.dest))
|
||||
|
||||
def test_move_departs(self):
|
||||
self.i.move()
|
||||
self.i.move(self.lib)
|
||||
self.assertTrue(not os.path.exists(self.path))
|
||||
|
||||
def test_copy_arrives(self):
|
||||
self.i.move(copy=True)
|
||||
self.i.move(self.lib, copy=True)
|
||||
self.assertTrue(os.path.exists(self.dest))
|
||||
|
||||
def test_copy_does_not_depart(self):
|
||||
self.i.move(copy=True)
|
||||
self.i.move(self.lib, copy=True)
|
||||
self.assertTrue(os.path.exists(self.path))
|
||||
|
||||
def test_move_changes_path(self):
|
||||
self.i.move()
|
||||
self.i.move(self.lib)
|
||||
self.assertEqual(self.i.path, beets.library._normpath(self.dest))
|
||||
|
||||
class WalkTest(unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue