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: 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) diff --git a/docs/changelog.rst b/docs/changelog.rst index eb80cce74..330e74f22 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -233,6 +233,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, causing + a null path that can't be removed. For packagers: