filehash over the whole file.
This commit is contained in:
parent
3da9846ae3
commit
cf4cc2cd93
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||||
</startup>
|
</startup>
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
@ -20,11 +20,11 @@ namespace KattekerCreator
|
|||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("Changelog")]
|
[DisplayName("Changelog")]
|
||||||
[Description("Filename of the changelog file")]
|
[Description("Path of the changelog file")]
|
||||||
public string ChangeLog
|
public string ChangeLog
|
||||||
{
|
{
|
||||||
get => _changeLog;
|
get => _changeLog;
|
||||||
set => SetPropertyIfNotDefault(ref _changeLog, value);
|
set => SetPropertyIfNotDefault(ref _changeLog, Path.GetFullPath(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("Channel")]
|
[DisplayName("Channel")]
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Katteker;
|
|
||||||
using Semver;
|
using Semver;
|
||||||
using TsudaKageyu;
|
using TsudaKageyu;
|
||||||
using Vestris.ResourceLib;
|
using Vestris.ResourceLib;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>KattekerCreator</RootNamespace>
|
<RootNamespace>KattekerCreator</RootNamespace>
|
||||||
<AssemblyName>KattekerCreator</AssemblyName>
|
<AssemblyName>KattekerCreator</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||||
<RestorePackages>true</RestorePackages>
|
<RestorePackages>true</RestorePackages>
|
||||||
|
@ -109,9 +109,10 @@ namespace KattekerCreator
|
|||||||
if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir);
|
if (!Directory.Exists(_appArguments.OutputDir)) Directory.CreateDirectory(_appArguments.OutputDir);
|
||||||
if (!string.IsNullOrEmpty(_appArguments.ChangeLog))
|
if (!string.IsNullOrEmpty(_appArguments.ChangeLog))
|
||||||
{
|
{
|
||||||
var changeLogPath = Path.Combine(Path.GetDirectoryName(_appArguments.ProgramFile), _appArguments.ChangeLog);
|
var changeLogFilename = Path.GetFileName(_appArguments.ChangeLog);
|
||||||
if (!File.Exists(changeLogPath)) throw new FileNotFoundException(changeLogPath);
|
|
||||||
File.Copy(changeLogPath, Path.Combine(_appArguments.OutputDir, _appArguments.ChangeLog), true);
|
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);
|
File.Copy(setupFilePath, Path.Combine(_appArguments.OutputDir, setupFile), true);
|
||||||
}
|
}
|
||||||
@ -145,7 +146,7 @@ namespace KattekerCreator
|
|||||||
var kattekerConfig = new KattekerConfig
|
var kattekerConfig = new KattekerConfig
|
||||||
{
|
{
|
||||||
Publish = _appArguments.PublishDir ?? _appArguments.OutputDir,
|
Publish = _appArguments.PublishDir ?? _appArguments.OutputDir,
|
||||||
Changelog = _appArguments.ChangeLog
|
Changelog = Path.GetFileName(_appArguments.ChangeLog)
|
||||||
};
|
};
|
||||||
kattekerConfig.WriteToFile(pathToFile);
|
kattekerConfig.WriteToFile(pathToFile);
|
||||||
return pathToFile;
|
return pathToFile;
|
||||||
|
@ -15,7 +15,7 @@ namespace Katteker.Test
|
|||||||
public void Sha1ChecksumOfFile()
|
public void Sha1ChecksumOfFile()
|
||||||
{
|
{
|
||||||
var actual = Utility.ComputeFileHash(ExampleFile);
|
var actual = Utility.ComputeFileHash(ExampleFile);
|
||||||
const string expected = "0zgDmFuotnldZIyADoWrpiSDUx4=";
|
const string expected = "maFpV7FK3EtnU2G5+q2nZ1E3YKY=";
|
||||||
Assert.AreEqual(expected, actual);
|
Assert.AreEqual(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,21 +30,18 @@ namespace Katteker
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compute file hash with SHA1.
|
/// Compute file hash with SHA1.
|
||||||
/// If the file is greater than 5 MB, the hash will only computed with the first 5 MB.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename"></param>
|
/// <param name="filename"></param>
|
||||||
/// <returns></returns>
|
/// <returns>Returns the hash as base64 string</returns>
|
||||||
internal static string ComputeFileHash(string filename)
|
internal static string ComputeFileHash(string filename)
|
||||||
{
|
{
|
||||||
string sha1;
|
string sha1;
|
||||||
var fileInfo = new FileInfo(filename);
|
var fileInfo = new FileInfo(filename);
|
||||||
|
|
||||||
|
using (var sha1Managed = new SHA1Managed())
|
||||||
using (var fileStream = fileInfo.OpenRead())
|
using (var fileStream = fileInfo.OpenRead())
|
||||||
{
|
{
|
||||||
var buffer = new byte[5242880];
|
sha1 = Convert.ToBase64String(sha1Managed.ComputeHash(fileStream));
|
||||||
fileStream.Read(buffer, 0, buffer.Length);
|
|
||||||
var sha1Managed = new SHA1Managed();
|
|
||||||
sha1 = Convert.ToBase64String(sha1Managed.ComputeHash(buffer));
|
|
||||||
}
|
}
|
||||||
return sha1;
|
return sha1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user