Fix Transmission connection testing and API compatibility
- Updated TransmissionClient to use correct method names from transmission-promise - Changed sessionGet to session() and sessionSet to sessionUpdate() - Added robust error handling in connection test - Improved logging for connection debugging - Fixed error handling in TransmissionClient constructor 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -28,8 +28,14 @@ class TransmissionClient {
|
||||
this.dirMappings = config.remoteConfig.directoryMapping;
|
||||
}
|
||||
|
||||
// Initialize the connection
|
||||
this.initializeConnection();
|
||||
// Initialize the connection - but don't throw if it fails initially
|
||||
// This allows the object to be created even if the connection fails
|
||||
try {
|
||||
this.initializeConnection();
|
||||
} catch (error) {
|
||||
console.error("Failed to initialize Transmission connection:", error.message);
|
||||
// Don't throw - allow methods to handle connection retry logic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,13 +70,17 @@ class TransmissionClient {
|
||||
*/
|
||||
async getStatus() {
|
||||
try {
|
||||
// Use the session-stats method for basic connectivity check
|
||||
const sessionInfo = await this.client.sessionStats();
|
||||
const version = await this.client.sessionGet();
|
||||
|
||||
// Use the session-get method to get version info
|
||||
// Note: In transmission-promise, this is 'session' not 'sessionGet'
|
||||
const session = await this.client.session();
|
||||
|
||||
return {
|
||||
connected: true,
|
||||
version: version.version,
|
||||
rpcVersion: version['rpc-version'],
|
||||
version: session.version || "Unknown",
|
||||
rpcVersion: session['rpc-version'] || "Unknown",
|
||||
downloadSpeed: sessionInfo.downloadSpeed,
|
||||
uploadSpeed: sessionInfo.uploadSpeed,
|
||||
torrentCount: sessionInfo.torrentCount,
|
||||
@@ -446,7 +456,8 @@ class TransmissionClient {
|
||||
*/
|
||||
async setSessionParams(params) {
|
||||
try {
|
||||
await this.client.sessionSet(params);
|
||||
// In transmission-promise, the method is sessionUpdate not sessionSet
|
||||
await this.client.sessionUpdate(params);
|
||||
return {
|
||||
success: true,
|
||||
message: 'Session parameters updated successfully'
|
||||
|
||||
Reference in New Issue
Block a user