refactor: use provided file hash

This commit is contained in:
Derrick Hammer 2023-05-23 20:14:21 -04:00
parent 396b3f60a8
commit 89ef950432
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 12 deletions

View File

@ -51,22 +51,12 @@ func (store DbFileStore) NewUpload(ctx context.Context, info handler.FileInfo) (
}
return nil, err
}
err = file.Close()
if err != nil {
return nil, err
}
hasher := blake3.New(64, nil)
_, err = io.Copy(hasher, file)
if err != nil {
return nil, err
}
var hash []byte
_, err = hasher.XOF().Read(hash)
if err != nil {
return nil, err
}
@ -74,7 +64,7 @@ func (store DbFileStore) NewUpload(ctx context.Context, info handler.FileInfo) (
upload := &fileUpload{
info: info,
binPath: binPath,
hash: hex.EncodeToString(hash),
hash: info.MetaData["blake3-hash"],
}
// writeInfo creates the file by itself if necessary