From c862faddd1a9e259ecf28c28a0c7547aea85f48e Mon Sep 17 00:00:00 2001 From: j Date: Mon, 14 Jan 2019 17:34:28 +0530 Subject: [PATCH] more NFD --- oml/item/models.py | 4 ++-- oml/item/scan.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/oml/item/models.py b/oml/item/models.py index 9448260..959979a 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -788,7 +788,7 @@ class File(db.Model): new_path = os.path.join(first, author, filename) if current_path == os.path.join(prefix, new_path): break - if self.path != new_path: + if unicodedata.normalize('NFD', self.path) != unicodedata.normalize('NFD', new_path): path = os.path.join(prefix, new_path) ox.makedirs(os.path.dirname(path)) mode = 0o644 @@ -797,7 +797,7 @@ class File(db.Model): shutil.move(current_path, path) except: logger.debug('failed to move %s to %s', current_path, path, exc_info=True) - if os.path.exists(path) and os.path.exists(current_path): + if os.path.exists(path): os.unlink(path) return logger.debug('mv "%s" "%s"', self.path, new_path) diff --git a/oml/item/scan.py b/oml/item/scan.py index aa96bdc..4490517 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -150,6 +150,8 @@ def run_scan(): if file: f1 = file.fullpath() f2 = os.path.join(prefix, f) + f1 = unicodedata.normalize('NFD', f1) + f2 = unicodedata.normalize('NFD', f2) if 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) @@ -161,6 +163,8 @@ def run_scan(): if file: f1 = file.fullpath() f2 = os.path.join(prefix, f) + f1 = unicodedata.normalize('NFD', f1) + f2 = unicodedata.normalize('NFD', f2) if 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)