Repository navigation
BUG: Keep the generation number of objects in incremental updates - #4484
Open
metsw24-max wants to merge 1 commit into
Open
metsw24-max wants to merge 1 commit into
metsw24-max wants to merge 1 commit into
Conversation
In incremental mode every object of the source was fetched and written back as generation 0. An object stored as `N 1 obj` was then missing from the writer or replaced by an older generation 0 version, and changes to it were written as `N 0 obj`, which references to `N 1 R` never reach. Fetch each object with the highest generation listed for its number, keep that generation for objects taken from the incremental source and write it in the object header and the xref stream entry of the increment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4484 +/- ##
=======================================
Coverage 99.25% 99.25%
=======================================
Files 59 59
Lines 12425 12429 +4
Branches 2368 2368
=======================================
+ Hits 12333 12337 +4
Misses 38 38
Partials 54 54 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incremental updates drop the generation number of existing objects
With
incremental=True,clone_reader_document_rootfetched every source object as generation 0 and_write_incrementwrote changed objects back asN 0 obj. An object stored asN 1 objwas therefore missing from the writer or replaced by an older generation 0 version, and changes to it never reached theN 1 Rreferences: filling the two text fields ofissue-3553.pdfwhose appearances are325 1 objand326 1 objleft the old empty appearance for both pypdf and qpdf, and intika-976970.pdfthe incremental writer returned a page dictionary as/Contentsof the second page. The clone now takes the highest generation listed for each number, which is the one the references point to, and the writer keeps and writes it for objects taken from the source.Notes for review
/Wfield of the increment's xref stream is now 2 bytes, as generation numbers can go up to 65535. Files that only use generation 0 should otherwise be written as before.update_page_form_field_valuesnow replaces an existing/AP /Nstream through_replace_object, which already keeps the generation.