def _upgrade_database(self): self.startup_version = current_version = self._get_version() if current_version > self._schema_version: msg = _("Database was created by a newer version of Miro " + "(db version is %(version)s)", {"version": current_version}) raise databaseupgrade.DatabaseTooNewError(msg) if current_version < self._schema_version: dbupgradeprogress.upgrade_start() try: self._upgrade_20_database() # need to pull the variable again here because # _upgrade_20_database will have done an upgrade current_version = self._get_version() self._change_database_file(current_version) databaseupgrade.new_style_upgrade(self.cursor, current_version, self._schema_version) self._set_version() self._change_database_file_back() finally: dbupgradeprogress.upgrade_end() self.current_version = self._schema_version
except storedatabase.UpgradeError: raise StartupError(None, None) database.initialize() downloader.reset_download_stats() end = time.time() logging.timing("Database upgrade time: %.3f", end - start) if app.db.startup_version != app.db.current_version: databaselog.info("Upgraded database from version %s to %s", app.db.startup_version, app.db.current_version) databaselog.print_old_log_entries() models.initialize() if DEBUG_DB_MEM_USAGE: util.db_mem_usage_test() mem_usage_test_event.set() dbupgradeprogress.upgrade_end() app.startup_timer.log_time("after db upgrade") app.icon_cache_updater = iconcache.IconCacheUpdater() setup_global_feeds() # call fix_database_inconsistencies() ASAP after the manual feed is set up fix_database_inconsistencies() logging.info("setup tabs...") setup_tabs() logging.info("setup theme...") setup_theme() install_message_handler() app.sharing_manager = sharing.SharingManager()
logging.timing("Database upgrade time: %.3f", end - start) if app.db.startup_version != app.db.current_version: databaselog.info("Upgraded database from version %s to %s", app.db.startup_version, app.db.current_version) databaselog.print_old_log_entries() models.initialize() if DEBUG_DB_MEM_USAGE: util.db_mem_usage_test() mem_usage_test_event.set() # MetadataProgressUpdater needs to be installed before ItemInfoCache, # since ItemInfoCache may create items if it uses failsafe mode app.metadata_progress_updater = metadataprogress.MetadataProgressUpdater() app.item_info_cache = iteminfocache.ItemInfoCache() app.item_info_cache.load() dbupgradeprogress.upgrade_end() logging.info("Loading video converters...") conversions.conversion_manager.startup() app.device_manager = devices.DeviceManager() app.device_tracker = devicetracker.DeviceTracker() searchengines.create_engines() setup_global_feeds() # call fix_database_inconsistencies() ASAP after the manual feed is set up fix_database_inconsistencies() logging.info("setup tabs...") setup_tabs() logging.info("setup theme...") setup_theme() install_message_handler()