Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/Filo/Core/FiloWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ManuHub.Filo.Utils;
using ManuHub.Filo.Shared;
using ManuHub.Filo.Utils;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
Expand Down Expand Up @@ -145,7 +146,7 @@ public async Task WriteAsync()

while ((read = await fs.ReadAsync(buffer)) > 0)
{
var offset = output.Position;
var chunkStartOffset = output.Position;
byte[] chunk = buffer[..read];

string hash = Convert.ToHexString(SHA256.HashData(chunk));
Expand All @@ -162,8 +163,8 @@ public async Task WriteAsync()
entry.Chunks.Add(new FiloChunkIndex
{
Id = chunkId++,
Offset = offset,
Length = encrypted.Length,
Offset = chunkStartOffset,
Length = FiloConstants.IvSize + FiloConstants.LengthSize + encrypted.Length,
Hash = hash
});
}
Expand All @@ -175,8 +176,8 @@ public async Task WriteAsync()
entry.Chunks.Add(new FiloChunkIndex
{
Id = chunkId++,
Offset = offset,
Length = read,
Offset = chunkStartOffset,
Length = FiloConstants.LengthSize + read,
Hash = hash
});
}
Expand Down
9 changes: 9 additions & 0 deletions src/Filo/Shared/FiloConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace ManuHub.Filo.Shared;

public static class FiloConstants
{
public const string FooterMagic = "FLOF";

public const int IvSize = 16;
public const int LengthSize = 4;
}
Loading