From ba676af8ebb6520aec1f63ce08875ba8b21d9c0f Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Sun, 1 Nov 2026 05:03:56 +0000 Subject: [PATCH] Pass the load cancellation check through the project metadata wrapper mw-project-metadata wraps vm.deserializeProject to read the loaded meta, but forwarded only the project and zip. The VM's third argument, the check that a load is still current, was dropped, so a project load superseded by a newer one could still install its targets. The wrapper now forwards every argument, with a test. --- src/lib/mw-project-metadata.js | 4 ++-- test/unit/util/mw-project-metadata.test.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/mw-project-metadata.js b/src/lib/mw-project-metadata.js index 801d9684896..2702e91284f 100644 --- a/src/lib/mw-project-metadata.js +++ b/src/lib/mw-project-metadata.js @@ -82,12 +82,12 @@ const installProjectMetadata = vm => { // deserializeProject is the one place the VM hands us the parsed project // json, so it is the only cheap way to see the meta a file arrived with. const originalDeserialize = vm.deserializeProject.bind(vm); - vm.deserializeProject = (projectJSON, zip) => { + vm.deserializeProject = (projectJSON, zip, ...rest) => { loadedMeta = (projectJSON && projectJSON.meta) || null; // Opening a project adopts its birthday; opening one without a // recorded birthday means the next save mints one. created = (loadedMeta && (loadedMeta.created || loadedMeta.createdAt)) || null; - return originalDeserialize(projectJSON, zip); + return originalDeserialize(projectJSON, zip, ...rest); }; }; diff --git a/test/unit/util/mw-project-metadata.test.js b/test/unit/util/mw-project-metadata.test.js index b2cf255e642..63c08b34535 100644 --- a/test/unit/util/mw-project-metadata.test.js +++ b/test/unit/util/mw-project-metadata.test.js @@ -5,6 +5,17 @@ import { } from '../../../src/lib/mw-project-metadata'; describe('project metadata', () => { + test('passes every deserialize argument through, including the load cancellation check', async () => { + const original = jest.fn(() => Promise.resolve()); + const vm = {toJSON: () => '{}', deserializeProject: original}; + const active = () => false; + + installProjectMetadata(vm); + await vm.deserializeProject({meta: {}}, 'zip', active); + + expect(original).toHaveBeenCalledWith({meta: {}}, 'zip', active); + }); + test('keeps Scratch metadata and carries MistWarp metadata across saves', async () => { let source = { meta: {