mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-12 04:53:52 -06:00
feat: keep the address of a file that left
files/?sha1= of a file the collection no longer holds answered that no
file the site knows has the hash. generate_db.py now records each sha1 a
rebuild drops in retired.json, with the day and the file in its place,
backfilled from the history since 0d586ef6b (4,139 files). The lookup
answers with it and leads to the successor's card.
This commit is contained in:
1 parent
578050b8e5
commit
350cd6d600
12 files changed
+37779
-10
No files matched your search
@@ -23,6 +23,9 @@ type Item = {
|
||||
system_name?: string;
|
||||
// On an archive-member record: the collection archive holding the member.
|
||||
archive?: string;
|
||||
// On a retired record: the day the file left, and the file in its place.
|
||||
left?: string;
|
||||
successor?: string;
|
||||
};
|
||||
|
||||
const siteRoot = () => new URL(import.meta.env.BASE_URL.replace(/\/?$/, '/'), location.origin);
|
||||
@@ -525,7 +528,7 @@ const renderMatches = async (status: HTMLElement, result: HTMLElement, matched:
|
||||
const searched = new Set(matched.map((item) => item.value));
|
||||
// A member's record names its archive, which is not the file searched for.
|
||||
const carried = [...new Set(matched.flatMap((item) =>
|
||||
(item.sha1 && item.layer !== 'archive-member' && !searched.has(item.sha1) ? [item.sha1] : [])))];
|
||||
(item.sha1 && !['archive-member', 'retired'].includes(item.layer) && !searched.has(item.sha1) ? [item.sha1] : [])))];
|
||||
const found = carried.length ? [...matched, ...(await lookupValues(carried).catch(() => [] as Item[]))] : matched;
|
||||
const held = distinct(found.filter((item) => item.layer === 'collection'), (item) => item.sha1 ?? item.url);
|
||||
const files = await Promise.all(held.map((item) => heldFile(item).catch(() => undefined)));
|
||||
@@ -613,7 +616,9 @@ const renderMatches = async (status: HTMLElement, result: HTMLElement, matched:
|
||||
),
|
||||
);
|
||||
});
|
||||
if (!held.length && !members.length) blocks.push(paragraph('No file in the collection has this hash.'));
|
||||
const retired = held.length ? [] : distinct(byLayer('retired'), (item) => item.sha1 ?? item.value);
|
||||
if (!held.length && !members.length && !retired.length) blocks.push(paragraph('No file in the collection has this hash.'));
|
||||
blocks.push(...retired.map(retiredParagraph));
|
||||
if (members.length) {
|
||||
// A ROM the collection holds inside a set: the set's card, by its name.
|
||||
const list = document.createElement('ul');
|
||||
@@ -657,6 +662,15 @@ const renderMatches = async (status: HTMLElement, result: HTMLElement, matched:
|
||||
result.replaceChildren(...blocks);
|
||||
};
|
||||
|
||||
// A file the collection held: its address keeps answering, with the day
|
||||
// it left and the card of the file in its place.
|
||||
const retiredParagraph = (item: Item) =>
|
||||
paragraph(
|
||||
code(item.name || item.value), ` left the collection on ${item.left}. `,
|
||||
item.successor ? link(item.url, 'Open the card of the file in its place') : link(item.url, 'Open the page it was on'),
|
||||
'.',
|
||||
);
|
||||
|
||||
const WANTED = 'provenance/#wanted-catalogued-dumps-this-project-does-not-have';
|
||||
|
||||
// Nothing the site knows has the value: where a dump of one's own can go.
|
||||
@@ -766,8 +780,12 @@ const resolveFileAddress = () => {
|
||||
const matches = items.filter((item) =>
|
||||
prefix ? item.algorithm === 'sha1' && item.value.startsWith(value) : item.value === value);
|
||||
const cards = matches.filter((item) => item.layer === 'collection' || item.layer === 'data-directory');
|
||||
const retired = matches.filter((item) => item.layer === 'retired' && item.algorithm === 'sha1');
|
||||
if (new Set(cards.map((item) => item.url)).size === 1) {
|
||||
location.replace(new URL(cards[0].url, siteRoot()));
|
||||
} else if (!cards.length && retired.length) {
|
||||
status.textContent = 'This file is no longer in the collection.';
|
||||
result.replaceChildren(...distinct(retired, (item) => item.value).map(retiredParagraph));
|
||||
} else if (matches.length) {
|
||||
return renderMatches(status, result, prefix ? cards : matches);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user