mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
don't fall over if cwd doesn't exist
This commit is contained in:
parent
b89dde97a8
commit
abf6e3fa13
1 changed files with 7 additions and 2 deletions
|
@ -23,7 +23,11 @@ class MediaManager(object):
|
|||
self._dir = re.sub("(?i)\.(anki2)$", ".media", self.col.path)
|
||||
if not os.path.exists(self._dir):
|
||||
os.makedirs(self._dir)
|
||||
try:
|
||||
self._oldcwd = os.getcwd()
|
||||
except OSError:
|
||||
# cwd doesn't exist
|
||||
self._oldcwd = None
|
||||
os.chdir(self._dir)
|
||||
# change database
|
||||
self.connect()
|
||||
|
@ -43,6 +47,7 @@ class MediaManager(object):
|
|||
self.db.close()
|
||||
self.db = None
|
||||
# change cwd back to old location
|
||||
if self._oldcwd:
|
||||
os.chdir(self._oldcwd)
|
||||
|
||||
def dir(self):
|
||||
|
|
Loading…
Reference in a new issue