Improved reading and writing large Office files without copying them into memory (#1243)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-28 23:03:30 +01:00
1 parent 918572c158
commit dbe609a9a7
37 files changed
+1161 -471

No files matched your search

@@ -52,14 +52,16 @@ the repository root and to `app/AGENTS.md`, which apply here as well.
The format refuses a larger text before reading it (`DocumentTooLargeException`), and `SelectDocument` when the
form is checked, before a run starts. A new format measures its own factor with a dense document.
- **Write only into the file the user chose, and never the whole file through memory.** A document with videos
takes hundreds of megabytes, and the SDK saves a package in the update mode of ZipArchive, which loads every entry
behind the first changed one. So `OpenXmlSegmentFormat` opens the source for reading only, the writer changes the
DOM, and `PackageRewrite` from `app/MindWork AI Studio/Tools/OpenXml/` writes a new archive in which every other
entry streams through as it is, a stored one stays stored. The new document comes about in a `StagedDocument`
below the data directory, not in the temporary folder, which lives in memory on many Linux systems, and
`TargetFile` streams it into the file the user chose. A writer therefore changes only the XML of existing parts and
never adds or removes parts or relationships. A new Office format brings only its reader, its writer, and the
element of each paragraph (`ElementOf`).
takes hundreds of megabytes. The SDK copies a document it opens for reading only into the temporary folder, as a
whole, and the temporary folder lives in memory on many Linux systems; it saves a package in the update mode of
ZipArchive, which loads every entry behind the first changed one. So `OpenXmlSegmentFormat` never opens the source
with the SDK: it reads and writes through a `PackageSkeleton` from `app/MindWork AI Studio/Tools/OpenXml/`, which
holds only the XML of the source. The writer changes the DOM of the skeleton, opened for reading only, and the
skeleton writes a new archive with the changed parts, in which every other entry streams through as it is, a stored
one stays stored. Skeleton and new document come about in `StagedDocument`s below the data directory, not in the
temporary folder, and `TargetFile` streams the new document into the file the user chose. A writer therefore changes
only the XML of existing parts and never adds or removes parts or relationships. A new Office format brings only its
reader, its writer, and the element of each paragraph (`ElementOf`).
## Markdown files and other text