A default name cut short is never a Windows device name
check / check (push) Canceled after 0s

defaultFileName replaced unsafe characters before cutting the name short,
so the cut could leave a device name: `CONSOLE.` before a 251-letter
extension became `CON.` and that extension, and `NULL.` became `NUL.`. A
name the cut leaves as a device name now gets a leading `_`, as
sanitizeFileName gives one, and is cut a byte shorter to leave room for it.

The backup's links and album folders and the `backup-metadata` album
folders need no change: the ID comes right after or right before the part
that is cut, so that part can never be a device name.

Model: opus-5-5
This commit is contained in:
2026-10-18 17:37:05 +00:00
parent e03e99b486
commit 4507b486c4
2 changed files with 17 additions and 8 deletions
+9
View File
@@ -216,4 +216,13 @@ describe("defaultFileName", () => {
`${"t".repeat(250)}.heic`,
);
});
// Cutting `CONSOLE` or `NULL` short before a long extension leaves `CON`
// or `NUL`, so the name gets the `_` `sanitizeFileName` gives a device
// name, and the part before the extension gives up a byte for it.
it("never returns a Windows device name, even once cut short", () => {
const ext = `.${"e".repeat(251)}`;
expect(defaultFileName(`CONSOLE${ext}`, 42)).toBe(`_CO${ext}`);
expect(defaultFileName(`NULL${ext}`, 42)).toBe(`_NU${ext}`);
});
});