Fix update functionality and improve documentation

- Fixed update detection in install scripts
- Added Git availability checks to update system
- Improved error handling for update endpoint
- Added detailed Git requirements to README
- Added troubleshooting section for update issues

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-03-10 16:57:47 +00:00
parent 9b45e669e2
commit 2dcd4becef
8 changed files with 535 additions and 105 deletions
+64 -7
View File
@@ -45,6 +45,7 @@ function loadModule(baseName) {
`./modules/${baseName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()}`
];
console.log(`Attempting to load module: ${baseName}`);
let lastError = null;
for (const modulePath of paths) {
try {
@@ -1236,7 +1237,16 @@ app.get('/api/auth/validate', authenticateJWT, (req, res) => {
});
});
// System status and update endpoints
// System endpoints - consolidated from server-endpoints.js
// Ensure TransmissionClient has the necessary methods
if (!TransmissionClient.prototype.sessionGet && TransmissionClient.prototype.getStatus) {
// Add compatibility method if missing
TransmissionClient.prototype.sessionGet = async function() {
return this.getStatus();
};
}
// System status endpoint
app.get('/api/system/status', authenticateJWT, async (req, res) => {
try {
// Get system uptime
@@ -1249,11 +1259,12 @@ app.get('/api/system/status', authenticateJWT, async (req, res) => {
// Check transmission connection
let transmissionStatus = 'Connected';
try {
const status = await transmissionClient.getStatus();
if (!status.connected) {
const status = await transmissionClient.sessionGet();
if (!status || (status.connected === false)) {
transmissionStatus = 'Disconnected';
}
} catch (err) {
console.error('Transmission connection error:', err);
transmissionStatus = 'Disconnected';
}
@@ -1278,11 +1289,34 @@ app.get('/api/system/status', authenticateJWT, async (req, res) => {
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'));
let isGitRepo = false;
let isGitAvailable = false;
try {
// First check if git command is available
await execAsync('which git');
isGitAvailable = true;
// Then check if directory is a git repository
isGitRepo = await fs.access(path.join(__dirname, '.git'))
.then(() => true)
.catch(() => false);
} catch (error) {
console.error('Error checking git availability:', error);
isGitAvailable = false;
}
if (!isGitAvailable) {
return res.json({
status: 'error',
message: 'Git is not installed or not available. Please install Git to enable updates.'
});
}
if (!isGitRepo) {
return res.json({
status: 'error',
message: 'This installation is not set up for updates. Please use the bootstrap installer.'
message: 'This installation is not set up as a Git repository. Please use the bootstrap installer.'
});
}
@@ -1370,11 +1404,34 @@ app.get('/api/system/check-updates', authenticateJWT, async (req, res) => {
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'));
let isGitRepo = false;
let isGitAvailable = false;
try {
// First check if git command is available
await execAsync('which git');
isGitAvailable = true;
// Then check if directory is a git repository
isGitRepo = await fs.access(path.join(__dirname, '.git'))
.then(() => true)
.catch(() => false);
} catch (error) {
console.error('Error checking git availability:', error);
isGitAvailable = false;
}
if (!isGitAvailable) {
return res.status(400).json({
status: 'error',
message: 'Git is not installed or not available. Please install Git to enable updates.'
});
}
if (!isGitRepo) {
return res.status(400).json({
status: 'error',
message: 'This installation is not set up for updates. Please use the bootstrap installer.'
message: 'This installation is not set up as a Git repository. Please use the bootstrap installer.'
});
}