-
-
Notifications
You must be signed in to change notification settings - Fork 52
Providing Custom Download Links
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). For files that won't be using BaseDownloadURL, you have to provide a DownloadURL (for repair patch '.lzdat' files and incremental patch 'PATCH_CODE.patch' files) and/or InfoURL (for PatchInfo 'PATCH_CODE.info' files). 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
becomeshttps://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.
For each patch file, right click the file in Drive, select "Get shareable link" and paste the link to VersionInfo.
For each patch file:
- select the file and click Share
- click the Create a link button and copy the share link
- replace the
?dl=0
part at the end of the share link with?dl=1
- paste the updated share link (with
?dl=1
) to VersionInfo
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.
First, we'll have to generate a text file holding the download links of the patch files:
- add Download Link Generator for Drive™ to your Drive
- right click the PatchFilesServer directory on Drive and select Open with-Download Link Generator
- after it says "Status: finished", copy the output and paste it inside an empty text file on your computer
- authenticate Download Link Generator for Dropbox™
- 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/ )
- enable the "Automatically share unshared file(s) publicly" option and click Go!
- after it says "Status: finished", copy the output and paste it inside an empty text file on your computer
You have to write a custom server script to help you generate the download links holder.
After you generate a text file holding the download links (i.e. download links holder), 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 download links holder
- 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"
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 download links holder 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:
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).