Rename ManifestBuilder to Builder
This commit is contained in:
parent
f3be3eba84
commit
48c3c09d85
10
README.md
10
README.md
@ -192,13 +192,13 @@ Reading file contents and computing cryptographic hashes for manifest generation
|
|||||||
### builder.go
|
### builder.go
|
||||||
- **Types**
|
- **Types**
|
||||||
- `FileProgress func(bytesRead int64)` - Callback for file processing progress
|
- `FileProgress func(bytesRead int64)` - Callback for file processing progress
|
||||||
- `ManifestBuilder struct` - Constructs manifests by adding files one at a time
|
- `Builder struct` - Constructs manifests by adding files one at a time
|
||||||
- **Functions**
|
- **Functions**
|
||||||
- `NewBuilder() *ManifestBuilder` - Creates a new ManifestBuilder
|
- `NewBuilder() *Builder` - Creates a new Builder
|
||||||
- **Methods**
|
- **Methods**
|
||||||
- `(*ManifestBuilder) AddFile(path string, size int64, mtime time.Time, reader io.Reader, progress FileProgress) (int64, error)` - Reads file, computes hash, adds to manifest
|
- `(*Builder) AddFile(path string, size int64, mtime time.Time, reader io.Reader, progress FileProgress) (int64, error)` - Reads file, computes hash, adds to manifest
|
||||||
- `(*ManifestBuilder) FileCount() int` - Returns number of files added
|
- `(*Builder) FileCount() int` - Returns number of files added
|
||||||
- `(*ManifestBuilder) Build(w io.Writer) error` - Finalizes and writes manifest
|
- `(*Builder) Build(w io.Writer) error` - Finalizes and writes manifest
|
||||||
|
|
||||||
### serialize.go
|
### serialize.go
|
||||||
- **Constants**
|
- **Constants**
|
||||||
|
|||||||
@ -12,16 +12,16 @@ import (
|
|||||||
// FileProgress is called during file processing to report bytes read.
|
// FileProgress is called during file processing to report bytes read.
|
||||||
type FileProgress func(bytesRead int64)
|
type FileProgress func(bytesRead int64)
|
||||||
|
|
||||||
// ManifestBuilder constructs a manifest by adding files one at a time.
|
// Builder constructs a manifest by adding files one at a time.
|
||||||
type ManifestBuilder struct {
|
type Builder struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
files []*MFFilePath
|
files []*MFFilePath
|
||||||
createdAt time.Time
|
createdAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBuilder creates a new ManifestBuilder.
|
// NewBuilder creates a new Builder.
|
||||||
func NewBuilder() *ManifestBuilder {
|
func NewBuilder() *Builder {
|
||||||
return &ManifestBuilder{
|
return &Builder{
|
||||||
files: make([]*MFFilePath, 0),
|
files: make([]*MFFilePath, 0),
|
||||||
createdAt: time.Now(),
|
createdAt: time.Now(),
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ func NewBuilder() *ManifestBuilder {
|
|||||||
// AddFile reads file content from reader, computes hashes, and adds to manifest.
|
// AddFile reads file content from reader, computes hashes, and adds to manifest.
|
||||||
// The progress callback is called periodically with total bytes read so far.
|
// The progress callback is called periodically with total bytes read so far.
|
||||||
// Returns the number of bytes read.
|
// Returns the number of bytes read.
|
||||||
func (b *ManifestBuilder) AddFile(
|
func (b *Builder) AddFile(
|
||||||
path string,
|
path string,
|
||||||
size int64,
|
size int64,
|
||||||
mtime time.Time,
|
mtime time.Time,
|
||||||
@ -85,14 +85,14 @@ func (b *ManifestBuilder) AddFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FileCount returns the number of files added to the builder.
|
// FileCount returns the number of files added to the builder.
|
||||||
func (b *ManifestBuilder) FileCount() int {
|
func (b *Builder) FileCount() int {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
return len(b.files)
|
return len(b.files)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build finalizes the manifest and writes it to the writer.
|
// Build finalizes the manifest and writes it to the writer.
|
||||||
func (b *ManifestBuilder) Build(w io.Writer) error {
|
func (b *Builder) Build(w io.Writer) error {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user