perf: compute hash while writing

This commit is contained in:
Anna 2024-02-17 22:49:36 -05:00
parent 4f4e168583
commit 0abe73ad41
Signed by: anna
GPG Key ID: D0943384CD9F87D1
1 changed files with 2 additions and 3 deletions

View File

@ -58,12 +58,11 @@ internal class Command : IDisposable {
return;
}
using var stream = this.OpenFile(ext);
using var stream = new Blake3Stream(this.OpenFile(ext));
stream.Write(imageData);
var meta = ScreenshotMetadata.Capture(this.Plugin);
var hash = new Blake3HashAlgorithm().ComputeHash(imageData);
meta.Blake3Hash = Convert.ToHexString(hash);
meta.Blake3Hash = Convert.ToHexString(stream.ComputeHash().AsSpan());
var json = JsonConvert.SerializeObject(meta, Formatting.Indented);
Plugin.Log.Info(json);