mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
fix media dir problem on win32, fix unicode issues with media
This commit is contained in:
parent
2aecbffafe
commit
7e74fe3844
2 changed files with 5 additions and 4 deletions
|
@ -1366,6 +1366,9 @@ where id = :id""", pending)
|
|||
if self.path:
|
||||
# file-backed
|
||||
dir = re.sub("(?i)\.(anki)$", ".media", self.path)
|
||||
if create == None:
|
||||
# don't create, but return dir
|
||||
return dir
|
||||
if not os.path.exists(dir) and create:
|
||||
try:
|
||||
os.mkdir(dir)
|
||||
|
@ -1391,10 +1394,9 @@ Return new path, relative to media dir."""
|
|||
def renameMediaDir(self, oldPath):
|
||||
"Copy oldPath to our current media dir. "
|
||||
assert os.path.exists(oldPath)
|
||||
newPath = self.mediaDir(create=True)
|
||||
newPath = self.mediaDir(create=None)
|
||||
# copytree doesn't want the dir to exist
|
||||
try:
|
||||
os.rmdir(newPath)
|
||||
shutil.copytree(oldPath, newPath)
|
||||
except:
|
||||
# FIXME: should really remove everything in old dir instead of
|
||||
|
|
|
@ -68,8 +68,7 @@ Update media table. If file already exists, don't copy."""
|
|||
# case insensitive filesystems suck
|
||||
pass
|
||||
else:
|
||||
shutil.copy2(path.encode(sys.getfilesystemencoding()),
|
||||
new.encode(sys.getfilesystemencoding()))
|
||||
shutil.copy2(path, new)
|
||||
newSize = os.stat(new)[stat.ST_SIZE]
|
||||
if not deck.s.scalar(
|
||||
"select 1 from media where filename = :f",
|
||||
|
|
Loading…
Reference in a new issue