From f0525a76fb41938ccc71c79ca79562d2a6cd3fc4 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 13 Dec 2013 20:24:39 +0900 Subject: [PATCH] if we renamed any files to nfc, need to rerun check --- anki/__init__.py | 2 +- anki/media.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/anki/__init__.py b/anki/__init__.py index b54587f97..530807a95 100644 --- a/anki/__init__.py +++ b/anki/__init__.py @@ -30,6 +30,6 @@ if arch[1] == "ELF": sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % ( sys.version_info[1], arch[0][0:2]))) -version="2.0.19" # build scripts grep this line, so preserve formatting +version="2.0.20" # build scripts grep this line, so preserve formatting from anki.storage import Collection __all__ = ["Collection"] diff --git a/anki/media.py b/anki/media.py index 9826ae6f1..a96135315 100644 --- a/anki/media.py +++ b/anki/media.py @@ -217,6 +217,7 @@ class MediaManager(object): files = os.listdir(mdir) else: files = local + renamedFiles = False for file in files: if not local: if not os.path.isfile(file): @@ -236,14 +237,20 @@ class MediaManager(object): # delete if we already have the NFC form, otherwise rename if os.path.exists(nfcFile): os.unlink(file) + renamedFiles = True else: os.rename(file, nfcFile) + renamedFiles = True file = nfcFile # compare if nfcFile not in allRefs: unused.append(file) else: allRefs.discard(nfcFile) + # if we renamed any files to nfc format, we must rerun the check + # to make sure the renamed files are not marked as unused + if renamedFiles: + return self.check(local=local) nohave = [x for x in allRefs if not x.startswith("_")] return (nohave, unused, invalid)