Upload via GUI (21 Dateien)
This commit is contained in:
+29
-2
@@ -82,7 +82,34 @@ function parseJavaVersion(javaPath, out) {
|
||||
return { path: javaPath, version: raw || 'unbekannt', major: major || 0, arch, info: vendorLine };
|
||||
}
|
||||
|
||||
function scanJava() {
|
||||
// Ergebnis des Suchlaufs zwischenspeichern – die Suche kostet ~1 s
|
||||
let javaCache = null;
|
||||
let javaCacheFile = null;
|
||||
function setCacheDir(dir) { javaCacheFile = path.join(dir, 'java-cache.json'); }
|
||||
|
||||
function scanJava(useCache = true) {
|
||||
const MAX_AGE = 24 * 3600 * 1000;
|
||||
if (useCache) {
|
||||
if (javaCache && Date.now() - javaCache.at < MAX_AGE) return javaCache.list;
|
||||
// Cache von der Platte (gilt auch direkt nach dem Start)
|
||||
if (javaCacheFile) {
|
||||
try {
|
||||
const c = JSON.parse(fs.readFileSync(javaCacheFile, 'utf8'));
|
||||
if (c && Date.now() - c.at < MAX_AGE && Array.isArray(c.list)
|
||||
&& c.list.every((j) => fs.existsSync(j.path))) {
|
||||
javaCache = c;
|
||||
return c.list;
|
||||
}
|
||||
} catch { /* kein oder unbrauchbarer Cache */ }
|
||||
}
|
||||
}
|
||||
const list = scanJavaUncached();
|
||||
javaCache = { at: Date.now(), list };
|
||||
if (javaCacheFile) { try { fs.writeFileSync(javaCacheFile, JSON.stringify(javaCache)); } catch { /* egal */ } }
|
||||
return list;
|
||||
}
|
||||
|
||||
function scanJavaUncached() {
|
||||
const found = new Set();
|
||||
|
||||
// 1) JAVA_HOME
|
||||
@@ -257,7 +284,7 @@ async function modrinthProjectTitle(projectId) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
scanJava, probeJava,
|
||||
scanJava, probeJava, setCacheDir,
|
||||
getMcVersions,
|
||||
modrinthSearch, modrinthResolveFile, modrinthInstall, modrinthProjectTitle, downloadFile,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user