Skip to content

Commit

Permalink
Fix previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Sep 15, 2024
1 parent 1c9d07f commit 6b34653
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions v2/Event.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const (
EVT_AFTER_HEADER_DECODING = 8 // Compression header decoding ends

EVT_HASH_NONE = 0
EVT_HASH_32BITS = 1
EVT_HASH_64BITS = 2
EVT_HASH_32BITS = 32
EVT_HASH_64BITS = 64
)

// Event a compression/decompression event
Expand Down
5 changes: 3 additions & 2 deletions v2/io/CompressedStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ type encodingTaskResult struct {
// Use headerless == false to create a bitstream without a header. The decompressor
// must know all the compression parameters to be able to decompress the bitstream.
// The headerless mode is only useful in very specific scenarios.
func NewWriter(os io.WriteCloser, transform, entropy string, blockSize, jobs uint, checksum bool, fileSize int64, headerless bool) (*Writer, error) {
// checksum must be 0, 32 or 64
func NewWriter(os io.WriteCloser, transform, entropy string, blockSize, jobs uint, checksum uint, fileSize int64, headerless bool) (*Writer, error) {
ctx := make(map[string]any)
ctx["entropy"] = entropy
ctx["transform"] = transform
Expand Down Expand Up @@ -1791,7 +1792,7 @@ func (this *decodingTask) decode(res *decodingTaskResult) {
res.err = &IOError{msg: errMsg, code: kanzi.ERR_CRC_CHECK}
return
}
} else if this.hasher32 != nil {
} else if this.hasher64 != nil {
checksum2 := this.hasher64.Hash(data[0:decoded])

if checksum2 != checksum1 {
Expand Down
6 changes: 3 additions & 3 deletions v2/io/CompressedStream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func compress(block []byte, entropy, transform string) int {
}

// Create a Writer
w, err2 := NewWriter(output, transform, entropy, blockSize, jobs, true, 0, false)
w, err2 := NewWriter(output, transform, entropy, blockSize, jobs, 32, 0, false)

if err2 != nil {
fmt.Printf("%v\n", err2)
Expand Down Expand Up @@ -186,7 +186,7 @@ func compressAfterWriteClose(block []byte) int {
copy(buf, block)
bs := internal.NewBufferStream()

os, err := NewWriter(bs, "NONE", "HUFFMAN", uint(len(block)), 1, false, 0, false)
os, err := NewWriter(bs, "NONE", "HUFFMAN", uint(len(block)), 1, 0, 0, false)

if err != nil {
fmt.Printf("%v\n", err)
Expand Down Expand Up @@ -219,7 +219,7 @@ func compressAfterReadClose(block []byte) int {
fmt.Println("Test - read after close")
bs := internal.NewBufferStream()

os, err := NewWriter(bs, "NONE", "NONE", uint(len(block)), 1, false, 0, false)
os, err := NewWriter(bs, "NONE", "NONE", uint(len(block)), 1, 0, 0, false)

if err != nil {
fmt.Printf("%v\n", err)
Expand Down

0 comments on commit 6b34653

Please sign in to comment.