mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Add catch for error when removing file
This commit is contained in:
parent
8ba67674cc
commit
62623d9ee8
1 changed files with 2 additions and 2 deletions
|
|
@ -452,12 +452,12 @@ def samefile(p1: bytes, p2: bytes) -> bool:
|
||||||
return shutil._samefile(syspath(p1), syspath(p2))
|
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
|
"""Remove the file. If `soft`, then no error will be raised if the
|
||||||
file does not exist.
|
file does not exist.
|
||||||
"""
|
"""
|
||||||
path = syspath(path)
|
path = syspath(path)
|
||||||
if soft and not os.path.exists(path):
|
if not path or (soft and not os.path.exists(path)):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue