Skip to content

feat(documents): open Word backup copies (.wbk) - #1935

Merged
KnifeLemon merged 2 commits into
KnifeLemon:mainfrom
YusufMntm:feat/wbk-backup-1840
Dec 1, 2026
Merged

KnifeLemon merged 2 commits into
KnifeLemon:mainfrom
YusufMntm:feat/wbk-backup-1840

Conversation

@YusufMntm

Copy link
Copy Markdown
Contributor

What does this change?

Filee opens Word backup copies (.wbk, written when Word's "Always create backup copy" is on) and converts them as the document inside. Fixes #1840.

As you wrote in the issue, a .wbk is either an ordinary DOCX or, when the original was a .doc, a Word 97–2003 file, so each file is checked for which one it holds:

  • A new read-only format wbk (Document, grade General like doc), on the documents donut. Not in FormatRegistry.Envelopes: Word names backups Backup of Report.wbk, not Report.docx.wbk, so Backup of Report.wbk becomes Backup of Report.pdf.
  • A built-in word-backup engine (Office/WordBackupConverter.cs), an IEnvelopeOpener like .p7m's, with edges wbk → docx and wbk → doc. InnerFormat reads the first 8 bytes: PK\x03\x04 with word/document.xml in the ZIP → docx; the OLE signature → doc. Anything else (empty, random bytes, a ZIP that isn't a Word document) refuses with its own key error.wbk_not_word and no detail. The step copies the file unchanged through a temp file beside the output, then moves it into place, so a refusal never touches an existing output.
  • Routes come for free through JobQueue + RoutePlanner.PlanThrough. A DOCX backup gets every built-in and optional DOCX route. A DOC backup goes straight to LibreOffice's doc → … edges, and without LibreOffice it fails with the usual doc → <target> missing-route message, which names the package to install.
  • Preset availability (PresetAvailability): wbk → docx → hwpx → pdf → png is four steps, more than Plan allows, and docx → xlsx is DirectOnly. So with only the direct check, PNG, XLSX and Translate would look unusable for a .wbk even though JobQueue (which plans through the opener) runs them. When the direct check fails, availability now also tries the formats an opener lists for that source. .p7m is left exactly as it was: its opener already has an edge to every format, and the new FormatRegistry.IsNamedEnvelope keeps it out of the fallback.
  • Schema 107: LearnExtensions(profiles, out _, ["wbk"]), like .p7m's v68 step; custom claims stay put. feat(image): colour-mapped previews of single-band rasters #1849 and feat(vector): read Adobe Illustrator templates (.ait) #1774 also ask for 107, so whichever lands later needs the next number. Happy to renumber this one.
  • i18n: engine.word-backup.name / .description and error.wbk_not_word in all 23 files.
  • Docs: the README Documents row, a docs/ENGINES.md section after .p7m, and a CHANGELOG bullet with a ko/en pair.

Left out on purpose, to keep this to one thing: the ITextShapingCheck replan is skipped for every envelope in JobQueue, so an Arabic or Thai DOCX inside a .wbk isn't moved off rhwp the way a plain .docx is, and the missing-font preflight (DocumentFonts.PackageExtensions) doesn't look inside a .wbk. Both behave the same for .p7m today.

Type of change

  • Bug fix
  • New feature or improvement
  • New format or engine
  • Translation
  • Documentation
  • Build, CI or dependencies

How was it tested?

  • dotnet format --verify-no-changes (changed .cs files)
  • dotnet test: WordBackupTests + P7m engine tests (13 passed), the whole Filee.Core.Tests (1838 passed, 11 skipped), and the App tests PresetAvailabilityTests, OrdinaryConversionNoticeTests, DefaultPlacementTests, LocalizationTests (292 passed)
  • Tried it in the app (what you converted or clicked, and on which OS):

New tests, with inputs built in the test:

  • WordBackupTests (Engines): a DOCX backup → docx, copied byte for byte with a .docx name; an OLE backup → doc, copied unchanged; empty, random, plain-ZIP and corrupt-ZIP files refuse with error.wbk_not_word; an existing output survives a refusal; JobQueue end to end, .wbk → TXT and → Markdown.
  • WbkFormatTests (Core): registration, the documents donut, NameWithoutExtension, and the v107 step (including a custom claim kept).
  • PresetAvailabilityTests.Word_backup_envelope_keeps_four_hop_png_direct_only_xlsx_and_translate_available (App).
  • FormatFieldsTests: General count 99 → 100.

I didn't have a real .wbk from Word; the DOCX backups in the tests are made by the test, and the OLE case only checks the signature and the copy. A DOC backup converted through LibreOffice wasn't tried by hand.

