Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Providing Custom Download Links

Süleyman Yasir KULA edited this page Nov 24, 2018 · 10 revisions

Some servers may not be suitable for BaseDownloadURL, e.g. Google Drive™ and Dropbox™ use unique ids in their download links. Or, you may want to use custom download urls for some files (rest of the files will be downloaded from BaseDownloadURL). In those cases, you have to provide a DownloadURL for repair patch files, InfoURL for PatchInfo files (PATCH_CODE.info) and DownloadURL for incremental patch files (PATCH_CODE.patch) that won't be using BaseDownloadURL. There are two ways to do so:

  • Manual: you basically fetch the download link of each file manually and paste it to VersionInfo by hand. With this method, you must handle the escaped XML characters correctly in the download links (e.g. https://myserver.com/fileUrl&export=download becomes https://myserver.com/fileUrl&export=download)
  • Automated: a text file that holds the download links of the patch files in {File relative path} {File download url} format (one file per line) is used to automatically update the download links. With this method, the main challenge is to generate the text file holding the download links. Please note that it's optional to enter "RepairPatch/" or "IncrementalPatch/" to the "File relative path"

In either way, the steps to update the download links depend on where you've hosted the patch files. This tutorial assumes that the patch files (RepairPatch and IncrementalPatch directories) are stored in a directory called PatchFilesServer on your server.

A. Manual Method

Google Drive™

For each patch file, right click the file in Drive, select "Get shareable link" and paste the link to VersionInfo.

Dropbox™

For each patch file:

  1. select the file and click Share
  2. click the Create a link button and copy the share link
  3. replace the ?dl=0 part at the end of the share link with ?dl=1
  4. paste the updated share link (with ?dl=1) to VersionInfo

Custom Server

If BaseDownloadURL is not an option for your server, for each patch file, make sure that the file is public and paste its download url to VersionInfo.

B. Automated Method

B.1. Generating Download Links Holder

First, we'll have to generate a text file holding the download links of the patch files:

Google Drive™

  1. add Download Link Generator for Drive™ to your Drive
  2. right click the PatchFilesServer directory on Drive and select Open with-Download Link Generator
  3. after it says "Status: finished", copy the output and paste it inside an empty text file on your computer

Dropbox™

  1. authenticate Download Link Generator for Dropbox™
  2. enter the path of the PatchFilesServer directory to the "Path to file/folder:" field (e.g. if PatchFilesServer resides at the root of your Dropbox, simply enter PatchFilesServer/ )
  3. enable the "Automatically share unshared file(s) publicly" option and click Go!
  4. after it says "Status: finished", copy the output and paste it inside an empty text file on your computer

Custom Server

You have to write a custom script for your server to automatically generate the text file holding the download links of the patch files.

B.2. Updating Download Links

After you generate a text file holding the download links, it is time to update the download links in VersionInfo using this file:

Use the Patcher update_links command:

  • versionInfoPath: path of the VersionInfo.info file
  • linksPath: path of the text file holding the download links of the patch files in the following format (one file per line): {File relative path} {File download url}
  • silent: (optional)(flag) progress will not be logged to the console

Example: Patcher update_links -versionInfoPath="C:\Users\USERNAME\Desktop\PatchFiles\VersionInfo.info" -linksPath="C:\Users\USERNAME\Desktop\links.txt"

Via Scripting API

Namespace: SimplePatchToolCore

public PatchUpdater( string versionInfoPath, LogEvent logger = null ): creates a new PatchUpdater instance. Path of the VersionInfo.info file should be passed to the versionInfoPath parameter. If a function is provided to logger (which has the signature delegate void LogEvent( string log )), this function will be called for each log. Otherwise, PatchUpdater will work silently. Please note that PatchUpdater works synchronously

bool UpdateDownloadLinks( string downloadLinksPath ): updates the download links of the files inside VersionInfo using the text file located at downloadLinksPath. Returns false, if downloadLinksPath doesn't point to an existing text file

bool UpdateDownloadLinks( Dictionary<string, string> downloadLinks ): updates the download links of the files inside VersionInfo using downloadLinks dictionary (its key-value pairs should store {File relative path} {File download url}). Currently, this function always returns true

VersionInfo VersionInfo { get; }: returns the VersionInfo that this PatchUpdater is modifying. Feel free to make any changes to this VersionInfo object

void SaveChanges(): updates the VersionInfo.info file. Call this function after executing the UpdateDownloadLinks function or changing the properties of VersionInfo

Example code: SimplePatchToolConsoleApp.Program.UpdateLinks

Open Window-Simple Patch Tool window and switch to the UPDATE tab:

unity-update-tab

These parameters correspond to the versionInfoPath and linksPath arguments mentioned in the console app section. If you want, you can copy&paste the download links directly to the specified text field so that you won't have to create a text file for the links (in this case, simply leave Download links holder blank).

Clone this wiki locally