Merge pull request #4906 from Serene-Arc/poisoned_db_fix

This commit is contained in:
Serene 2023-09-23 18:53:53 +10:00 committed by GitHub
commit 7736ae7634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View file

@ -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:

View file

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

View file

@ -233,6 +233,8 @@ Bug fixes:
already. A new option ``--noinherit/-I`` to :ref:`modify <modify-cmd>`
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: