Delete archive_context.rs and archive_ops.rs (1200+ lines of duplicated logic). Replace with four focused modules: 1. open_archive() - opens a file, detects compression, returns raw bytes 2. read_archive() - parses bytes into validated observations 3. CompressionWriter - writes bytes with any compression format 4. WriteStrategy - given a list of files, determines input archive, output archive, output format, and which of four write modes to use: - Create: new archive, no input - Append: uncompressed input, seek to end - AtomicSwap: compressed input, rewrite via temp file - CopyOnWrite: different input/output paths, transcode between formats Previously you could not specify output format. Appending always preserved the input format, creating compressed archives didn't work. Now all four cases work with any supported compression format. Atomic swap now writes to temp file, then renames. Crash-safe. Trade-off: This approach prioritizes code clarity over syscall efficiency. The archive file may be opened and read multiple times during a single operation (once for format detection, once for reading state, once for copying content). A more optimized implementation could reuse file handles, but the current approach makes each step's purpose obvious.
32 lines
1.1 KiB
TOML
32 lines
1.1 KiB
TOML
[package]
|
|
name = "json-archive"
|
|
version = "0.99.1"
|
|
edition = "2021"
|
|
authors = ["Karl <marxism@peoplesgrocers.com>", "nobody <nobody@localhost>"]
|
|
homepage = "https://peoplesgrocers.com/code/oss/json-archive"
|
|
repository = "https://peoplesgrocers.com/code/oss/json-archive"
|
|
license = "AGPL-3.0"
|
|
description = "CLI tool for tracking JSON file changes over time using delta-based archives"
|
|
keywords = ["json", "diff", "archive", "history", "cli"]
|
|
categories = ["command-line-utilities", "development-tools", "encoding"]
|
|
readme = "README.md"
|
|
|
|
[features]
|
|
default = ["compression"]
|
|
compression = ["flate2", "brotli", "zstd"]
|
|
|
|
[dependencies]
|
|
xflags = "0.3"
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
serde_json = "1.0"
|
|
chrono = { version = "0.4", features = ["serde"] }
|
|
uuid = { version = "1.0", features = ["v4", "serde"] }
|
|
|
|
# Compression support (optional, enabled by default)
|
|
flate2 = { version = "1.0", optional = true }
|
|
brotli = { version = "8.0", optional = true }
|
|
zstd = { version = "0.13", optional = true }
|
|
|
|
[dev-dependencies]
|
|
tempfile = "3.0"
|
|
arbitrary = { version = "1.0", features = ["derive"] }
|