Skip to main content

Module uploads

Module uploads 

Source
Expand description

Directory walker for :upload-collection. Recursively reads a local directory and produces the Vec<CollectionEntry> that bee.file().upload_collection_entries(...) consumes.

§Why a separate module

:upload-file is one tokio::fs::read away from a working upload — it doesn’t need its own module. Collections are different: traversal rules (skip hidden, skip symlinks), caps (size + entry count), and tar-friendly path normalisation all want unit tests against synthetic on-disk fixtures. Keeping the walker pure (no Bee API, no tokio runtime) makes it straightforward to test that.

§Path normalisation

Tar entries within a collection use forward-slash separators regardless of host OS — Bee resolves them to manifest forks literally. We strip the input-dir prefix from each walked path, convert backslashes to forward slashes (Windows safety), and reject any path that escapes the root via .. (defense in depth — WalkDir shouldn’t surface them when symlinks are ignored, but we keep the explicit check).

Structs§

WalkedCollection
Result of a directory walk.

Enums§

WalkError

Constants§

MAX_COLLECTION_BYTES
Total bytes an :upload-collection invocation is allowed to pack. Same ceiling as :upload-file: keeps the cockpit’s event loop responsive on operator-typical hardware. Operators with larger payloads should drive swarm-cli out of process.
MAX_COLLECTION_ENTRIES
Cap on entry count. A 10k-file collection is already extreme for a TUI verb (the tar build is in-memory) but the cap is generous enough that a typical static-site dist/ directory fits without question.

Functions§

walk_dir
Walk root recursively, returning every regular file as a CollectionEntry. Hidden files / directories (any path component starting with .) and symlinks are skipped.