Content Sureness
This commit is contained in:
@@ -425,6 +425,11 @@ func writeResourceData(w io.Writer, resource Resource) error {
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// The hash is computed while streaming into w, so size/SHA mismatches are
|
||||
// only detected AFTER the (bad) bytes have already been written. A non-nil
|
||||
// return therefore means w holds partially-written, unverified output; the
|
||||
// caller must discard it. writeHAKArchive does this by writing to a temp file
|
||||
// and removing it on any Write error rather than renaming it into place.
|
||||
hash := sha256.New()
|
||||
written, err := io.Copy(io.MultiWriter(w, hash), file)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user