mirror of
https://github.com/beetbox/beets.git
synced 2026-02-28 02:03:05 +01:00
fix copying when file is already where it needs to be
This commit is contained in:
parent
43b8235a4c
commit
87500cf5c4
3 changed files with 19 additions and 4 deletions
2
NEWS
2
NEWS
|
|
@ -10,6 +10,8 @@
|
|||
* Fixed a spurious crash when LANG or a related environment variable is
|
||||
set to an invalid value (such as 'UTF-8' on some installations of Mac
|
||||
OS X).
|
||||
* Fixed an error when trying to copy a file that is already at its
|
||||
destination.
|
||||
|
||||
1.0b5
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -328,10 +328,11 @@ class Item(object):
|
|||
# Create necessary ancestry for the move.
|
||||
_mkdirall(dest)
|
||||
|
||||
if copy:
|
||||
shutil.copy(self.path, dest)
|
||||
else:
|
||||
shutil.move(self.path, dest)
|
||||
if not shutil._samefile(self.path, dest):
|
||||
if copy:
|
||||
shutil.copy(self.path, dest)
|
||||
else:
|
||||
shutil.move(self.path, dest)
|
||||
|
||||
# Either copying or moving succeeded, so update the stored path.
|
||||
self.path = dest
|
||||
|
|
|
|||
|
|
@ -72,6 +72,18 @@ class MoveTest(unittest.TestCase):
|
|||
def test_move_changes_path(self):
|
||||
self.i.move(self.lib)
|
||||
self.assertEqual(self.i.path, beets.library._normpath(self.dest))
|
||||
|
||||
def test_copy_already_at_destination(self):
|
||||
self.i.move(self.lib)
|
||||
old_path = self.i.path
|
||||
self.i.move(self.lib, copy=True)
|
||||
self.assertEqual(self.i.path, old_path)
|
||||
|
||||
def test_move_already_at_destination(self):
|
||||
self.i.move(self.lib)
|
||||
old_path = self.i.path
|
||||
self.i.move(self.lib, copy=False)
|
||||
self.assertEqual(self.i.path, old_path)
|
||||
|
||||
class HelperTest(unittest.TestCase):
|
||||
def test_ancestry_works_on_file(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue