Skip to content

Commit

Permalink
Fixed missed filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
Azyyyyyy committed Jan 7, 2024
1 parent 082152b commit b4d89f4
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Packages/TinyUpdate.TUUP/TuupUpdatePackageCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,13 @@ async Task<bool> FindAndAddMovedFile(string newSha256Hash, string relativeNewFil
var filepath = relativeNewFile + Consts.MovedFileExtension;
using (await _zipLock.LockAsync())
{
CheckFilePath(ref filepath);

await using var zipShasumEntryStream = zipArchive.CreateEntry(filepath, CompressionLevel.SmallestSize).Open();
await using var shasumStreamWriter = new StreamWriter(zipShasumEntryStream);
var path = Path.GetRelativePath(oldApplicationLocation, oldFile);

if (Path.DirectorySeparatorChar != '\\')
{
path = path.Replace(Path.DirectorySeparatorChar, '\\');
}
CheckFilePath(ref path);
await shasumStreamWriter.WriteAsync(path);
}

Expand Down Expand Up @@ -177,11 +176,8 @@ private Task<bool> AddSameFile(ZipArchive zipArchive, string filepath, string ha

private async Task<bool> AddFile(ZipArchive zipArchive, Stream fileContentStream, string filepath, string? sha256Hash = null)
{
if (Path.DirectorySeparatorChar != '\\')
{
filepath = filepath.Replace(Path.DirectorySeparatorChar, '\\');
}

CheckFilePath(ref filepath);

//Add the file
using (await _zipLock.LockAsync())
{
Expand All @@ -196,8 +192,18 @@ private async Task<bool> AddFile(ZipArchive zipArchive, Stream fileContentStream
return true;
}

private void CheckFilePath(ref string filepath)
{
if (Path.DirectorySeparatorChar != '\\')
{
filepath = filepath.Replace(Path.DirectorySeparatorChar, '\\');
}
}

private async Task AddHashAndSizeData(ZipArchive zipArchive, string filepath, string sha256Hash, long filesize)
{
CheckFilePath(ref filepath);

using (await _zipLock.LockAsync())
{
await using var zipShasumEntryStream = zipArchive.CreateEntry(Path.ChangeExtension(filepath, Consts.ShasumFileExtension), CompressionLevel.SmallestSize).Open();
Expand Down

0 comments on commit b4d89f4

Please sign in to comment.