Rewrite an unsigned file in full when saving after deleting pages (#3407)

This commit is contained in:
srt8hellcat2-ui
2026-10-23 13:10:19 -04:00
committed by GitHub
parent cf0f80604f
commit d149d23320
+5
View File
@@ -3945,6 +3945,11 @@ impl Session {
// Signed documents are only ever saved incrementally: an edit that needs a full rewrite
// (applying redactions, changing security, sanitizing) would invalidate the signatures.
// So does any edit to a file rebuilt from object headers: it has no chain to append to.
// Deleted pages are freed, but an incremental save keeps them (and their text) in the
// earlier revision and the file does not shrink (#3407): rewrite an unsigned file in full.
if !signed && matches!(edit, Edit::DeletePages { .. }) {
next.require_full_save();
}
let rewrites = |c: &pdfcraft_cos::Document| c.full_save_required() || c.encryption_changed();
if signed && ((rewrites(&next) && !rewrites(&editor.cos)) || (next.is_modified() && next.revisions().is_empty())) {
return Err(EditError::SignedRewrite(edit.label().to_string()));