normalize to nfc when sending media in sync

This commit is contained in:
Damien Elmes 2013-10-16 08:37:34 +09:00
parent 5bf0a31c51
commit 6be7503543

View File

@ -2,15 +2,21 @@
# Copyright: Damien Elmes <anki@ichi2.net> # Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os, shutil, re, urllib, unicodedata, \ import os
sys, zipfile import re
import send2trash import urllib
import unicodedata
import sys
import zipfile
from cStringIO import StringIO from cStringIO import StringIO
import send2trash
from anki.utils import checksum, isWin, isMac, json from anki.utils import checksum, isWin, isMac, json
from anki.db import DB from anki.db import DB
from anki.consts import * from anki.consts import *
from anki.latex import mungeQA from anki.latex import mungeQA
class MediaManager(object): class MediaManager(object):
soundRegexps = ["(?i)(\[sound:(?P<fname>[^]]+)\])"] soundRegexps = ["(?i)(\[sound:(?P<fname>[^]]+)\])"]
@ -356,7 +362,7 @@ class MediaManager(object):
# the later forgetAdded() call easier # the later forgetAdded() call easier
fnames.append([fname]) fnames.append([fname])
z.write(fname, str(cnt)) z.write(fname, str(cnt))
files[str(cnt)] = fname files[str(cnt)] = unicodedata.normalize("NFC", fname)
sz += os.path.getsize(fname) sz += os.path.getsize(fname)
if sz > SYNC_ZIP_SIZE or cnt > SYNC_ZIP_COUNT: if sz > SYNC_ZIP_SIZE or cnt > SYNC_ZIP_COUNT:
break break