mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
normalize filenames as we sync
user still needs to run "check media" if their fields are encoded incorrectly, but by fixing on the fly we'll ensure mediaSanity doesn't fail
This commit is contained in:
parent
ba8ed39e13
commit
3224a155a7
1 changed files with 9 additions and 0 deletions
|
@ -384,6 +384,15 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0);
|
|||
if not os.path.getsize(f):
|
||||
os.unlink(f)
|
||||
continue
|
||||
# check encoding
|
||||
if not isMac:
|
||||
normf = unicodedata.normalize("NFC", f)
|
||||
if f != normf:
|
||||
# wrong filename encoding which will cause sync errors
|
||||
if os.path.exists(normf):
|
||||
os.unlink(f)
|
||||
else:
|
||||
os.rename(f, normf)
|
||||
# newly added?
|
||||
if f not in self.cache:
|
||||
added.append(f)
|
||||
|
|
Loading…
Reference in a new issue