From 0efe144b095721d64e81ae009e58736970f85c12 Mon Sep 17 00:00:00 2001 From: choibk Date: Mon, 26 Jan 2026 09:38:32 +0900 Subject: [PATCH] [STABLE] v0.4.2.2 - Critical stability fixes for production (Synology/NAS) --- server/index.js | 23 +++++------------------ server/routes/system.js | 26 ++++++++++---------------- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/server/index.js b/server/index.js index 16d26b4..f1705d6 100644 --- a/server/index.js +++ b/server/index.js @@ -51,6 +51,9 @@ const sessionStoreOptions = { }; const sessionStore = new MySQLStore(sessionStoreOptions); +sessionStore.on('error', (err) => { + console.error('Session Store Error:', err); +}); // Middleware app.use(cors({ @@ -456,29 +459,13 @@ initTables(); const packageJson = require('./package.json'); app.get('/api/health', (req, res) => { - // Force Korean time (UTC+9) for the timestamp + // Light-weight health check const kstOffset = 9 * 60 * 60 * 1000; const kstDate = new Date(Date.now() + kstOffset); - // Dynamic Version detection: Prioritize local Git Tag to match the "Update" rule - let version = '0.0.0.0'; - try { - const { execSync } = require('child_process'); - // Get the latest tag on the current commit - version = execSync('git describe --tags --abbrev=0', { cwd: path.join(__dirname, '..') }).toString().trim().replace(/^v/, ''); - } catch (e) { - // Fallback to root package.json if git fails - try { - const rootPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8')); - version = rootPkg.version; - } catch (err) { - version = packageJson.version; // Fallback to server/package.json - } - } - res.json({ status: 'ok', - version: version, + version: packageJson.version, node_version: process.version, platform: process.platform, arch: process.arch, diff --git a/server/routes/system.js b/server/routes/system.js index 36cab35..c5f05f9 100644 --- a/server/routes/system.js +++ b/server/routes/system.js @@ -489,30 +489,24 @@ const getGiteaAuth = async () => { // 5. Get Version Info (Current, Remote & History from Tags) router.get('/version/remote', isAuthenticated, hasRole('admin'), async (req, res) => { try { - // Dynamic Version detection: Prioritize local Git Tag + // Local version detection (No caching) let currentVersion = '0.0.0.0'; try { - currentVersion = execSync('git describe --tags --abbrev=0', { cwd: path.join(__dirname, '../..') }).toString().trim().replace(/^v/, ''); + const rootPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf8')); + currentVersion = rootPkg.version; } catch (e) { - try { - const packageJsonPath = path.resolve(__dirname, '../../package.json'); - const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); - currentVersion = packageJson.version; - } catch (err) { - currentVersion = '0.4.0.0'; // Ultimate fallback - } + currentVersion = '0.4.2.1'; } - // Prepare git fetch command with auth if available + // Prepare git fetch command const auth = await getGiteaAuth(); - let fetchCmd = 'git fetch --tags --force'; + let fetchCmd = 'git fetch --tags'; - if (auth.user && auth.pass) { + if (auth.user && auth.pass && auth.url && auth.url.includes('https://')) { const authenticatedUrl = auth.url.replace('https://', `https://${encodeURIComponent(auth.user)}:${encodeURIComponent(auth.pass)}@`); - // Use explicit refspec to ensure local tags are updated from the remote URL - fetchCmd = `git fetch ${authenticatedUrl} +refs/tags/*:refs/tags/* --force --prune --prune-tags`; - } else { - fetchCmd = `git fetch ${auth.url} +refs/tags/*:refs/tags/* --force --prune --prune-tags`; + fetchCmd = `git fetch ${authenticatedUrl} --tags --force --prune`; + } else if (auth.url) { + fetchCmd = `git fetch ${auth.url} --tags --force --prune`; } exec(fetchCmd, (err, stdout, stderr) => {