Skip to content

Commit

Permalink
Fixed a bug where it didn't recognize previous version of Updater as …
Browse files Browse the repository at this point in the history
…legit.
  • Loading branch information
GregaMohorko committed Sep 24, 2020
1 parent 163a5e2 commit 1b6e0e3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
Binary file added Documentation/Icon/BlueUpdate Icon 128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ In order to use the `BlueUpdate` toolkit, you must have your own web directory i

Before using the `Update` class, you must set the `UpdatableApp.Current`, which represents the currently running application. This must be done in order to check if the currently running application was installed correctly, to set the root directory, etc.. Every application must be inside the directory with the same name as the application itself. The recommended install path format is: *`/MyCompany/My App/My App.exe`*. The root directory of this example is *`/MyCompany`*. This way, you can have multiple applications inside your companies root directory.

When you use the `Update` class for the first time, its static initializer will check if the updater is installed inside the root directory. If I follow the previous path example, the updater would be installed in *`/MyCompany/Updater`*. If the updater is not yet installed, it will install it. The updater is very small (~1 MB).
When you use the `Update` class for the first time, its static initializer will check if the updater is installed inside the root directory. If I follow the previous path example, the updater would be installed in *`/MyCompany/Updater`*. If the updater is not yet installed, it will install it. The updater is very small (~398 KB).

The `Update.Check()` simply checks if the latest version of the application is greater than the current. If it is, then it needs to be updated.
The `Update.Run()` starts the updater application, which will update the currently running application. That is why the currently running application must close immediately after that, otherwise the updater will not be able to update/modify the files of the application.
Expand Down
4 changes: 2 additions & 2 deletions src/BlueUpdate/BlueUpdate Updater/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4.0")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyVersion("1.0.4.1")]
[assembly: AssemblyFileVersion("1.0.4.1")]
12 changes: 8 additions & 4 deletions src/BlueUpdate/BlueUpdate/BlueUpdate.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@
<license type="file">LICENSE.md</license>
<projectUrl>https://github.com/GregaMohorko/BlueUpdate</projectUrl>
<repository type="git" url="https://github.com/GregaMohorko/BlueUpdate.git" branch="master" />
<icon>BlueUpdate Icon.png</icon>
<icon>BlueUpdate Icon 128x128.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>$copyright$</copyright>
<tags>Update Updater Version Check Checksum Deployment Install</tags>
<releaseNotes>Enabled SourceLink.</releaseNotes>
<releaseNotes>Fixed a bug where it didn't recognize previous version of Updater as legit.</releaseNotes>
<dependencies>
<dependency id="GM.Utility" version="1.3.0" />
<group targetFramework=".NETFramework4.7.1">
</group>
<group>
<dependency id="GM.Utility" version="1.3.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="readme.txt" />
<file src="..\..\..\Documentation\Icon\BlueUpdate Icon.png" target="" />
<file src="..\..\..\Documentation\Icon\BlueUpdate Icon 128x128.png" target="" />
<file src="..\..\..\LICENSE.md" target="" />
</files>
</package>
4 changes: 2 additions & 2 deletions src/BlueUpdate/BlueUpdate/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4.0")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyVersion("1.0.4.1")]
[assembly: AssemblyFileVersion("1.0.4.1")]
11 changes: 8 additions & 3 deletions src/BlueUpdate/BlueUpdate/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ namespace BlueUpdate
{
public static class Update
{
/// <summary>
/// For backward compatibility, include all previous company names.
/// </summary>
private static string[] GetAllPastCompanyNames() => new string[] { "Grega Mohorko" };

/// <summary>
/// Root directory of all applications.
/// </summary>
Expand Down Expand Up @@ -78,7 +83,7 @@ static Update()
if(updaterFileInfo != null) {
ReflectionUtility.AssemblyInformation assembly = ReflectionUtility.GetAssemblyInformation(ReflectionUtility.GetAssembly(ReflectionUtility.AssemblyType.CURRENT));

if(updaterFileInfo.CompanyName != assembly.Company || updaterFileInfo.ProductName != BlueUpdateConstants.UPDATER_NAME) {
if((updaterFileInfo.CompanyName != assembly.Company && !GetAllPastCompanyNames().Contains(updaterFileInfo.CompanyName)) || updaterFileInfo.ProductName != BlueUpdateConstants.UPDATER_NAME) {
throw new Exception("Updater executable is not legit.");
}
Version currentVersion = Version.Parse(updaterFileInfo.FileVersion);
Expand All @@ -98,8 +103,8 @@ static Update()
UpdateUtility.Update(Updater);
}
}catch(Exception e) {
MessageBox.Show($"Error while initializing BlueUpdate:{Environment.NewLine}{Environment.NewLine}{e.Message}");
throw e;
_ = MessageBox.Show($"Error while initializing BlueUpdate:{Environment.NewLine}{Environment.NewLine}{e.Message}");
throw;
}
}

Expand Down

0 comments on commit 1b6e0e3

Please sign in to comment.