diff --git a/beets/importer.py b/beets/importer.py index 76f34036f..5206562de 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -391,7 +391,8 @@ class ImportTask(object): if session.config['incremental']: self.save_history() - self.cleanup(copy=session.config['copy'], delete=session.config['delete'], + self.cleanup(copy=session.config['copy'], + delete=session.config['delete'], move=session.config['move']) self._emit_imported(session.lib) @@ -430,7 +431,8 @@ class ImportTask(object): def lookup_candidates(self): """Retrieve and store candidates for this album. """ - artist, album, candidates, recommendation = autotag.tag_album(self.items) + artist, album, candidates, recommendation = \ + autotag.tag_album(self.items) self.cur_artist = artist self.cur_album = album self.candidates = candidates @@ -574,6 +576,13 @@ class ImportTask(object): self.set_choice(choice) session.log_choice(self) + def reload(self): + """Reload albums and items from the database. + """ + for item in self.imported_items(): + item.load() + self.album.load() + # Utilities. def prune(self, filename): @@ -667,6 +676,9 @@ class SingletonImportTask(ImportTask): self.set_choice(choice) session.log_choice(self) + def reload(self): + self.item.load() + # FIXME The inheritance relationships are inverted. This is why there # are so many methods which pass. We should introduce a new @@ -1055,8 +1067,9 @@ def plugin_stage(session, func, task): func(session, task) # Stage may modify DB, so re-load cached item data. - for item in task.imported_items(): - item.load() + # FIXME Importer plugins should not modify the database but instead + # the albums and items attached to tasks. + task.reload() @pipeline.mutator_stage diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 1b47e07c3..4b4f53bea 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -278,8 +278,7 @@ class FetchArtPlugin(BeetsPlugin): # For any other choices (e.g., TRACKS), do nothing. return - album = session.lib.get_album(task.album_id) - path = art_for_album(album, task.paths, self.maxwidth, local) + path = art_for_album(task.album, task.paths, self.maxwidth, local) if path: self.art_paths[task] = path @@ -290,7 +289,7 @@ class FetchArtPlugin(BeetsPlugin): if task in self.art_paths: path = self.art_paths.pop(task) - album = session.lib.get_album(task.album_id) + album = task.album src_removed = (config['import']['delete'].get(bool) or config['import']['move'].get(bool)) album.set_art(path, not src_removed) diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index eea428dfa..6646e6af3 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -382,7 +382,7 @@ class LastGenrePlugin(plugins.BeetsPlugin): def imported(self, session, task): """Event hook called when an import task finishes.""" if task.is_album: - album = session.lib.get_album(task.album_id) + album = task.album album.genre, src = self._get_genre(album) log.debug(u'added last.fm album genre ({0}): {1}'.format( src, album.genre diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 87a4eb2dc..acf7afc86 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -601,8 +601,7 @@ class ReplayGainPlugin(BeetsPlugin): return if task.is_album: - album = session.lib.get_album(task.album_id) - self.handle_album(album, False) + self.handle_album(task.album, False) else: self.handle_track(task.item, False)