Checklist

  • New UI strings are in all src/Filee.App/Assets/i18n/*.json files
  • New third-party code or binaries are listed in THIRD-PARTY-NOTICES.md (none)
  • The PR does one thing (unrelated changes go in a separate PR)

🤖 Generated with Claude Code

A .wbk holds either a DOCX (ZIP with word/document.xml) or, when the original
was a .doc, a Word 97-2003 OLE file. The built-in word-backup engine is an
IEnvelopeOpener: it reads the first bytes, passes the unchanged copy on as
docx or doc, and the planner continues along the usual routes. Anything else
is refused with error.wbk_not_word. Preset availability looks through such an
opener's inner formats, so 4-step and direct-only DOCX presets stay usable;
.p7m is left as it was. Schema v107 teaches existing libraries .wbk.

Fixes KnifeLemon#1840

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the feature New features label Nov 30, 2026
@YusufMntm YusufMntm mentioned this pull request Dec 1, 2026
6 of 12 tasks
@KnifeLemon KnifeLemon mentioned this pull request Dec 1, 2026
1 task done

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @YusufMntm! I read the whole diff. CI is green on every leg.

What I checked

  • Detection: the OLE signature becomes doc, and a ZIP with word/document.xml becomes docx. Anything else gets its own error.wbk_not_word. A refusal never touches an existing output, because the copy goes through a temp file and a move.
  • Routes: the DOCX case is fully built in. The DOC case uses the existing doc → … routes and names the package only when it's missing. No new LibreOffice-only path is added, which fits how we handle documents.
  • PresetAvailability: the fallback to the opener's inner formats only applies to un-named envelopes, so .p7m stays as it was. The new test covers the four-step PNG route, direct-only XLSX and Translate.
  • Names: Backup of Report.wbk → Backup of Report.pdf is right, since Word doesn't name backups after the file inside.
  • i18n: the three keys are in all 23 files. The engine name stays in English in the same files as engine.p7m.name.

Schema number: #1849 and #1774 also use 107. We'll renumber this step (and the 106/107 in WbkFormatTests) when we merge, so there's nothing for you to do.

Your note about the text-shaping replan and the font preflight not looking inside envelopes is fine as a follow-up.

KnifeLemon#1849 took 107. CHANGELOG.md is main's; this PR's lines go in with the maintainers' CHANGELOG catch-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KnifeLemon

Copy link
Copy Markdown
Owner

I merged main into this branch. #1849 took schema step 107, so .wbk is now step 108: CurrentSchemaVersion = 108, from < 108 in UserDataStore.cs, and WbkFormatTests now migrates from 107.

To stop the open PRs from conflicting on CHANGELOG.md every time one of them merges, this branch now carries main's CHANGELOG. Your lines aren't lost: I saved them and will add them in one CHANGELOG PR after the merges.

@KnifeLemon
KnifeLemon merged commit fe38249 into KnifeLemon:main Dec 1, 2026
11 checks passed
KnifeLemon added a commit to YusufMntm/Filee that referenced this pull request Dec 1, 2026
main took v108 for Word backup copies (.wbk, KnifeLemon#1935), so 3D Studio models learn the 3D donut in v109
(CurrentSchemaVersion 109, the BuiltInData note and the migration test follow). FormatFieldsTests counts .wbk
(General 100) and .3ds (Specialist 146). .3ds is a 2.6.0 format for shared presets (SharedPresetVersions).
CHANGELOG.md is main's; this PR's lines go in with the maintainers' CHANGELOG catch-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KnifeLemon added a commit that referenced this pull request Dec 1, 2026
Word backup copies (#1935) joined FormatRegistry after #1951 listed the formats added since 2.5.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
YusufMntm added a commit to YusufMntm/Filee that referenced this pull request Dec 1, 2026
KnifeLemon#1935 took schema step 108 for .wbk, so the .ait step moves to v109.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paulodalves pushed a commit to paulodalves/Filee that referenced this pull request Dec 1, 2026
Lines for KnifeLemon#1381 (macOS updates), KnifeLemon#1698 (portable updates), KnifeLemon#1913, KnifeLemon#1934, KnifeLemon#1915, KnifeLemon#1935, KnifeLemon#1947, KnifeLemon#1864, KnifeLemon#1831, KnifeLemon#1910,
KnifeLemon#1918 and KnifeLemon#1919. The contributors' own lines (left out of their PRs to avoid CHANGELOG conflicts) are used where
they wrote one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Format]: .wbk

2 participants