diff --git a/beetsplug/importadded.py b/beetsplug/importadded.py index d362005f9..a98b27795 100644 --- a/beetsplug/importadded.py +++ b/beetsplug/importadded.py @@ -43,6 +43,16 @@ def reimported_album(album): return album.path in replaced_album_paths +@ImportAddedPlugin.listen('import_task_start') +def record_if_inplace(task, session): + if not (session.config['copy'] or session.config['move'] or + session.config['link']): + log.debug(u"In place import detected, recording mtimes from source" + u"paths") + for item in task.items: + record_import_mtime(item, item.path, item.path) + + @ImportAddedPlugin.listen('import_task_files') def record_reimported(task, session): global reimported_item_ids, replaced_album_paths @@ -81,6 +91,7 @@ item_mtime = dict() @ImportAddedPlugin.listen('before_item_moved') @ImportAddedPlugin.listen('item_copied') +@ImportAddedPlugin.listen('item_linked') def record_import_mtime(item, source, destination): """Record the file mtime of an item's path before its import. """ diff --git a/test/test_importadded.py b/test/test_importadded.py index 6a885cd71..b228ee24c 100644 --- a/test/test_importadded.py +++ b/test/test_importadded.py @@ -76,13 +76,22 @@ class ImportAddedTest(unittest.TestCase, ImportHelper): """For comparing file modification times at a sufficient precision""" self.assertAlmostEqual(first, second, places=4, msg=msg) - def test_import_album_with_added_dates(self): + def assertAlbumImport(self): self.importer.run() album = self.lib.albums().get() self.assertEqual(album.added, self.min_mtime) for item in album.items(): self.assertEqual(item.added, self.min_mtime) + def test_import_album_with_added_dates(self): + self.assertAlbumImport() + + def test_import_album_inplace_with_added_dates(self): + self.config['import']['copy'] = False + self.config['import']['move'] = False + self.config['import']['link'] = False + self.assertAlbumImport() + def test_import_album_with_preserved_mtimes(self): self.config['importadded']['preserve_mtimes'] = True self.importer.run()