Skip to content

Add EntryContent decoded view for NormalEntry - #3207

Merged
ChanTsune merged 6 commits into
mainfrom
feat/entry-content
Jul 17, 2026
Merged

Add EntryContent decoded view for NormalEntry#3207
ChanTsune merged 6 commits into
mainfrom
feat/entry-content

Conversation

@ChanTsune

@ChanTsune ChanTsune commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

Add EntryContent, a decoded view enum for NormalEntry that interprets entry data according to its DataKind, and migrate the manual link-target decoding in extract, diff and list to it. This moves per-kind payload interpretation (decrypt → UTF-8 validation → EntryReference restoration) from CLI call sites into libpna.

Notes

  • Link targets are restored with EntryReference::from_utf8_preserve_root, so absolute targets round-trip without sanitization.
  • Directory never touches entry data: it decodes without a password even when the header claims encryption, and stray data on malformed archives is ignored.
  • EntryContent is #[non_exhaustive]; Reserved/Private kinds surface as Unknown(kind, reader) with the raw decoded bytes.
  • CLI behavior is unchanged (same error kinds, output strings, and list's "-" fallback).

Summary by CodeRabbit

  • New Features

    • Added a unified way to read archive entry content, including files, directories, symbolic links, and hard links.
    • Link targets are now decoded and validated consistently, including encrypted entries.
  • Bug Fixes

    • Improved archive comparisons for symbolic and hard links.
    • Improved extraction and listing of link targets.
    • Directories can be read correctly even when encrypted or containing unexpected data.
    • Invalid link encoding is reported clearly instead of being silently misinterpreted.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a public EntryContent API that decodes archive payloads by entry kind, then updates CLI diff, extraction, and listing commands to consume decoded symbolic-link and hard-link targets.

Changes

Entry content decoding and CLI integration

Layer / File(s) Summary
Decoded entry content API and validation
lib/src/entry.rs, lib/src/entry/content.rs
Adds EntryContent, NormalEntry::content, reference decoding, public re-exports, and tests for files, directories, links, unknown kinds, invalid UTF-8, and encryption.
Link comparison and listing integration
cli/src/command/diff.rs, cli/src/command/list.rs
Diff and list operations use decoded EntryContent variants for symbolic-link and hard-link targets.
Link extraction integration
cli/src/command/extract.rs
Link extraction uses decoded targets while preserving safety checks, warnings, and deferred overwrite behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: cli, lib

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding an EntryContent decoded view for NormalEntry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/entry-content

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the EntryContent enum and the NormalEntry::content method to provide a decoded view of entry data based on its DataKind. It refactors the CLI commands (diff, extract, and list) to use this new API for handling symbolic and hard links instead of manually reading and decoding the entry data. Comprehensive unit tests are also added for the new functionality. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/src/entry/content.rs`:
- Around line 57-59: Update read_reference to enforce a small maximum
link-target size while reading the payload, before converting it with
EntryReference::from_utf8_preserve_root. Return an io::Error with InvalidData
when the target exceeds the limit, avoiding unbounded read_to_string allocation
and preserving the existing successful decoding path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 37f641f1-b1da-43df-b77e-712ac400e25d

📥 Commits

Reviewing files that changed from the base of the PR and between 1614d08 and 18208c3.

📒 Files selected for processing (5)
  • cli/src/command/diff.rs
  • cli/src/command/extract.rs
  • cli/src/command/list.rs
  • lib/src/entry.rs
  • lib/src/entry/content.rs

Comment thread lib/src/entry/content.rs
@github-actions github-actions Bot added cli This issue is about cli application lib This issue is about lib crate labels Jul 16, 2026
Comment thread lib/src/entry/content.rs Dismissed
Comment thread lib/src/entry/content.rs Dismissed
@github-actions github-actions Bot added the break API braking change label Jul 16, 2026
@ChanTsune
ChanTsune merged commit 44ecd5a into main Jul 17, 2026
109 of 110 checks passed
@ChanTsune
ChanTsune deleted the feat/entry-content branch July 17, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

break API braking change cli This issue is about cli application lib This issue is about lib crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants