Files
Miguel Ángel e00baefb5c fix(studio): reload the preview only when a file it loaded changes (#4570)
* fix(studio): reload the preview only when a file it loaded changes

* test(studio): read the owner id from the new change-owner shape

* refactor(studio): drop a comment the parser name already says

* fix(studio): keep reloading until the preview is built, and count what its document names

* style(studio): format the reference pattern and name the kept reload

* fix(studio-server): scan preview references in linear time and refresh all thumbnails on a merged reload

* fix(studio): keep a waiting film change when a file the preview never loaded arrives behind it

* test(studio): name the preview ownership test for what it checks

* chore(ci): allow the watchIgnore removals and trim the new comments

* fix(studio-server): reload the preview when a folder holding a file it loaded moves in or out

* perf(studio-server): check a changed folder in one lookup and cover every reference form

* fix(studio-server): record read folders for a project at the filesystem root

* fix(studio-server): reload the preview when the file a symlinked asset points at changes

* fix(studio-server): resolve symlinks on every preview read and key projects by their real folder

* fix(studio-server): record every link a preview read passes through, resolved as the system does
2026-09-27 10:05:53 +00:00

13 lines
503 B
TypeScript

import { sep } from "node:path";
/** The watched project that owns `filePath`, nearest root first when projects nest. */
export function previewChangeOwner(
watchedProjects: ReadonlyMap<string, string>,
filePath: string,
): { projectDir: string; projectId: string } | null {
const owner = [...watchedProjects]
.sort(([left], [right]) => right.length - left.length)
.find(([dir]) => filePath.startsWith(dir + sep));
return owner ? { projectDir: owner[0], projectId: owner[1] } : null;
}