diff --git a/apps/server/src/classes/data-provider/DataProvider.ts b/apps/server/src/classes/data-provider/DataProvider.ts index 35d781d64..66321b7e4 100644 --- a/apps/server/src/classes/data-provider/DataProvider.ts +++ b/apps/server/src/classes/data-provider/DataProvider.ts @@ -12,7 +12,6 @@ import { ViewSettings, } from 'ontime-types'; -import { cloneRundown } from '../../api-data/rundown/rundown.utils.js'; import { isTest } from '../../setup/environment.js'; import { shouldCrashDev } from '../../utils/development.js'; import { isPath } from '../../utils/fileManagement.js'; @@ -102,8 +101,16 @@ function getCustomFields(): Readonly { return db.data.customFields; } +/** + * Stores a rundown, replacing any existing entry for the same key. + * Takes ownership of `newData` and stores it by reference - the caller must not mutate it + * afterward. Every call site either hands over a freshly-built object it never touches again, + * or (for the loaded rundown) the cache's own long-lived object, which is already the single + * source of truth for that data - aliasing it here costs nothing and avoids a second full + * deep copy of the rundown on every commit. + */ async function setRundown(rundownKey: string, newData: Rundown): ReadonlyPromise { - db.data.rundowns[rundownKey] = cloneRundown(newData); + db.data.rundowns[rundownKey] = newData; await persist(); return db.data.rundowns; }