diff --git a/src/core/services/tokenizer/hachidori-parser-bridge.test.ts b/src/core/services/tokenizer/hachidori-parser-bridge.test.ts index 30076b18..d371f765 100644 --- a/src/core/services/tokenizer/hachidori-parser-bridge.test.ts +++ b/src/core/services/tokenizer/hachidori-parser-bridge.test.ts @@ -38,7 +38,6 @@ function lookupResult(matched: string, expression: string, reading: string, dict type UploadReply = Record; // The parts of vendor/hachidori/extension/linked-import.js the harness drives. type LinkedImportModule = { - ENGINE_BUSY_CODE: string; createUploadHost(options: { store: { append(token: string, data: string): void; @@ -85,7 +84,6 @@ async function createHarness(emptyLibrary = false) { let proxyUrl: unknown; let loadingStatusReplies = 0; let busyEngineReplies = 0; - let busyCommits = 0; const uploads: Array<{ fileName: string; replace: boolean; bytes: Buffer }> = []; const apiModule: unknown = await import( pathToFileURL(path.join(extensionPath, 'api-host.js')).href @@ -108,10 +106,6 @@ async function createHarness(emptyLibrary = false) { token: string, { fileName, replace }: { fileName: string; replace: boolean }, ) => { - if (busyCommits > 0) { - busyCommits -= 1; - return { ok: false, error: 'busy', errorCode: linkedImportModule.ENGINE_BUSY_CODE }; - } uploads.push({ fileName, replace, bytes: Buffer.concat(uploadParts.get(token) ?? []) }); return { ok: true, report: { success: true } }; }, @@ -280,9 +274,6 @@ async function createHarness(emptyLibrary = false) { setBusyEngineReplies: (count: number) => { busyEngineReplies = count; }, - setBusyCommits: (count: number) => { - busyCommits = count; - }, uploads: () => uploads, }; } @@ -541,8 +532,6 @@ test('Hachidori mining requests render native dictionary aliases and frequency m test('Hachidori settings automation uploads ZIP bytes as a replacement and removes the matching dictionary ID', async () => { const harness = await createHarness(); - // The engine is mid-change for the first commit; the same upload must still land once. - harness.setBusyCommits(1); await harness.run( "__subminerYomitanSettingsAutomation.importDictionaryArchiveBase64('UEstdGVzdA==', 'characters.zip')", ); diff --git a/src/core/services/tokenizer/hachidori-parser-bridge.ts b/src/core/services/tokenizer/hachidori-parser-bridge.ts index b07fc8de..2772cd17 100644 --- a/src/core/services/tokenizer/hachidori-parser-bridge.ts +++ b/src/core/services/tokenizer/hachidori-parser-bridge.ts @@ -209,20 +209,11 @@ export const HACHIDORI_PARSER_BRIDGE_SCRIPT = String.raw` void invoke(action, params).then(result => callback({ result }), error => callback({ error: { message: error.message } })); }; // Archives go through Hachidori's upload requests: an unlinked install imports - // the ZIP itself and a linked one forwards it to its host. A busy engine keeps - // the upload open, so the same commit is sent again. - const sendUpload = async (type, fields) => { - const deadline = Date.now() + 300000; - for (;;) { - const reply = await chrome.runtime.sendMessage({ - target: 'hachidori-linked-import', type, requestId: crypto.randomUUID(), ...fields, - }); - if (type !== 'hd_import_commit' || reply?.errorCode !== 'engine-mutating' || Date.now() >= deadline) { - return reply; - } - await sleep(500); - } - }; + // the ZIP itself and a linked one forwards it to its host. The engine queues + // an import behind any dictionary change already running. + const sendUpload = (type, fields) => chrome.runtime.sendMessage({ + target: 'hachidori-linked-import', type, requestId: crypto.randomUUID(), ...fields, + }); async function importArchive(blob, fileName) { await waitForEngineReady(); const reply = await uploadDictionary({ blob, fileName, replace: true, send: sendUpload });