refactor: use provided file hash
This commit is contained in:
parent
396b3f60a8
commit
89ef950432
|
@ -51,22 +51,12 @@ func (store DbFileStore) NewUpload(ctx context.Context, info handler.FileInfo) (
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = file.Close()
|
err = file.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -74,7 +64,7 @@ func (store DbFileStore) NewUpload(ctx context.Context, info handler.FileInfo) (
|
||||||
upload := &fileUpload{
|
upload := &fileUpload{
|
||||||
info: info,
|
info: info,
|
||||||
binPath: binPath,
|
binPath: binPath,
|
||||||
hash: hex.EncodeToString(hash),
|
hash: info.MetaData["blake3-hash"],
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeInfo creates the file by itself if necessary
|
// writeInfo creates the file by itself if necessary
|
||||||
|
|
Loading…
Reference in New Issue