mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
if we renamed any files to nfc, need to rerun check
This commit is contained in:
parent
ab81227dac
commit
f0525a76fb
2 changed files with 8 additions and 1 deletions
|
@ -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"]
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue