From a9f0d2abe435d511f7acb7928507e1415159e7f0 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 17 Dec 2025 17:19:08 -0800 Subject: [PATCH] Update README to reflect current API (FileProgress was already a channel) --- README.md | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b0e2865..8ea82c9 100644 --- a/README.md +++ b/README.md @@ -170,35 +170,19 @@ Reading file contents and computing cryptographic hashes for manifest generation ### manifest.go - **Types** - - `ManifestScanOptions struct` - Options for scanning directories - - `IncludeDotfiles bool` - Include dot (hidden) files (excluded by default) - - `FollowSymLinks bool` -- **Functions** - - `New() *manifest` - Creates a new empty manifest - - `NewFromPaths(options *ManifestScanOptions, inputPaths ...string) (*manifest, error)` - Creates manifest from filesystem paths - - `NewFromFS(options *ManifestScanOptions, fs afero.Fs) (*manifest, error)` - Creates manifest from afero filesystem + - `manifest struct` - Internal representation of a manifest file - **Methods** - - `(*manifest) HasError() bool` - Returns true if manifest has errors - - `(*manifest) AddError(e error) *manifest` - Adds an error to the manifest - - `(*manifest) WithContext(c context.Context) *manifest` - Sets context for cancellation - - `(*manifest) GetFileCount() int64` - Returns number of files in manifest - - `(*manifest) GetTotalFileSize() int64` - Returns total size of all files - `(*manifest) Files() []*MFFilePath` - Returns all file entries from a loaded manifest - - `(*manifest) Scan() error` - Scans source filesystems and populates file list - -### output.go -- **Methods** - - `(*manifest) WriteToFile(path string) error` - Writes manifest to file path - - `(*manifest) WriteTo(output io.Writer) error` - Writes manifest to io.Writer ### builder.go - **Types** - - `FileProgress func(bytesRead int64)` - Callback for file processing progress + - `FileHashProgress struct` - Progress info during file hashing (BytesRead int64) - `Builder struct` - Constructs manifests by adding files one at a time - **Functions** - `NewBuilder() *Builder` - Creates a new Builder - **Methods** - - `(*Builder) 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 chan<- FileHashProgress) (int64, error)` - Reads file, computes hash, adds to manifest + - `(*Builder) AddFileWithHash(path string, size int64, mtime time.Time, hash []byte)` - Adds file with pre-computed hash - `(*Builder) FileCount() int` - Returns number of files added - `(*Builder) Build(w io.Writer) error` - Finalizes and writes manifest @@ -208,9 +192,8 @@ Reading file contents and computing cryptographic hashes for manifest generation ### deserialize.go - **Functions** - - `NewFromProto(input io.Reader) (*manifest, error)` - Deserializes manifest from protobuf - `NewManifestFromReader(input io.Reader) (*manifest, error)` - Reads and parses manifest from io.Reader - - `NewManifestFromFile(path string) (*manifest, error)` - Reads and parses manifest from file path + - `NewManifestFromFile(fs afero.Fs, path string) (*manifest, error)` - Reads and parses manifest from file path ### mf.pb.go (generated from mf.proto) - **Enum Types** @@ -352,11 +335,6 @@ The manifest file would do several important things: - **Manifest size:** Manifests must fit entirely in system memory during reading and writing. -# TODO - -- [ ] **Change FileProgress callback to channel** - `mfer/builder.go` uses a callback for progress reporting; should use channels like `EnumerateStatus` and `ScanStatus` for consistency. -- [ ] **Consolidate legacy manifest code** - `mfer/manifest.go` has old scanning code (`Scan()`, `addFile()`) that duplicates the new `internal/scanner` + `mfer/builder.go` pattern. - # Open Questions - Should the manifest file include checksums of individual file chunks, or just for the whole assembled file?