[archiver] Switch to using Blake3 instead of SHA256.
This commit is contained in:
parent
2d988264f6
commit
b584611a06
3 changed files with 10 additions and 4 deletions
|
@ -3,7 +3,6 @@
|
|||
package archiver
|
||||
|
||||
|
||||
import "crypto/sha256"
|
||||
import "encoding/hex"
|
||||
import "encoding/json"
|
||||
import "flag"
|
||||
|
@ -20,6 +19,7 @@ import "syscall"
|
|||
import "time"
|
||||
|
||||
import "github.com/colinmarc/cdb"
|
||||
import "github.com/zeebo/blake3"
|
||||
import "go.etcd.io/bbolt"
|
||||
|
||||
import . "github.com/volution/kawipiko/lib/common"
|
||||
|
@ -93,7 +93,7 @@ func archiveFile (_context *context, _pathResolved string, _pathInArchive string
|
|||
}
|
||||
|
||||
_fileIdText := fmt.Sprintf ("%d.%d-%d-%d.%d", _fileDev, _fileInode, _fileSize, _fileTimestamp[0], _fileTimestamp[1])
|
||||
_fileIdRaw := sha256.Sum256 ([]byte (_fileIdText))
|
||||
_fileIdRaw := blake3.Sum256 ([]byte (_fileIdText))
|
||||
_fileId := hex.EncodeToString (_fileIdRaw[:])
|
||||
|
||||
var _wasStored bool
|
||||
|
@ -492,7 +492,7 @@ func prepareDataContent (_context *context, _pathResolved string, _pathInArchive
|
|||
} else {
|
||||
return "", nil, nil, _error
|
||||
}
|
||||
_fingerprintContentRaw := sha256.Sum256 (_dataContent)
|
||||
_fingerprintContentRaw := blake3.Sum256 (_dataContent)
|
||||
_fingerprintContent = hex.EncodeToString (_fingerprintContentRaw[:])
|
||||
_dataSize = len (_dataContent)
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ func prepareDataMeta (_context *context, _dataMeta map[string]string) (string, [
|
|||
return "", nil, _error
|
||||
}
|
||||
|
||||
_fingerprintMetaRaw := sha256.Sum256 (_dataMetaRaw)
|
||||
_fingerprintMetaRaw := blake3.Sum256 (_dataMetaRaw)
|
||||
_fingerprintMeta := hex.EncodeToString (_fingerprintMetaRaw[:])
|
||||
|
||||
if _wasStored, _ := _context.storedDataMeta[_fingerprintMeta]; _wasStored {
|
||||
|
|
|
@ -16,6 +16,7 @@ require (
|
|||
github.com/stretchr/testify v1.7.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
github.com/zeebo/blake3 v0.2.1 // indirect
|
||||
go.etcd.io/bbolt v1.3.6 // indirect
|
||||
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
|
|
|
@ -25,12 +25,17 @@ github.com/valyala/fasthttp v1.31.0 h1:lrauRLII19afgCs2fnWRJ4M5IkV0lo2FqA61uGkNB
|
|||
github.com/valyala/fasthttp v1.31.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=
|
||||
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
|
||||
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
|
||||
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
||||
github.com/zeebo/blake3 v0.2.1 h1:O+N0Y8Re2XAYjp0adlZDA2juyRguhMfPCgh8YIf7vyE=
|
||||
github.com/zeebo/blake3 v0.2.1/go.mod h1:TSQ0KjMH+pht+bRyvVooJ1rBpvvngSGaPISafq9MxJk=
|
||||
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
|
||||
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
|
||||
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
|
Loading…
Reference in a new issue