From 8ba67674ccad39dd55ebb624aa58a662dccff2ff Mon Sep 17 00:00:00 2001 From: Serene-Arc <33189705+Serene-Arc@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:00:24 +1000 Subject: [PATCH 1/4] Catch when items have no path --- beets/ui/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 74e7f7d45..3117e64b4 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1232,7 +1232,7 @@ def update_items(lib, query, album, move, pretend, fields, affected_albums = set() for item in items: # Item deleted? - if not os.path.exists(syspath(item.path)): + if not item.path or not os.path.exists(syspath(item.path)): ui.print_(format(item)) ui.print_(ui.colorize('text_error', ' deleted')) if not pretend: From 62623d9ee8074f8dc0c69d086e9d5344849e18c7 Mon Sep 17 00:00:00 2001 From: Serene-Arc <33189705+Serene-Arc@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:25:28 +1000 Subject: [PATCH 2/4] Add catch for error when removing file --- beets/util/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 000cc5ac1..11c829ec3 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -452,12 +452,12 @@ def samefile(p1: bytes, p2: bytes) -> bool: return shutil._samefile(syspath(p1), syspath(p2)) -def remove(path: bytes, soft: bool = True): +def remove(path: Optional[bytes], soft: bool = True): """Remove the file. If `soft`, then no error will be raised if the file does not exist. """ path = syspath(path) - if soft and not os.path.exists(path): + if not path or (soft and not os.path.exists(path)): return try: os.remove(path) From 08b5b9fdc741fb36373af3fd7537fc6c062e6494 Mon Sep 17 00:00:00 2001 From: Serene-Arc <33189705+Serene-Arc@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:32:51 +1000 Subject: [PATCH 3/4] Add changelog entry --- docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 39e51ddcb..dae8bbf52 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -229,6 +229,7 @@ Bug fixes: already. A new option ``--noinherit/-I`` to :ref:`modify ` allows changing this behaviour. :bug:`4822` +* Fix bug where an interrupted import process poisons the database. For packagers: From 7f2dfb770dafcf15ce9b5caba9ab47b5e33acd2c Mon Sep 17 00:00:00 2001 From: Serene-Arc <33189705+Serene-Arc@users.noreply.github.com> Date: Sat, 23 Sep 2023 18:53:39 +1000 Subject: [PATCH 4/4] Update changelog entry --- docs/changelog.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index dae8bbf52..e84f5c64b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -229,7 +229,8 @@ Bug fixes: already. A new option ``--noinherit/-I`` to :ref:`modify ` allows changing this behaviour. :bug:`4822` -* Fix bug where an interrupted import process poisons the database. +* Fix bug where an interrupted import process poisons the database, causing + a null path that can't be removed. For packagers: