You are browsing as a guest. Sign up (or log in) to start making projects!

2h 0m logged

Implement project file I/O with atomic writes, placeholder detection, and directory utilities

Add the complete project file management layer in pwr-core. The
.project.toml file is the stable identity marker that persists on local
disk regardless of whether project content is present (Local state) or
stored on the server (Archived state).

read_project_file returns Option, returning None when no
.project.toml exists so callers can distinguish untracked directories
from tracked projects. write_project_file uses an atomic write-through
pattern: contents are serialized to a .tmp sibling file first, then
renamed over the target, preventing readers from observing a partially
written metadata file. remove_project_file deletes the marker without
touching directory contents.

State detection predicates cover all cases needed by the CLI and shell
wrapper. is_archived_placeholder confirms that a directory contains only
a .project.toml whose state field is Archived — the signal that triggers
automatic restore in the ensure command. is_local_project checks for the
opposite state. is_tracked simply tests file existence without parsing.

Directory utilities support the archive and restore workflows.
dir_size computes total bytes excluding the metadata file itself, with
symlinks counted by their target path length rather than followed.
file_count tallies regular files recursively for transfer progress
estimation. remove_dir_contents_except_project strips a directory down
to its .project.toml placeholder after a successful archive.

Eleven tests cover round-trip I/O, atomic write behavior, placeholder
and local state detection, tracking predicate, exact byte counting, file
enumeration, directory stripping, and recursive discovery.

0
1

Comments 0

No comments yet. Be the first!