Added check for database connection problem on config

This commit is contained in:
Adolfo Gómez García 2021-11-26 11:52:49 +01:00
parent eb4be53508
commit bde63f7b4f

View File

@ -111,13 +111,17 @@ class Config:
readed.field_type = self._type readed.field_type = self._type
readed.save(update_fields=['field_type']) readed.save(update_fields=['field_type'])
self._type = readed.field_type self._type = readed.field_type
except Exception: except DBConfig.DoesNotExist:
# Not found # Not found, so we create it
if self._default != '' and self._crypt: if self._default != '' and self._crypt:
self.set(cryptoManager().decrypt(self._default)) self.set(cryptoManager().decrypt(self._default))
elif not self._crypt: elif not self._crypt:
self.set(self._default) self.set(self._default)
self._data = self._default self._data = self._default
except Exception as e:
logger.info('Error accessing db config {0}.{1}'.format(self._section.name(), self._key))
logger.exception(e)
self._data = self._default
if self._crypt: if self._crypt:
return cryptoManager().decrypt(typing.cast(str, self._data)) return cryptoManager().decrypt(typing.cast(str, self._data))