Repository navigation
Conversation
PDF Optimizer > Discard Objects gets "Discard embedded search index", off by default. It removes the entries of the catalog's /PieceInfo whose application name contains "index" in any letter case, such as IBM-ODIndexes, and removes /PieceInfo when nothing else is left in it. Other application data and the pages' own /PieceInfo stay. An indirect /PieceInfo is not edited: the catalog gets a direct copy without those entries, and other objects that refer to the original keep it. The full save leaves out the objects that only the removed entries refer to. doc_optimize takes discard_search_index and reports search_indexes.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Merged
|
|
Merged Checks on
|
# Conflicts: # crates/automation/src/tools.rs
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the diff: the PDF Optimizer can discard an embedded search index (discard_search_index, the command optimize.discard-search-index): the automation layer's settings table gains the flag, the tool schema lists it, the result reports search_indexes (the number discarded), and the test optimizing_discards_an_embedded_search_index_through_tools builds a catalogue /PieceInfo with an IBM-ODIndexes and an Illustrator entry, optimises without the option (the count is 0 and both entries stay) and with it (the count is 1 and only Illustrator remains). Acrobat's Optimizer has the same choice ("Discard embedded search indexes"). Testing that the other private data is untouched is the right negative case. The key point is which entries count as search indexes: here the one name IBM-ODIndexes (Acrobat's Catalog index), so state the list and where it comes from, since a wrong match would delete a private application's data. I read the automation side only; the optimiser's implementation is in a part I did not see, so I could not check it removes only that entry and keeps an empty /PieceInfo valid (it should be removed when empty). The PR bundles the CLI, the tool and the engine in a repository where the engine side normally goes first. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
|
Merged main at 0cba87a; conflict in crates/automation/src/tools.rs (the doc_optimize description) resolved. cargo check --workspace --tests, cargo fmt --check and clippy on pdfcraft-optimize and pdfcraft-automation pass; 450 tests in those two crates pass. |
|
The branch includes main at Filtering an indirect Windows checks: workspace test compilation, formatting, optimizer and automation tests (461 passed), and clippy for the optimizer, automation and UI crates. |
|
Merged main at ef8c71a; the doc_optimize tool description in crates/automation/src/tools.rs conflicted, resolved by keeping main's JBIG2Globals sentence and this branch's search_index sentence. Checked with cargo check, clippy and the branch's tests. |
What this changes
PDF Optimizer ▸ Discard Objects had no option for an embedded search index (
optimize.discard-search-indexwas planned). The reference app's help page lists it in the Discard Objects panel: "Discard Embedded Search Index: Removes embedded search indexes, which reduces the file size." (https://web.archive.org/web/20221217175446/https://helpx.adobe.com/acrobat/using/optimizing-pdfs-acrobat-pro.html).Settings::discard_search_index)./PieceInfowhose application name contains "index" in any letter case, such asIBM-ODIndexes, and removes/PieceInfowhen nothing else is left in it. Other application data and the pages' own/PieceInfostay./PieceInfois not edited. The catalog gets a direct copy without those entries, and other objects that refer to the original keep it.doc_optimizetakesdiscard_search_indexand returnssearch_indexes.How you verified it
cargo fmt --check-D warningson the crates I changedcargo xtask layersandcargo xtask assets(if you touched crate boundaries or any asset)New tests, each seen failing with its part of the change reverted (on
mainthey do not compile):optimize.rs::search_indexes_in_the_catalog_go_and_other_application_data_stays: two index entries go and another application's entry stays; after saving, the two objects of the index that refer to each other are gone, and an object the page also uses stays; with the option off nothing changes.optimize.rs::an_indirect_piece_info_is_left_for_its_other_users: a/PieceInfoshared with a page leaves the catalog and keeps its entry for the page, and a/PieceInfothat is not a dictionary is left alone.automation.rs::optimizing_discards_an_embedded_search_index_through_tools:doc_optimizekeeps the index by default and removes it withdiscard_search_index.Commands:
cargo clippy -p pdfcraft-optimize -p pdfcraft-automation -p pdfcraft-ui-egui --all-targets -- -D warnings;cargo test -p pdfcraft-optimize(34 passed);cargo test -p pdfcraft-automation --test it -- optimiz(7 passed);cargo test -p pdfcraft-ui-egui --lib i18n(63 passed);cargo xtask parity,layers,assets.On Windows 11 (x86-64) with rustc 1.99.1, on 1ca8455 (this branch with
mainat20eebc1cmerged in):cargo fmt --all -- --check;cargo clippy -p pdfcraft-optimize -p pdfcraft-automation -p pdfcraft-ui-egui --all-targets -- -D warnings.cargo test -p pdfcraft-optimize -p pdfcraft-engine -p pdfcraft-automation -p pdfcraft-ui-egui -p pdfcraft-cli -p pdfcraft -p pdfcraft-web: 20 test binaries, 2,666 passed, 5 failed, 15 ignored. The 5 failures arepdfcraft-ui-eguiprint::tests that save through "Save as PDF"; they fail the same way onmainat9e90b2a5without this branch.cargo xtask layers,assetsandparity.git merge-treereports no conflicts withmainat20eebc1c.On 79d713a (
mainat24bb8530merged in; the one conflict was thedoc_optimizedescription incrates/automation/src/tools.rs, which now carries bothmain'smonoclause and this branch'ssearch_indexclause), on Windows 11 (x86-64) with rustc 1.99.1:cargo fmt --all -- --check;cargo check --workspace --tests;cargo clippy -p pdfcraft-optimize -p pdfcraft-automation -p pdfcraft-ui-egui --all-targets -- -D warnings.cargo test -p pdfcraft-optimize(81 passed);cargo test -p pdfcraft-automation --test it -- optimiz(10 passed);cargo test -p pdfcraft-ui-egui --lib i18n(65 passed).cargo xtask layers,assetsandparity.Never-crash
Every PDF, script, MCP call, settings file and keystroke is untrusted input (
AGENTS.md§4).unwrap/expect/panic!/unreachable!/todo!outside tests, unless it isprovably infallible with a comment saying why
get, and strings only at charboundaries); checked or saturating arithmetic; allocations sized by input are capped;
recursion is bounded
unsafeThis fixes no crash. The change edits one dictionary and does not walk the object graph; the full save's own reachability walk drops the objects.
Provenance
This is the part that cannot be undone after a merge, and the part a new contributor is
least likely to know about. Please read
AGENTS.md§1 before adding any asset.storytold/craft-fonts)
run as external oracle processes
another implementation's source
ATTRIBUTION.tomlentry andcargo xtask assetspassesSecurity
--rootconfinement still holds on every path, including ones reached by nestedtool dispatch
Parity and reach
parity/acrobat-features.tomlupdated in this PR, withnotessaying what is stillmissing —
shippedmeans "exists and tested", not "as good as Acrobat"automationtool where that applies (AGENTS.md§3),so agents can drive it and not just the UI
docs/, crate README)optimize.discard-search-indexis now shipped;crates/optimize/README.mddescribes it. The new label has no catalog rows yet.Anything a reviewer should look at first
/PieceInfoentry (application data for the whole document, ISO 32000-2 §14.5) whose name contains "index".IBM-ODIndexesis one such name in use. An index stored under a name without "index" is kept; Remove Hidden Information's private-data category still removes all of/PieceInfo.crates/automation/src/tools.rs, where the one-linedoc_optimizedescription needs every added clause. It adds nomodline, so themodlist conflict between those two does not grow.Summary by CodeRabbit