Skip to content

Commit

Permalink
new version 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
prrvchr committed Apr 16, 2024
1 parent c7c1e8d commit 57199cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
14 changes: 7 additions & 7 deletions uno/lib/uno/embedded/documenthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def queryClosing(self, event, owner):
with self._lock:
document = event.Source
if self._closeDataBase(document):
self._removeFolder()
self.removeFolder()
self._url = None
self._logger.logprb(INFO, 'DocumentHandler', 'queryClosing()', 202, url)

Expand All @@ -97,7 +97,7 @@ def notifyStorageChange(self, document, storage):
with self._lock:
newpath, newfolder = self._getDataBaseInfo(url)
if self._switchDataBase(document, storage, newfolder):
self._removeFolder()
self.removeFolder()
self._path = newpath
self._folder = newfolder
self._url = url
Expand Down Expand Up @@ -128,6 +128,11 @@ def setListener(self, document):
# FIXME: If storage has been changed the closeListener has been removed
document.addCloseListener(self)

def removeFolder(self):
sf = getSimpleFile(self._ctx)
if sf.isFolder(self._path):
sf.kill(self._path)

# DocumentHandler getter methods
def getConnectionUrl(self, storage):
with self._lock:
Expand Down Expand Up @@ -246,11 +251,6 @@ def _extractStorage(self, sf, source, url):
source.dispose()
return count

def _removeFolder(self):
sf = getSimpleFile(self._ctx)
if sf.isFolder(self._path):
sf.kill(self._path)

def _getPath(self, path, name):
return '%s/%s' % (path, name)

31 changes: 17 additions & 14 deletions uno/lib/uno/embedded/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,27 @@ def __init__(self, ctx, lock, service, name, index):

# XDriver
def connect(self, url, infos):
# XXX: We need to test first if jdbcDriverOOo is installed...
driver = self._getDriver()
newinfos, document, storage, location = self._getConnectionInfo(infos)
if storage is None or location is None:
self._logException(112, url, ' ')
raise self._getException(1001, None, 111, url, '\n')
# XXX: Calling handler unpacks the database files
handler = self._getDocumentHandler(location)
path = handler.getConnectionUrl(storage)
self._logger.logprb(INFO, 'Driver', 'connect()', 113, location)
try:
newinfos, document, storage, location = self._getConnectionInfo(infos)
if storage is None or location is None:
self._logException(112, url, ' ')
raise self._getException(1001, None, 111, url, '\n')
handler = self._getDocumentHandler(location)
path = handler.getConnectionUrl(storage)
self._logger.logprb(INFO, 'Driver', 'connect()', 113, location)
connection = self._getDriver().connect(path, newinfos)
version = connection.getMetaData().getDriverVersion()
handler.setListener(document)
self._logger.logprb(INFO, 'Driver', 'connect()', 114, g_dbname, version, g_user)
return connection
except SQLException as e:
raise e
connection = driver.connect(path, newinfos)
except Exception as e:
self._logger.logprb(SEVERE, 'Driver', 'connect()', 115, str(e), traceback.format_exc())
handler.removeFolder()
raise e
# XXX: Connection has been done we can add close and change listener to document
handler.setListener(document)
version = connection.getMetaData().getDriverVersion()
self._logger.logprb(INFO, 'Driver', 'connect()', 114, g_dbname, version, g_user)
return connection

def acceptsURL(self, url):
accept = url.startswith(g_url)
Expand Down

0 comments on commit 57199cb

Please sign in to comment.