Merge branch 'master' of https://git.boerchers.org/holger/Katteker
This commit is contained in:
commit
26343921f7
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
@ -10,6 +10,7 @@ namespace KattekerCreator
|
||||
private string _outputDir;
|
||||
private string _programFile;
|
||||
private string _publishDir;
|
||||
private string _version;
|
||||
|
||||
[DisplayName("Program")]
|
||||
[Description("Path to the program file")]
|
||||
@ -20,11 +21,11 @@ namespace KattekerCreator
|
||||
}
|
||||
|
||||
[DisplayName("Changelog")]
|
||||
[Description("Filename of the changelog file")]
|
||||
[Description("Path of the changelog file")]
|
||||
public string ChangeLog
|
||||
{
|
||||
get => _changeLog;
|
||||
set => SetPropertyIfNotDefault(ref _changeLog, value);
|
||||
set => SetPropertyIfNotDefault(ref _changeLog, Path.GetFullPath(value));
|
||||
}
|
||||
|
||||
[DisplayName("Channel")]
|
||||
@ -51,6 +52,14 @@ namespace KattekerCreator
|
||||
set => SetPropertyIfNotDefault(ref _publishDir, value);
|
||||
}
|
||||
|
||||
[DisplayName("Version")]
|
||||
[Description("Override version number of the application.")]
|
||||
public string Version
|
||||
{
|
||||
get => _version;
|
||||
set => SetPropertyIfNotDefault(ref _version, value);
|
||||
}
|
||||
|
||||
private static bool SetPropertyIfNotDefault<T>(ref T field, T value)
|
||||
{
|
||||
if (Equals(value, field)) return false;
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Katteker;
|
||||
using Semver;
|
||||
using TsudaKageyu;
|
||||
using Vestris.ResourceLib;
|
||||
@ -16,17 +15,17 @@ namespace KattekerCreator
|
||||
private readonly string _description;
|
||||
private readonly string _productName;
|
||||
|
||||
public AssemblyFileInfo(string fileName, string tempDir)
|
||||
public AssemblyFileInfo(ApplicationArguments appArguments, string tempDir)
|
||||
{
|
||||
FileInfo = new FileInfo(fileName);
|
||||
FileInfo = new FileInfo(appArguments.ProgramFile);
|
||||
using (var resourceInfo = new ResourceInfo())
|
||||
{
|
||||
resourceInfo.Load(fileName);
|
||||
resourceInfo.Load(appArguments.ProgramFile);
|
||||
if (resourceInfo.ResourceTypes.All(x => x.ResourceType != Kernel32.ResourceTypes.RT_VERSION)) return;
|
||||
var versionResource = (VersionResource) resourceInfo[Kernel32.ResourceTypes.RT_VERSION].First();
|
||||
var stringFileInfo = ((StringFileInfo) versionResource[nameof(StringFileInfo)]).Strings
|
||||
.FirstOrDefault().Value;
|
||||
AssemblyIconPath = GetAssemblyIcon(fileName, tempDir);
|
||||
AssemblyIconPath = GetAssemblyIcon(appArguments.ProgramFile, tempDir);
|
||||
if (stringFileInfo.Strings.ContainsKey("CompanyName"))
|
||||
_company = stringFileInfo.Strings["CompanyName"].StringValue.TrimEnd('\0');
|
||||
if (stringFileInfo.Strings.ContainsKey("FileDescription"))
|
||||
@ -36,14 +35,13 @@ namespace KattekerCreator
|
||||
if (stringFileInfo.Strings.ContainsKey("ProductName"))
|
||||
_productName = stringFileInfo.Strings["ProductName"].StringValue.TrimEnd('\0');
|
||||
if (!stringFileInfo.Strings.ContainsKey("ProductVersion")) return;
|
||||
AssemblyVersion =
|
||||
GetSemanticVersion(stringFileInfo.Strings["ProductVersion"].StringValue.TrimEnd('\0'));
|
||||
AssemblyVersion = appArguments.Version != null ? GetSemanticVersion(appArguments.Version) : GetSemanticVersion(stringFileInfo.Strings["ProductVersion"].StringValue.TrimEnd('\0'));
|
||||
}
|
||||
}
|
||||
|
||||
public string AssemblyIconPath { get; }
|
||||
|
||||
public SemVersion AssemblyVersion { get; private set; }
|
||||
public SemVersion AssemblyVersion { get; }
|
||||
|
||||
public string Company => _company ?? string.Empty;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace KattekerCreator.Helper
|
||||
{
|
||||
@ -9,17 +10,17 @@ namespace KattekerCreator.Helper
|
||||
|
||||
public static void WriteInfoLine(string text)
|
||||
{
|
||||
using (var c = new ConsoleWithOtherColor())
|
||||
using (new ConsoleWithOtherColor())
|
||||
{
|
||||
c.WriteLine($"{Info} [{DateTime.Now:G}] {text}");
|
||||
ConsoleWithOtherColor.WriteLine($"{Info} [{DateTime.Now:G}] {text}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteErrorLine(string text)
|
||||
{
|
||||
using (var c = new ConsoleWithOtherColor(ConsoleColor.DarkRed))
|
||||
using (new ConsoleWithOtherColor(ConsoleColor.DarkRed))
|
||||
{
|
||||
c.WriteLine($"{Error} [{DateTime.Now:G}] {text}");
|
||||
ConsoleWithOtherColor.WriteLine($"{Error} [{DateTime.Now:G}] {text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,13 +39,20 @@ namespace KattekerCreator.Helper
|
||||
Console.ForegroundColor = color;
|
||||
}
|
||||
|
||||
public void WriteLine(string text)
|
||||
public static void WriteLine(string text)
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposing) return;
|
||||
if (_defaultColor != null) Console.ForegroundColor = _defaultColor.Value;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>KattekerCreator</RootNamespace>
|
||||
<AssemblyName>KattekerCreator</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
|
@ -56,7 +56,7 @@ namespace KattekerCreator
|
||||
//Modify AppStub
|
||||
var appStubFile = ModifyAppStub();
|
||||
//Acquire infos from Executable.
|
||||
_assemblyFileInfo = new AssemblyFileInfo(_appArguments.ProgramFile, _tempDir);
|
||||
_assemblyFileInfo = new AssemblyFileInfo(_appArguments, _tempDir);
|
||||
var configFile = CreateConfigFile();
|
||||
|
||||
//Generate NSIS-Script
|
||||
@ -109,9 +109,10 @@ namespace KattekerCreator
|
||||
if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir);
|
||||
if (!string.IsNullOrEmpty(_appArguments.ChangeLog))
|
||||
{
|
||||
var changeLogPath = Path.Combine(Path.GetDirectoryName(_appArguments.ProgramFile), _appArguments.ChangeLog);
|
||||
if (!File.Exists(changeLogPath)) throw new FileNotFoundException(changeLogPath);
|
||||
File.Copy(changeLogPath, Path.Combine(_appArguments.OutputDir, _appArguments.ChangeLog), true);
|
||||
var changeLogFilename = Path.GetFileName(_appArguments.ChangeLog);
|
||||
|
||||
if (!File.Exists(_appArguments.ChangeLog)) throw new FileNotFoundException(_appArguments.ChangeLog);
|
||||
File.Copy(_appArguments.ChangeLog, Path.Combine(_appArguments.OutputDir, changeLogFilename), true);
|
||||
}
|
||||
File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true);
|
||||
}
|
||||
@ -145,7 +146,7 @@ namespace KattekerCreator
|
||||
var kattekerConfig = new KattekerConfig
|
||||
{
|
||||
Publish = _appArguments.PublishDir ?? _appArguments.OutputDir,
|
||||
Changelog = _appArguments.ChangeLog
|
||||
Changelog = Path.GetFileName(_appArguments.ChangeLog)
|
||||
};
|
||||
kattekerConfig.WriteToFile(pathToFile);
|
||||
return pathToFile;
|
||||
|
@ -42,6 +42,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Wrapper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
|
41
Katteker.Gui/NativeMethods.cs
Normal file
41
Katteker.Gui/NativeMethods.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace Katteker.Gui
|
||||
{
|
||||
/// <summary>
|
||||
/// Native methods.
|
||||
/// </summary>
|
||||
public static class NativeMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// Hit Test Caption
|
||||
/// </summary>
|
||||
public const int HTCAPTION = 0x2;
|
||||
|
||||
/// <summary>
|
||||
/// Posted when the user presses the left mouse button while the cursor is within the nonclient area of a window.
|
||||
/// </summary>
|
||||
public const int WM_NCLBUTTONDOWN = 0xA1;
|
||||
|
||||
/// <summary>
|
||||
/// Release the capture
|
||||
/// </summary>
|
||||
[DllImport("User32.dll")]
|
||||
public static extern bool ReleaseCapture();
|
||||
|
||||
/// <summary>
|
||||
/// Send message
|
||||
/// </summary>
|
||||
[DllImport("User32.dll")]
|
||||
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
|
||||
/// <summary>
|
||||
/// Set Process API aware
|
||||
/// </summary>
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetProcessDPIAware();
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using Katteker.Gui.Properties;
|
||||
|
||||
@ -9,13 +8,11 @@ namespace Katteker.Gui
|
||||
{
|
||||
public sealed partial class UpdateWindow : Form
|
||||
{
|
||||
private readonly UpdateManager _updateManager;
|
||||
private readonly ReleaseEntry _entry;
|
||||
private const int HTCAPTION = 0x2;
|
||||
private const int WM_NCLBUTTONDOWN = 0xA1;
|
||||
private readonly UpdateManager _updateManager;
|
||||
|
||||
/// <summary>
|
||||
/// The Update Window
|
||||
/// The Update Window
|
||||
/// </summary>
|
||||
public UpdateWindow(UpdateManager updateManager, ReleaseEntry entry)
|
||||
{
|
||||
@ -24,36 +21,25 @@ namespace Katteker.Gui
|
||||
Font = SystemFonts.MessageBoxFont;
|
||||
Application.EnableVisualStyles();
|
||||
if (Environment.OSVersion.Version.Major >= 6)
|
||||
SetProcessDPIAware();
|
||||
NativeMethods.SetProcessDPIAware();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private string Changelog => _updateManager.ChangelogFilename;
|
||||
|
||||
private string PublishPath => _updateManager.UrlOrPath;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
components?.Dispose();
|
||||
}
|
||||
if (disposing) components?.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
private static extern bool ReleaseCapture();
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetProcessDPIAware();
|
||||
private void CloseBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
@ -76,9 +62,10 @@ namespace Katteker.Gui
|
||||
MaximizeBtn_Click(sender, e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Button != MouseButtons.Left) return;
|
||||
ReleaseCapture();
|
||||
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
|
||||
NativeMethods.ReleaseCapture();
|
||||
NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTCAPTION, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -137,9 +124,9 @@ namespace Katteker.Gui
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(Resources.CouldNotUpdateYourApplication + Environment.NewLine + ex.Message, Gui.Properties.Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(Resources.CouldNotUpdateYourApplication + Environment.NewLine + ex.Message,
|
||||
Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
WriteTitle(Resources.Updater);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />
|
||||
<Import Project="..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@ -39,10 +39,10 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
<HintPath>..\packages\MSTest.TestFramework.1.3.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
<HintPath>..\packages\MSTest.TestFramework.1.3.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -51,9 +51,6 @@
|
||||
<Compile Include="KattekerLibTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="testdata\Example.exe">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@ -65,14 +62,17 @@
|
||||
<Name>Katteker</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" />
|
||||
<Import Project="..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.0\build\net45\MSTest.TestAdapter.targets')" />
|
||||
</Project>
|
@ -15,7 +15,7 @@ namespace Katteker.Test
|
||||
public void Sha1ChecksumOfFile()
|
||||
{
|
||||
var actual = Utility.ComputeFileHash(ExampleFile);
|
||||
const string expected = "0zgDmFuotnldZIyADoWrpiSDUx4=";
|
||||
const string expected = "maFpV7FK3EtnU2G5+q2nZ1E3YKY=";
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net461" />
|
||||
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net461" />
|
||||
<package id="MSTest.TestAdapter" version="1.3.0" targetFramework="net461" />
|
||||
<package id="MSTest.TestFramework" version="1.3.0" targetFramework="net461" />
|
||||
</packages>
|
@ -22,7 +22,6 @@ namespace Katteker
|
||||
[DataMember]
|
||||
public string Changelog { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read file and deserialize content.
|
||||
/// </summary>
|
||||
@ -36,7 +35,7 @@ namespace Katteker
|
||||
using (var fileStream = File.OpenRead(path))
|
||||
{
|
||||
var obj = dataContractJsonSerializer.ReadObject(fileStream);
|
||||
return (KattekerConfig) obj;
|
||||
return (KattekerConfig)obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Semver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Semver;
|
||||
|
||||
namespace Katteker
|
||||
{
|
||||
@ -59,26 +59,32 @@ namespace Katteker
|
||||
/// Version
|
||||
/// </summary>
|
||||
public SemVersion Version { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Hashsum of the file.
|
||||
/// </summary>
|
||||
public string SHA1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// filename
|
||||
/// </summary>
|
||||
public string Filename { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Size of the file.
|
||||
/// </summary>
|
||||
public long Filesize { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is true if the update is delta file. False otherwise.
|
||||
/// </summary>
|
||||
public bool IsDelta { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the application.
|
||||
/// </summary>
|
||||
public string ApplicationName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Format the release entry as line for release file.
|
||||
/// </summary>
|
||||
|
@ -81,6 +81,10 @@ namespace Katteker
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for updates
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<ReleaseEntry>> CheckForUpdateAsync()
|
||||
{
|
||||
_releases = Utility.IsWebUrl(_urlOrPath) ? await DownloadIndexAsync(_urlOrPath).ConfigureAwait(false) : GetFromFilesystem(_urlOrPath);
|
||||
|
@ -30,21 +30,18 @@ namespace Katteker
|
||||
|
||||
/// <summary>
|
||||
/// Compute file hash with SHA1.
|
||||
/// If the file is greater than 5 MB, the hash will only computed with the first 5 MB.
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
/// <returns>Returns the hash as base64 string</returns>
|
||||
internal static string ComputeFileHash(string filename)
|
||||
{
|
||||
string sha1;
|
||||
var fileInfo = new FileInfo(filename);
|
||||
|
||||
using (var sha1Managed = new SHA1Managed())
|
||||
using (var fileStream = fileInfo.OpenRead())
|
||||
{
|
||||
var buffer = new byte[5242880];
|
||||
fileStream.Read(buffer, 0, buffer.Length);
|
||||
var sha1Managed = new SHA1Managed();
|
||||
sha1 = Convert.ToBase64String(sha1Managed.ComputeHash(buffer));
|
||||
sha1 = Convert.ToBase64String(sha1Managed.ComputeHash(fileStream));
|
||||
}
|
||||
return sha1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user