-
-
Notifications
You must be signed in to change notification settings - Fork 52
Updating Download Links in VersionInfo
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 fromhttp://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 fromhttp://myserver.com/dl?1_0__1_1.info
- enter custom
InfoURL
s andDownloadURL
s 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
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 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.
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 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
InfoURL
s (for PATCH_CODE.info files) and theDownloadURL
s (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.
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>
).
NOTE: if your incremental patch files reside outside the RepairFiles subdirectory of the PatchFiles directory, you have to provide their InfoURL
s (for PATCH_CODE.info files) and DownloadURL
s (for PATCH_CODE.patch files) manually.
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 RepairFiles subdirectory of the PatchFiles 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 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/)
- 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 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"
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