6081: Crash after double-click on .gpkg file

svn: r22643
This commit is contained in:
Doug Blank 2013-07-03 12:54:19 +00:00
parent 6b8eff0908
commit 9442a5afe8

View File

@ -336,28 +336,30 @@ class CLIDbManager(object):
or (None, None) if no import was performed.
"""
pmgr = BasePluginManager.get_instance()
# Allow URL names here; make temp file if necessary
url = urlparse(filename)
if url.scheme != "":
if url.scheme == "file":
filename = url2pathname(filename[7:])
else:
url_fp = urlopen(filename) # open URL
# make a temp local file:
ext = os.path.splitext(url.path)[1]
fd, filename = tempfile.mkstemp(suffix=ext)
temp_fp = os.fdopen(fd, "w")
# read from URL:
data = url_fp.read()
# write locally:
temp_fp.write(data)
url_fp.close()
from gen.db.dbconst import BDBVERSFN
versionpath = os.path.join(name, BDBVERSFN)
_LOG.debug("Write bsddb version %s" % str(dbase.version()))
with open(versionpath, "w") as version_file:
version_file.write(str(dbase.version()))
temp_fp.close()
# check to see if it isn't a filename directly:
if not os.path.isfile(filename):
# Allow URL names here; make temp file if necessary
url = urlparse(filename)
if url.scheme != "":
if url.scheme == "file":
filename = url2pathname(filename[7:])
else:
url_fp = urlopen(filename) # open URL
# make a temp local file:
ext = os.path.splitext(url.path)[1]
fd, filename = tempfile.mkstemp(suffix=ext)
temp_fp = os.fdopen(fd, "w")
# read from URL:
data = url_fp.read()
# write locally:
temp_fp.write(data)
url_fp.close()
from gen.db.dbconst import BDBVERSFN
versionpath = os.path.join(name, BDBVERSFN)
_LOG.debug("Write bsddb version %s" % str(dbase.version()))
with open(versionpath, "w") as version_file:
version_file.write(str(dbase.version()))
temp_fp.close()
(name, ext) = os.path.splitext(os.path.basename(filename))
format = ext[1:].lower()