Skip to content

Instantly share code, notes, and snippets.

@Forkk
Last active December 30, 2015 01:09
Show Gist options
  • Save Forkk/7753959 to your computer and use it in GitHub Desktop.
Save Forkk/7753959 to your computer and use it in GitHub Desktop.
Design doc for MultiMC's update checker and downloader.

Vocabulary

Before we start, I'd like to define some vocabulary that has been a source of confusion in previous discussions of MultiMC's versioning and update systems. This is the vocabulary that will be used throughout this design document.

  • branch - Refers to a branch on the Git repository. Nothing more, nothing less.
  • channel - Channels are separate "types" of builds (don't call them types), usually built off of different branches of the code. For example, there may be a "stable" channel and "develop" channel for stable and development builds.
  • repository / update repository - A GoUpdate repository.
  • builder - A single Buildbot build configuration.

Compile Time Configuration

Naturally, MultiMC needs to be able to know the URL for its update repository in order to check for and download updates. This is done through arguments passed to CMake at compile time:

  • MultiMC_CHANLIST_URL - The URL for the channel list file. The channel list file is a JSON file described in the "Channel List" section below.
  • MultiMC_VERSION_CHANNEL - The channel that the current build of MultiMC came from.

Both of these options are passed to the CMakeLists file and put into the config.h header.

Channel List

The only information MultiMC is compiled with is the channel list URL. At this URL is a JSON file with a list of objects containing the following fields:

  • id - A short string, uniquely identifying the channel. For example, "stable" or "develop".
  • name - The channel's name as it should be displayed to the user. For example, "Stable", or "Development".
  • description - A short description string that will be shown to the user to explain what this channel is for.
  • url - The URL for the channel's GoUpdate repository.

Rather than simply having a "use development builds" checkbox in the settings menu like MultiMC 4, MultiMC 5 will show a list of channels and allow the user to select from one of the channels in the list.

Checking for Updates

Checking for updates is a fairly simple process.

  1. MultiMC checks whether its current channel is the same as the channel the user has selected. If not, then it prompts the user to update.
  2. If the current channel is the same as the channel the user selected, MultiMC downloads the channel list, finds the channel that the user has selected, and gets its repository URL.
  3. MultiMC downloads the repository index from the repository URL it got from the channel list and gets the version with the highest ID number.
  4. If the ID number from that version is not equal to the ID number for MultiMC's build number, MultiMC downloads and installs that version. The processes for downloading and installing a version are described in the "Downloading Updates" and "Installing Updates" sections below.

Downloading Updates

Naturally, once an update is found, the next step is to download that update. On Windows, MultiMC itself is unable to swap out the binaries for itself and its libraries while it is running. To get around this problem, MultiMC uses a special external program to install the update. In order to use this, MultiMC needs to download all the files for the update and build a set of instructions for how to install them. These instructions will then be passed to the binary swapper.

During the process of preparing for updates, MultiMC needs to build up an "operations list". The operations list describes what operations MultiMC needs to do during updates. Such operations may include "copy file x to path y" and "delete file at path x". This operations list serves as the list of instructions that will be passed to the binary swapper.

While preparing for updates, MultiMC also needs to build a list of files to download into the updatefiles folder. MultiMC will download each file it needs to download for the new version into this updatefiles folder and add a copy operation to the operations list to have the update installer copy the file to wherever it is supposed to be installed.

First, MultiMC parses the version files for both the current and the new version and compares the file lists for both versions.

For each file in the current version's file list, it does the following.

  1. Check to see if there is an entry in the new version's file list with the same path and MD5sum and, if not, add a delete operation to the operations list to delete that file.

For each file in the new version's file list, it does the following.

  1. Check to see if there is a file with the same path and MD5sum in MultiMC's folder and, if not, add the file to the download list and add a copy operation to the operations list to copy the downloaded file to its installation path.

Installing Updates

TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment