feat: optimize PDF saving to prevent file bloat during metadata updates#28
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds a structurallyModified flag and a getOriginalBytes() helper to enable metadata-only saves that reuse original file bytes; PdfSaver.saveToBytes gains an originalBytes parameter. Also bumps project version to 0.14.0 and adds tests exercising import and metadata-save size behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant PdfDocument
participant PdfSaver
participant NativeLib as Native PDFium
participant FileSystem
rect rgba(100,150,200,0.5)
Note over Client,FileSystem: Metadata-only save (structurallyModified = false)
Client->>PdfDocument: saveToBytes(SaveOptions)
PdfDocument->>PdfDocument: check structurallyModified & pending metadata
PdfDocument->>FileSystem: getOriginalBytes() (read if needed)
FileSystem-->>PdfDocument: original bytes
PdfDocument->>PdfSaver: saveToBytes(..., originalBytes)
PdfSaver->>PdfSaver: use originalBytes as base
PdfSaver->>NativeLib: apply incremental metadata update
NativeLib-->>PdfSaver: updated bytes
PdfSaver-->>PdfDocument: return bytes
PdfDocument-->>Client: return bytes
end
rect rgba(200,150,100,0.5)
Note over Client,NativeLib: Structural save (structurallyModified = true)
Client->>PdfDocument: saveToBytes(SaveOptions)
PdfDocument->>PdfDocument: check structurallyModified
PdfDocument->>PdfSaver: saveToBytes(..., null)
PdfSaver->>NativeLib: nativeSave(docHandle)
NativeLib-->>PdfSaver: full serialized bytes
PdfSaver->>PdfSaver: apply metadata/XMP updates
PdfSaver-->>PdfDocument: return bytes
PdfDocument-->>Client: return bytes
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
Summary by CodeRabbit
New Features
Tests
Chores