示例#1
0
 def state_migration_step_1(self, state: State) -> bool:
     """
     Migration Step from State Version 0 to 1
     :return:
     """
     if state.is_older_state_version():
         db_dir_v1 = os.path.join(config.user.data_dir,
                                  config.dev.db_name + '2')
         self._tmp_state = State(state._db)  # DB Pointing to Older State
         state._db = db.DB(db_dir_v1)  # DB Pointing to Newer State
         return True
     return False
示例#2
0
    def state_migration_step_2(self, state: State):
        """
        Migration Step from State Version 0 to 1
        :return:
        """
        del self._tmp_state
        self._tmp_state = None
        del state._db

        tmp_db_dir = os.path.join(config.user.data_dir,
                                  config.dev.db_name + "3")
        db_dir = os.path.join(config.user.data_dir, config.dev.db_name)
        shutil.move(db_dir, tmp_db_dir)
        tmp_db_dir = os.path.join(config.user.data_dir,
                                  config.dev.db_name + "2")
        shutil.move(tmp_db_dir, db_dir)
        state._db = db.DB()
        logger.warning("State Migration Finished")