compare NFD normalized paths

This commit is contained in:
j 2019-01-14 17:10:40 +05:30
parent 3cd63695c4
commit 74586d7164
2 changed files with 5 additions and 0 deletions

View file

@ -168,6 +168,7 @@ def remove(data):
''' '''
if 'ids' in data and data['ids']: if 'ids' in data and data['ids']:
for i in models.Item.query.filter(models.Item.id.in_(data['ids'])): for i in models.Item.query.filter(models.Item.id.in_(data['ids'])):
logger.info('remove item %s', i)
i.remove_file() i.remove_file()
state.cache.clear('group:') state.cache.clear('group:')
return { return {

View file

@ -7,6 +7,7 @@ import os
import shutil import shutil
import stat import stat
import time import time
import unicodedata
import ox import ox
@ -31,6 +32,7 @@ def remove_missing(books=None):
prefix = get_prefix() prefix = get_prefix()
if books is None: if books is None:
books = collect_books(prefix) books = collect_books(prefix)
books = [unicodedata.normalize('NFD', path) for path in books]
with db.session(): with db.session():
if os.path.exists(prefix): if os.path.exists(prefix):
logger.debug('scan for removed files') logger.debug('scan for removed files')
@ -40,6 +42,8 @@ def remove_missing(books=None):
if state.shutdown: if state.shutdown:
return return
path = f.fullpath() path = f.fullpath()
path = unicode
path = unicodedata.normalize('NFD', path)
db_paths.append(path) db_paths.append(path)
if f.item: if f.item:
items[path] = f.sha1 items[path] = f.sha1