Extract file load to queue

This enables other parsers to keep their load function in the same file
This commit is contained in:
Dominik Reh
2023-02-10 11:55:56 +01:00
parent 890f1a48c2
commit cbeced9121
8 changed files with 119 additions and 94 deletions

View File

@@ -24,4 +24,19 @@ class HypernetParser extends BaseTagParser {
}
}
PARSERS.push(new HypernetParser(HYP_TRIGGER));
async function load() {
if (hypernetworks.length === 0) {
try {
hypernetworks = (await readFile(`${tagBasePath}/temp/hyp.txt?${new Date().getTime()}`)).split("\n")
.filter(x => x.trim().length > 0) //Remove empty lines
.map(x => x.trim()); // Remove carriage returns and padding if it exists
} catch (e) {
console.error("Error loading hypernetworks.txt: " + e);
}
}
}
PARSERS.push(new HypernetParser(HYP_TRIGGER));
// Add load function to the queue
QUEUE_FILE_LOAD.push(load);