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

Updating Download Links in VersionInfo

Süleyman Yasir KULA edited this page Aug 27, 2018 · 17 revisions

With SimplePatchTool, you have two options for download links inside VersionInfo.info:

  • enter a <BaseDownloadURL> (e.g. http://myserver.com/dl?) and when SimplePatchTool attempts to download e.g. MyDir/file.bin, it will be downloaded from http://myserver.com/dl?MyDir/file.bin.lzdat. In other words, relative path of the file will be appended to the BaseDownloadURL to form a download url. This approach also works for PatchInfo files, so e.g. 1_0__1_1.info will be downloaded from http://myserver.com/dl?1_0__1_1.info
  • enter custom InfoURLs and DownloadURLs for the IncrementalPatch'es and custom <DownloadURL>s for the VersionItem's (repair files). If you want, you can provide custom download urls for only a selection of files, and the rest will be downloaded from the BaseDownloadURL

Some servers may not be suitable for BaseDownloadURL, e.g. Google Drive™ and Dropbox™ use unique ids in download links. In those cases, you have to provide a DownloadURL/InfoURL for each file. 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&amp;export=download)
  • Automated: a text file that holds the download links of the patch files in {File relative path} {File download url} format (one line per patch file) is used to automatically update the download links. With this method, the main challenge is to generate the text file holding the download links

In either way, the steps to update the download links depend on where you've hosted the patch files. This tutorial assumes that patch files (VersionInfo.info, any incremental patches and the RepairFiles directory) are stored in a directory called PatchFiles.

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 possible, use a BaseDownloadURL for the repair files. You can handle incremental patch files in one of two ways:

  • move them into the RepairFiles subdirectory of the PatchFiles directory and then they will be downloaded via BaseDownloadURL, as well
  • fill the InfoURLs (for PATCH_CODE.info files) and the DownloadURLs (for PATCH_CODE.patch files) inside VersionInfo manually

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

Local File System (For Testing Purposes)

Move the incremental patch files into the RepairFiles subdirectory and use its path as BaseDownloadURL (e.g. <BaseDownloadURL>file://C:\Users\USERNAME\Desktop\PatchFiles\RepairFiles\</BaseDownloadURL>).

B. Automated Method

NOTE: if your incremental patch files reside outside the RepairFiles subdirectory of the PatchFiles directory, you have to provide their InfoURLs (for PATCH_CODE.info files) and DownloadURLs (for PATCH_CODE.patch files) manually.

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 RepairFiles subdirectory of the PatchFiles 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 RepairFiles subdirectory of the PatchFiles directory to the "Path to file/folder:" field (e.g. if PatchFiles directory resides at the root of your Dropbox, enter PatchFiles/RepairFiles/)
  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.

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

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

Clone this wiki locally