@@ -48,37 +48,56 @@ def __init__(self, addon=None):
4848
4949 def update_backup_location (self ):
5050 """Update backup location from settings"""
51+ xbmc .log ("BackupManager: Updating backup location settings" , xbmc .LOGINFO )
52+
5153 # Get backup location type from settings
5254 self .location_type = int (self .addon .getSetting ('backup_location_type' ) or "0" )
53-
55+ xbmc .log (f"BackupManager: Location type = { self .location_type } (0=Local, 1=Remote)" , xbmc .LOGINFO )
56+
5457 # Define paths for various Kodi directories
5558 self .kodi_home = xbmcvfs .translatePath ('special://home' )
5659 self .kodi_userdata = xbmcvfs .translatePath ('special://userdata' )
57-
60+ xbmc .log (f"BackupManager: Kodi paths - home: { self .kodi_home } , userdata: { self .kodi_userdata } " , xbmc .LOGDEBUG )
61+
5862 # Initialize backup_dir
5963 self .backup_dir = None
60-
64+
6165 # Handle local backup location
6266 if self .location_type == 0 : # Local
6367 self .backup_dir = self .addon .getSetting ('backup_location' )
68+ xbmc .log (f"BackupManager: Local backup location setting: { self .backup_dir } " , xbmc .LOGINFO )
69+
6470 if not self .backup_dir :
6571 self .backup_dir = "/storage/backup" # Default location
66-
72+ xbmc .log ("BackupManager: Using default local backup location: /storage/backup" , xbmc .LOGINFO )
73+
6774 # Validate that local path doesn't contain network protocols or remote path formats
6875 if self .backup_dir and (self .backup_dir .startswith (('nfs:' , 'smb:' , 'ftp:' , 'sftp:' , 'http:' , 'https:' )) or '://' in self .backup_dir or ':' in self .backup_dir ):
69- xbmc .log (f"Invalid local path detected (contains network protocol or remote path format): { self .backup_dir } " , xbmc .LOGWARNING )
76+ xbmc .log (f"BackupManager: Invalid local path detected (contains network protocol or remote path format): { self .backup_dir } " , xbmc .LOGWARNING )
7077 # Reset to default if invalid
7178 self .backup_dir = "/storage/backup"
7279 self .addon .setSetting ('backup_location' , self .backup_dir )
73- xbmc .log (f"Reset backup location to default: { self .backup_dir } " , xbmc .LOGINFO )
80+ xbmc .log ("BackupManager: Reset backup location to default: /storage/backup" , xbmc .LOGINFO )
81+ else :
82+ xbmc .log (f"BackupManager: Local backup directory validated: { self .backup_dir } " , xbmc .LOGINFO )
7483 else : # Remote
84+ xbmc .log ("BackupManager: Configuring remote backup settings" , xbmc .LOGINFO )
85+
7586 # Get remote settings
7687 self .remote_type = int (self .addon .getSetting ('remote_location_type' ) or "0" )
7788 self .remote_path = self .addon .getSetting ('remote_path' )
7889 self .remote_username = self .addon .getSetting ('remote_username' )
79- self . remote_password = self . addon . getSetting ( 'remote_password' )
90+ # Don't log password for security
8091 self .remote_port = int (self .addon .getSetting ('remote_port' ) or "0" )
81-
92+
93+ remote_type_names = ["SMB" , "NFS" , "FTP" , "SFTP" , "WebDAV" ]
94+ remote_type_name = remote_type_names [self .remote_type ] if self .remote_type < len (remote_type_names ) else f"Unknown({ self .remote_type } )"
95+
96+ xbmc .log (f"BackupManager: Remote type = { self .remote_type } ({ remote_type_name } )" , xbmc .LOGINFO )
97+ xbmc .log (f"BackupManager: Remote path = { self .remote_path } " , xbmc .LOGINFO )
98+ xbmc .log (f"BackupManager: Remote username = { self .remote_username } " , xbmc .LOGINFO )
99+ xbmc .log (f"BackupManager: Remote port = { self .remote_port } " , xbmc .LOGINFO )
100+
82101 # Set default ports if not specified
83102 if self .remote_port == 0 :
84103 if self .remote_type == 0 : # SMB
@@ -91,21 +110,28 @@ def update_backup_location(self):
91110 self .remote_port = 22
92111 elif self .remote_type == 4 : # WebDAV
93112 self .remote_port = 80
94-
113+ xbmc .log (f"BackupManager: Set default port for { remote_type_name } : { self .remote_port } " , xbmc .LOGINFO )
114+
95115 # Create a temporary local directory for staging remote files
96116 self .backup_dir = os .path .join (xbmcvfs .translatePath ('special://temp' ), 'libreelec_backupper' )
97-
117+ xbmc .log (f"BackupManager: Remote staging directory: { self .backup_dir } " , xbmc .LOGINFO )
118+
98119 # Ensure backup directory exists (only for remote backups where we create temp dirs)
99120 if self .location_type != 0 : # Remote
100121 if self .backup_dir and not os .path .exists (self .backup_dir ):
101122 try :
102123 os .makedirs (self .backup_dir )
124+ xbmc .log (f"BackupManager: Created staging directory: { self .backup_dir } " , xbmc .LOGINFO )
103125 except Exception as e :
104- xbmc .log (f"Error creating backup directory: { str (e )} " , xbmc .LOGERROR )
126+ xbmc .log (f"BackupManager: Error creating backup directory: { str (e )} " , xbmc .LOGERROR )
105127 # Fall back to addon profile if custom location can't be created
106128 self .backup_dir = xbmcvfs .translatePath (self .addon .getAddonInfo ('profile' ))
129+ xbmc .log (f"BackupManager: Falling back to addon profile directory: { self .backup_dir } " , xbmc .LOGWARNING )
107130 if not os .path .exists (self .backup_dir ):
108131 os .makedirs (self .backup_dir )
132+ xbmc .log ("BackupManager: Created fallback directory" , xbmc .LOGINFO )
133+
134+ xbmc .log (f"BackupManager: Final backup directory: { self .backup_dir } " , xbmc .LOGINFO )
109135
110136 def _create_webdav_session (self ):
111137 """Create a WebDAV session with retry logic and connection pooling"""
0 commit comments