def startup_for_frontend(obj, thread): """Run the startup code needed to get the frontend started This function should be kept as small as possible to ensure good startup times. """ threadcheck.set_eventloop_thread(thread) logging.info("Installing deleted file checker...") item.setup_deleted_checker() logging.info("Restoring database...") start = time.time() app.db = storedatabase.LiveStorage() try: app.db.upgrade_database() except databaseupgrade.DatabaseTooNewError: summary = _("Database too new") description = _( "You have a database that was saved with a newer version of " "%(appname)s. You must download the latest version of " "%(appname)s and run that.", {"appname": app.config.get(prefs.SHORT_APP_NAME)}, ) raise StartupError(summary, description) except storedatabase.UpgradeErrorSendCrashReport, e: send_startup_crash_report(e.report) return
def test_preallocate(self): # test preallocating space preallocate = 512 * 1024 # 512KB path = os.path.join(self.tempdir, 'testdb') storage = storedatabase.LiveStorage(path, preallocate=preallocate) # check while open self.check_preallocate_size(path, preallocate) # check that it remains that big after close storage.close() self.check_preallocate_size(path, preallocate)
def finish_startup(obj, thread): database.set_thread(thread) logging.info("Installing deleted file checker...") item.setup_deleted_checker() logging.info("Restoring database...") start = time.time() app.db = storedatabase.LiveStorage() try: app.db.upgrade_database() except databaseupgrade.DatabaseTooNewError: summary = _("Database too new") description = _( "You have a database that was saved with a newer version of " "%(appname)s. You must download the latest version of " "%(appname)s and run that.", {"appname": app.config.get(prefs.SHORT_APP_NAME)}, ) raise StartupError(summary, description) except storedatabase.UpgradeErrorSendCrashReport, e: send_startup_crash_report(e.report) return
def setup_new_database(self, path, schema_version, object_schemas): app.db = storedatabase.LiveStorage(path, schema_version=schema_version, object_schemas=object_schemas) app.db.raise_load_errors = self.raise_db_load_errors
def setup_new_database(self, path, **kwargs): app.db = storedatabase.LiveStorage(path, **kwargs) app.db.raise_load_errors = self.raise_db_load_errors