newdb: Fix move_library() broken on case-insenstive file systems

get_top_level_move_items() was not checking that the items it returned
actually existed on case-insensitive file systems. This bug is actually
present in olddb as well.
This commit is contained in:
Kovid Goyal 2013-08-06 11:39:09 +05:30
parent 666248454b
commit 562f8f16b4
2 changed files with 5 additions and 2 deletions

View File

@ -1485,7 +1485,7 @@ class DB(object):
if not self.is_case_sensitive:
for x in items:
path_map[x.lower()] = x
items = set(path_map)
items = {x.lower() for x in items}
paths = {x.lower() for x in paths}
items = items.intersection(paths)
return items, path_map

View File

@ -167,7 +167,6 @@ class LegacyTest(BaseTest):
for meth, args in {
'find_identical_books': [(Metadata('title one', ['author one']),), (Metadata('unknown'),), (Metadata('xxxx'),)],
'get_top_level_move_items': [()],
'get_books_for_category': [('tags', newstag), ('#formats', 'FMT1')],
'get_next_series_num_for': [('A Series One',)],
'get_id_from_uuid':[('ddddd',), (db.uuid(1, True),)],
@ -241,6 +240,10 @@ class LegacyTest(BaseTest):
for a in args:
self.assertEqual(fmt(getattr(db, meth)(*a)), fmt(getattr(ndb, meth)(*a)),
'The method: %s() returned different results for argument %s' % (meth, a))
def f(x, y): # get_top_level_move_items is broken in the old db on case-insensitive file systems
x.discard('metadata_db_prefs_backup.json')
return x, y
self.assertEqual(f(*db.get_top_level_move_items()), f(*ndb.get_top_level_move_items()))
d1, d2 = BytesIO(), BytesIO()
db.copy_cover_to(1, d1, True)
ndb.copy_cover_to(1, d2, True)