fix: handle duplicate raw-path claims by routing to orphaned
This commit is contained in:
13
.obsidian/plugins/webinar-dash/main.js
vendored
13
.obsidian/plugins/webinar-dash/main.js
vendored
@@ -29,9 +29,16 @@ function extractRawPath(text) {
|
||||
}
|
||||
|
||||
function derivePipeline({ rawFiles, sourcePages }) {
|
||||
// First claim on a raw path wins. A later page claiming the same file is a
|
||||
// duplicate claim — real catalog drift — and joins `orphaned` rather than
|
||||
// being silently dropped. `orphaned` therefore means "source page not paired
|
||||
// with a raw file", whatever the reason.
|
||||
const claimed = new Map();
|
||||
const duplicates = [];
|
||||
for (const page of sourcePages) {
|
||||
if (page.rawPath) claimed.set(page.rawPath, page);
|
||||
if (!page.rawPath) continue;
|
||||
if (claimed.has(page.rawPath)) duplicates.push(page);
|
||||
else claimed.set(page.rawPath, page);
|
||||
}
|
||||
|
||||
const processed = [];
|
||||
@@ -43,7 +50,9 @@ function derivePipeline({ rawFiles, sourcePages }) {
|
||||
}
|
||||
|
||||
const rawPaths = new Set(rawFiles.map((f) => f.path));
|
||||
const orphaned = sourcePages.filter((p) => !p.rawPath || !rawPaths.has(p.rawPath));
|
||||
const orphaned = sourcePages
|
||||
.filter((p) => !p.rawPath || !rawPaths.has(p.rawPath))
|
||||
.concat(duplicates);
|
||||
|
||||
unprocessed.sort((a, b) => a.name.localeCompare(b.name));
|
||||
processed.sort((a, b) => b.page.name.localeCompare(a.page.name));
|
||||
|
||||
Reference in New Issue
Block a user