Upload via GUI (21 Dateien)

This commit is contained in:
Git Manager GUI
2026-08-01 19:32:20 +02:00
parent afe02f81be
commit 7a6b31fb11
13 changed files with 858 additions and 20 deletions
+29 -2
View File
@@ -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,
};