mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix a regression in the previous release that could result in empty author folders remaining in the library when the author of a book is changed
This commit is contained in:
parent
4bb9c9fba8
commit
970ca5293e
@ -1872,6 +1872,9 @@ class DB:
|
|||||||
|
|
||||||
if os.path.exists(spath):
|
if os.path.exists(spath):
|
||||||
copy_tree(os.path.abspath(spath), tpath, delete_source=True, transform_destination_filename=transform_format_filenames)
|
copy_tree(os.path.abspath(spath), tpath, delete_source=True, transform_destination_filename=transform_format_filenames)
|
||||||
|
parent = os.path.dirname(spath)
|
||||||
|
with suppress(OSError):
|
||||||
|
os.rmdir(parent) # remove empty parent directory
|
||||||
else:
|
else:
|
||||||
os.makedirs(tpath)
|
os.makedirs(tpath)
|
||||||
update_paths_in_db()
|
update_paths_in_db()
|
||||||
|
@ -127,7 +127,10 @@ class FilesystemTest(BaseTest):
|
|||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
cache.set_metadata(1, Metadata('t1', ('a1', 'a2')))
|
cache.set_metadata(1, Metadata('t1', ('a1', 'a2')))
|
||||||
check_that_filesystem_and_db_entries_match(1)
|
check_that_filesystem_and_db_entries_match(1)
|
||||||
|
# check that empty author folders are removed
|
||||||
|
for x in os.scandir(cache.backend.library_path):
|
||||||
|
if x.is_dir():
|
||||||
|
self.assertTrue(os.listdir(x.path))
|
||||||
|
|
||||||
@unittest.skipUnless(iswindows, 'Windows only')
|
@unittest.skipUnless(iswindows, 'Windows only')
|
||||||
def test_windows_atomic_move(self):
|
def test_windows_atomic_move(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user