[STABLE] v0.4.2.2 - Critical stability fixes for production (Synology/NAS)

This commit is contained in:
choibk 2026-01-26 09:38:32 +09:00
parent 3aa442e0fa
commit 0efe144b09
2 changed files with 15 additions and 34 deletions

View File

@ -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,

View File

@ -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) => {