Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions beets/importer/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def import_asis(session: ImportSession, task: ImportTask):

log.info("{}", displayable_path(task.paths))
task.set_choice(Action.ASIS)
_resolve_duplicates(session, task)
_apply_choice(session, task)


Expand Down
49 changes: 40 additions & 9 deletions test/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,29 +945,34 @@ def test_remove_duplicate_album(self):
item = self.lib.items().get()
assert item.title == "new title"

def test_no_autotag_keeps_duplicate_album(self):
def test_no_autotag_removes_duplicate_album(self):
config["import"]["autotag"] = False
album = self.lib.albums().get()
item = self.lib.items().get()
assert item.title == "t\xeftle 0"
assert item.filepath.exists()

# Imported item has the same artist and album as the one in the
# library.
# Imported item has the same albumartist and album as the one in the
# library album. We use album metadata (not item metadata) since
# duplicate detection uses album-level fields.
import_file = os.path.join(
self.importer.paths[0], b"album", b"track_1.mp3"
)
import_file = MediaFile(import_file)
import_file.artist = item["artist"]
import_file.albumartist = item["artist"]
import_file.album = item["album"]
import_file.artist = album.albumartist
import_file.albumartist = album.albumartist
import_file.album = album.album
import_file.title = "new title"
import_file.save()

self.importer.default_resolution = self.importer.Resolution.REMOVE
self.importer.run()

assert item.filepath.exists()
assert len(self.lib.albums()) == 2
assert len(self.lib.items()) == 2
# Old duplicate should be removed, new one imported
assert len(self.lib.albums()) == 1
assert len(self.lib.items()) == 1
# The new item should be in the library
assert self.lib.items().get().title == "new title"

def test_keep_duplicate_album(self):
self.importer.default_resolution = self.importer.Resolution.KEEPBOTH
Expand Down Expand Up @@ -1096,6 +1101,32 @@ def test_keep_when_extra_key_is_different(self):

assert len(self.lib.items()) == 2

def test_no_autotag_removes_duplicate_singleton(self):
config["import"]["autotag"] = False
item = self.lib.items().get()
assert item.mb_trackid == "old trackid"
assert item.filepath.exists()

# Imported item has the same artist and title as the one in the
# library. We use item metadata since duplicate detection uses
# item-level fields for singletons.
import_file = os.path.join(
self.importer.paths[0], b"album", b"track_1.mp3"
)
import_file = MediaFile(import_file)
import_file.artist = item.artist
import_file.title = item.title
import_file.mb_trackid = "new trackid"
import_file.save()

self.importer.default_resolution = self.importer.Resolution.REMOVE
self.importer.run()

# Old duplicate should be removed, new one imported
assert len(self.lib.items()) == 1
# The new item should be in the library
assert self.lib.items().get().mb_trackid == "new trackid"

def test_twice_in_import_dir(self):
self.skipTest("write me")

Expand Down
Loading