From ab46fa0a70b4ef6bfe1a9fa88d3afdc9002b502f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 15 Jan 2013 07:43:10 +0900 Subject: [PATCH] don't fail when importing apkg that references subdirs --- anki/importing/anki2.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/anki/importing/anki2.py b/anki/importing/anki2.py index c6a0143c2..0df5e39ab 100644 --- a/anki/importing/anki2.py +++ b/anki/importing/anki2.py @@ -323,7 +323,11 @@ insert or ignore into revlog values (?,?,?,?,?,?,?,?,?)""", revlog) def _writeDstMedia(self, fname, data): path = os.path.join(self.dst.media.dir(), fname) - open(path, "wb").write(data) + try: + open(path, "wb").write(data) + except (OSError, IOError): + # the user likely used subdirectories + pass def _mungeMedia(self, mid, fields): fields = splitFields(fields)