mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -05:00
don't leak fds in upgrade
This commit is contained in:
parent
caf46e948a
commit
ad81a564d1
2 changed files with 4 additions and 2 deletions
|
|
@ -113,7 +113,7 @@ analyze;""")
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def _openDB(self, path):
|
def _openDB(self, path):
|
||||||
(fd, self.tmppath) = tmpfile(suffix=".anki2")
|
self.tmppath = tmpfile(suffix=".anki2")
|
||||||
shutil.copy(path, self.tmppath)
|
shutil.copy(path, self.tmppath)
|
||||||
self.db = DB(self.tmppath)
|
self.db = DB(self.tmppath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,9 @@ def tmpdir():
|
||||||
return _tmpdir
|
return _tmpdir
|
||||||
|
|
||||||
def tmpfile(prefix="", suffix=""):
|
def tmpfile(prefix="", suffix=""):
|
||||||
return tempfile.mkstemp(dir=tmpdir(), prefix=prefix, suffix=suffix)
|
(fd, name) = tempfile.mkstemp(dir=tmpdir(), prefix=prefix, suffix=suffix)
|
||||||
|
os.close(fd)
|
||||||
|
return name
|
||||||
|
|
||||||
def namedtmp(name):
|
def namedtmp(name):
|
||||||
"Return tmpdir+name. Deletes any existing file."
|
"Return tmpdir+name. Deletes any existing file."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue