mirror of
https://github.com/restic/restic.git
synced 2026-06-28 11:34:18 +00:00
48 lines
920 B
Go
48 lines
920 B
Go
package repository
|
|
|
|
import (
|
|
"github.com/restic/chunker"
|
|
"github.com/restic/restic/internal/restic"
|
|
)
|
|
|
|
type baseChunker struct {
|
|
bc *chunker.BaseChunker
|
|
pol chunker.Pol
|
|
}
|
|
|
|
func (c *baseChunker) Reset() {
|
|
c.bc.Reset(c.pol)
|
|
}
|
|
|
|
func (c *baseChunker) NextSplitPoint(buf []byte) int {
|
|
return c.bc.NextSplitPoint(buf)
|
|
}
|
|
|
|
type chunkerFactory struct {
|
|
pol chunker.Pol
|
|
zeroChunk func() restic.ID
|
|
}
|
|
|
|
func newChunkerFactory(r *Repository) *chunkerFactory {
|
|
return &chunkerFactory{
|
|
pol: r.Config().ChunkerPolynomial,
|
|
zeroChunk: r.zeroChunk,
|
|
}
|
|
}
|
|
|
|
func (f *chunkerFactory) NewChunker() restic.Chunker {
|
|
return &baseChunker{bc: chunker.NewBase(f.pol), pol: f.pol}
|
|
}
|
|
|
|
func (f *chunkerFactory) MaxChunkSize() int {
|
|
return chunker.MaxSize
|
|
}
|
|
|
|
func (f *chunkerFactory) ZeroChunk() restic.ID {
|
|
return f.zeroChunk()
|
|
}
|
|
|
|
func (r *Repository) ChunkerFactory() restic.ChunkerFactory {
|
|
return newChunkerFactory(r)
|
|
}
|