Uranium
Application Framework
UM.VersionUpgradeManager.VersionUpgradeManager Class Reference

Regulates the upgrading of configuration from one application version to the next. More...

Public Member Functions

def getInstance (cls)
 Gets the instance of the VersionUpgradeManager, or creates one. More...
 
def __init__ (self)
 Initialises the version upgrade manager. More...
 
def getStoragePaths
 Gets the paths where a specified type of file should be stored. More...
 
def setCurrentVersions (self, current_versions)
 Changes the target versions to upgrade to. More...
 
def registerCurrentVersion
 
def upgrade (self)
 Performs the version upgrades of all configuration files to the most recent version. More...
 
def upgradeExtraFile
 Schedules an additional file for upgrading. More...
 
def copyVersionFolder
 
def getFileVersion
 Gets the version of the given file data.
 
def updateFilesData
 

Detailed Description

Regulates the upgrading of configuration from one application version to the next.

The process of upgrading will take a look at all profiles, preferences and machine instances and check their version numbers. If they are older than the current version number of their respective type of file, an upgrade route will be planned for it in order to upgrade the file to the current version in as few conversions as possible.

To this end, the upgrade manager will maintain the shortest routes to the current version for each of the types of profiles and each old version it encounters. Once a shortest route is found, it is cached and can be re-used for all nodes along this route. This minimises the extra start-up time required for the conversions.

Old versions of the configuration are not deleted, but put in a folder next to the current (upgraded) versions, where they are never loaded again unless the user manually retrieves the files.

Constructor & Destructor Documentation

◆ __init__()

def UM.VersionUpgradeManager.VersionUpgradeManager.__init__ (   self)

Initialises the version upgrade manager.

This initialises the cache for shortest upgrade routes, and registers the version upgrade plug-ins.

Member Function Documentation

◆ getInstance()

def UM.VersionUpgradeManager.VersionUpgradeManager.getInstance (   cls,
  VersionUpgradeManager 
)

Gets the instance of the VersionUpgradeManager, or creates one.

◆ getStoragePaths()

def UM.VersionUpgradeManager.VersionUpgradeManager.getStoragePaths (   self,
  configuration_type 
)

Gets the paths where a specified type of file should be stored.

This differs from the storage path in the Resources class, since it also knows where to store old file types. This information is gathered from the upgrade plug-ins.

Parameters
configuration_typeThe type of configuration to be stored.
Returns
A set of storage paths for the specified configuration type.

◆ setCurrentVersions()

def UM.VersionUpgradeManager.VersionUpgradeManager.setCurrentVersions (   self,
  current_versions,
  None 
)

Changes the target versions to upgrade to.

Parameters
current_versionsA dictionary of tuples of configuration types and their versions currently in use, and with each of these a tuple of where to store this type of file and its MIME type.

◆ upgrade()

def UM.VersionUpgradeManager.VersionUpgradeManager.upgrade (   self,
  bool 
)

Performs the version upgrades of all configuration files to the most recent version.

The upgrade plug-ins must all be loaded at this point, or no upgrades can be performed.

Returns
True if anything was upgraded, or False if it was already up to date.

◆ upgradeExtraFile()

def UM.VersionUpgradeManager.VersionUpgradeManager.upgradeExtraFile (   self,
  storage_path 
)

Schedules an additional file for upgrading.

This method is intended to be called by upgrade plug-ins during upgrading, to make sure we also upgrade any extra files that should be added during the upgrade process. Note that the file is not immediately upgraded, but scheduled for upgrading. If this method is called while the upgrade() function is still running, it will get upgraded at the end of that run. If it is called while the upgrade() function is not running, it would get upgraded during the next call to upgrade().

Parameters
storage_pathThe path to where the specified type of file is stored.
file_nameThe path to the file to upgrade, relative to the storage path.
configuration_typeThe file type of the specified file.

The documentation for this class was generated from the following file: