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] 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)