mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Fix regression that was causing files to not be removed from disk when removing a format from a book
This commit is contained in:
parent
651d609784
commit
8ea22bb7cc
@ -688,16 +688,15 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
|
|
||||||
def remove_format(self, index, format, index_is_id=False, notify=True):
|
def remove_format(self, index, format, index_is_id=False, notify=True):
|
||||||
id = index if index_is_id else self.id(index)
|
id = index if index_is_id else self.id(index)
|
||||||
path = os.path.join(self.library_path, self.path(id, index_is_id=True))
|
path = os.path.join(self.library_path, *self.path(id, index_is_id=True).split(os.sep))
|
||||||
name = self.conn.get('SELECT name FROM data WHERE book=? AND format=?', (id, format), all=False)
|
name = self.conn.get('SELECT name FROM data WHERE book=? AND format=?', (id, format), all=False)
|
||||||
name = name[0] if name else False
|
|
||||||
if name:
|
if name:
|
||||||
ext = ('.' + format.lower()) if format else ''
|
ext = ('.' + format.lower()) if format else ''
|
||||||
path = os.path.join(path, name+ext)
|
path = os.path.join(path, name+ext)
|
||||||
try:
|
try:
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
except:
|
except:
|
||||||
pass
|
traceback.print_exc()
|
||||||
self.conn.execute('DELETE FROM data WHERE book=? AND format=?', (id, format.upper()))
|
self.conn.execute('DELETE FROM data WHERE book=? AND format=?', (id, format.upper()))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
self.refresh_ids([id])
|
self.refresh_ids([id])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user