compare NFC

This commit is contained in:
j 2019-01-14 20:32:34 +05:30
commit 52f45beaec
4 changed files with 11 additions and 7 deletions

View file

@ -14,7 +14,7 @@ import ox
from changelog import add_record
from item.models import File, Item
from user.models import List
from utils import remove_empty_folders
from utils import remove_empty_folders, same_path
from websocket import trigger_event
import db
import media
@ -132,8 +132,6 @@ def collect_books(prefix, status=None):
logger.debug('found %s books', len(books))
return books
def nfd_same(f1, f2):
return unicodedata.normalize('NFD', f1) == unicodedata.normalize('NFD', f2)
def run_scan():
logger.debug('run_scan')
@ -155,7 +153,7 @@ def run_scan():
if file:
f1 = file.fullpath()
f2 = os.path.join(prefix, f)
if not nfd_same(f1, f2) and os.path.exists(f1) and os.path.exists(f2):
if not same_path(f1, f2) and os.path.exists(f1) and os.path.exists(f2):
logger.debug('file exists in multiple locations %s', id)
logger.debug('"%s" vs "%s"', f1, f2)
os.chmod(f2, stat.S_IWRITE)
@ -166,7 +164,7 @@ def run_scan():
if file:
f1 = file.fullpath()
f2 = os.path.join(prefix, f)
if not nfd_same(f1, f2) and os.path.exists(f1) and os.path.exists(f2):
if not same_path(f1, f2) and os.path.exists(f1) and os.path.exists(f2):
logger.debug('"%s" vs "%s"', f1, f2)
os.chmod(f2, stat.S_IWRITE)
os.unlink(f2)