Compare commits

...

2 Commits

Author SHA1 Message Date
302c75c534 Bump version to 2.0.9 and update README
- Updated version to 2.0.9
- Added new changelog entries for all fixes
- Documented remote connection fixes
- Documented update button and status endpoint additions

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-07 09:25:19 +00:00
8887f6fda1 Add system status and update endpoints
- Added /api/system/status endpoint to report application status
- Added /api/system/check-updates endpoint to check for updates via git
- Added /api/system/update endpoint for applying updates
- Fixed update button in dashboard
- Added proper error handling for git operations

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-07 09:24:27 +00:00
3 changed files with 184 additions and 2 deletions

View File

@ -1,9 +1,17 @@
# Transmission RSS Manager v2.0.8
# Transmission RSS Manager v2.0.9
A comprehensive web-based tool to automate and manage your Transmission torrent downloads with RSS feed integration, intelligent media organization, and enhanced security features. Now with automatic updates and easy installation!
## Changelog
### v2.0.9 (2025-03-07)
- **Fixed**: Update button now appears properly on dashboard
- **Fixed**: Remote Transmission connection issues resolved
- **Fixed**: Improved connection test with better error handling
- **Added**: System status and update endpoints for version checking
- **Improved**: Update detection and notification on dashboard
- **Improved**: Better error handling for git operations
### v2.0.8 (2025-03-07)
- **Fixed**: Module import issues on fresh installations with proper file extension handling
- **Fixed**: Adding compatibility symlinks for different module naming styles

View File

@ -1,6 +1,6 @@
{
"name": "transmission-rss-manager",
"version": "2.0.8",
"version": "2.0.9",
"description": "A comprehensive web-based tool to automate and manage your Transmission torrent downloads with RSS feed integration and intelligent media organization",
"main": "server.js",
"scripts": {

174
server.js
View File

@ -13,6 +13,10 @@ const http = require('http');
const https = require('https');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');
const { exec } = require('child_process');
const util = require('util');
const execAsync = util.promisify(exec);
const semver = require('semver'); // For semantic version comparison
// Import custom modules
// Try to import with .js extension first, then fallback to no extension for better compatibility
@ -1196,6 +1200,176 @@ app.get('/api/auth/validate', authenticateJWT, (req, res) => {
});
});
// System status and update endpoints
app.get('/api/system/status', authenticateJWT, async (req, res) => {
try {
// Get system uptime
const uptimeSeconds = Math.floor(process.uptime());
const hours = Math.floor(uptimeSeconds / 3600);
const minutes = Math.floor((uptimeSeconds % 3600) / 60);
const seconds = uptimeSeconds % 60;
const uptime = `${hours}h ${minutes}m ${seconds}s`;
// Check transmission connection
let transmissionStatus = 'Connected';
try {
const status = await transmissionClient.getStatus();
if (!status.connected) {
transmissionStatus = 'Disconnected';
}
} catch (err) {
transmissionStatus = 'Disconnected';
}
res.json({
status: 'success',
data: {
version: APP_VERSION,
uptime,
transmissionStatus
}
});
} catch (error) {
console.error('Error getting system status:', error);
res.status(500).json({
status: 'error',
message: 'Failed to get system status'
});
}
});
// Check for updates
app.get('/api/system/check-updates', authenticateJWT, async (req, res) => {
try {
// Check if git is available and if this is a git repository
const isGitRepo = fs.existsSync(path.join(__dirname, '.git'));
if (!isGitRepo) {
return res.json({
status: 'error',
message: 'This installation is not set up for updates. Please use the bootstrap installer.'
});
}
// Get current version
const currentVersion = APP_VERSION;
// Check for test mode flag which forces update availability for testing
const testMode = req.query.test === 'true';
if (testMode) {
// In test mode, always return that an update is available
return res.json({
status: 'success',
data: {
updateAvailable: true,
currentVersion,
remoteVersion: '2.1.0-test',
commitsBehind: 1,
testMode: true
}
});
}
try {
// Normal mode - fetch latest updates without applying them
await execAsync('git fetch');
// Check if we're behind the remote repository
const { stdout } = await execAsync('git rev-list HEAD..origin/main --count');
const behindCount = parseInt(stdout.trim());
if (behindCount > 0) {
// Get the new version from the remote package.json
const { stdout: remotePackageJson } = await execAsync('git show origin/main:package.json');
const remotePackage = JSON.parse(remotePackageJson);
const remoteVersion = remotePackage.version;
// Compare versions semantically - only consider it an update if remote version is higher
const isNewerVersion = semver.gt(remoteVersion, currentVersion);
return res.json({
status: 'success',
data: {
updateAvailable: isNewerVersion,
currentVersion,
remoteVersion,
commitsBehind: behindCount,
newerVersion: isNewerVersion
}
});
} else {
return res.json({
status: 'success',
data: {
updateAvailable: false,
currentVersion
}
});
}
} catch (gitError) {
console.error('Git error checking for updates:', gitError);
// Even if git commands fail, return a valid response with error information
return res.json({
status: 'error',
message: 'Error checking git repository: ' + gitError.message,
data: {
updateAvailable: false,
currentVersion,
error: true,
errorDetails: gitError.message
}
});
}
} catch (error) {
console.error('Error checking for updates:', error);
res.status(500).json({
status: 'error',
message: 'Failed to check for updates: ' + error.message
});
}
});
// Apply updates
app.post('/api/system/update', authenticateJWT, async (req, res) => {
try {
// Check if git is available and if this is a git repository
const isGitRepo = fs.existsSync(path.join(__dirname, '.git'));
if (!isGitRepo) {
return res.status(400).json({
status: 'error',
message: 'This installation is not set up for updates. Please use the bootstrap installer.'
});
}
// Run the update script
const updateScriptPath = path.join(__dirname, 'scripts', 'update.sh');
// Make sure the update script is executable
await execAsync(`chmod +x ${updateScriptPath}`);
// Execute the update script
const { stdout, stderr } = await execAsync(updateScriptPath);
// If we get here, the update was successful
// The service will be restarted by the update script
res.json({
status: 'success',
message: 'Update applied successfully. The service will restart.',
data: {
output: stdout,
errors: stderr
}
});
} catch (error) {
console.error('Error applying update:', error);
res.status(500).json({
status: 'error',
message: 'Failed to apply update: ' + error.message
});
}
});
// Catch-all route for SPA
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));