Skip to content

Commit 5bf450a

Browse files
author
Nigel
committed
Fix NFS/SMB mounting and path handling issues
- Add 'nolock' option to NFS mount commands for better compatibility - Fix SMB path conversion when browsing (smb://server/share -> server:/share) - Prevent local backup path reset when NFS mounts are inaccessible - Improve error handling for remote connections
1 parent 2d3046b commit 5bf450a

2 files changed

Lines changed: 29 additions & 20 deletions

File tree

service.libreelec.backupper/resources/lib/backup_utils.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,17 @@ def update_backup_location(self):
9595
# Create a temporary local directory for staging remote files
9696
self.backup_dir = os.path.join(xbmcvfs.translatePath('special://temp'), 'libreelec_backupper')
9797

98-
# Ensure backup directory exists
99-
if self.backup_dir and not os.path.exists(self.backup_dir):
100-
try:
101-
os.makedirs(self.backup_dir)
102-
except Exception as e:
103-
xbmc.log(f"Error creating backup directory: {str(e)}", xbmc.LOGERROR)
104-
# Fall back to addon profile if custom location can't be created
105-
self.backup_dir = xbmcvfs.translatePath(self.addon.getAddonInfo('profile'))
106-
if not os.path.exists(self.backup_dir):
98+
# Ensure backup directory exists (only for remote backups where we create temp dirs)
99+
if self.location_type != 0: # Remote
100+
if self.backup_dir and not os.path.exists(self.backup_dir):
101+
try:
107102
os.makedirs(self.backup_dir)
108-
if self.location_type == 0: # Only update setting for local backups
109-
self.addon.setSetting('backup_location', self.backup_dir)
103+
except Exception as e:
104+
xbmc.log(f"Error creating backup directory: {str(e)}", xbmc.LOGERROR)
105+
# Fall back to addon profile if custom location can't be created
106+
self.backup_dir = xbmcvfs.translatePath(self.addon.getAddonInfo('profile'))
107+
if not os.path.exists(self.backup_dir):
108+
os.makedirs(self.backup_dir)
110109

111110
def _create_webdav_session(self):
112111
"""Create a WebDAV session with retry logic and connection pooling"""
@@ -188,9 +187,9 @@ def connect_remote(self):
188187
subprocess.call(["umount", mount_point], stderr=subprocess.DEVNULL)
189188

190189
# Mount the NFS share with proper options
191-
# Use soft mount and shorter timeout for better error handling
192-
mount_options = ["-t", "nfs", "-o", "soft,timeo=10,retrans=2"]
193-
result = subprocess.call(["mount"] + mount_options + [nfs_path, mount_point],
190+
# Use soft mount, shorter timeout, and nolock for better compatibility
191+
mount_options = ["-t", "nfs", "-o", "soft,timeo=10,retrans=2,nolock"]
192+
result = subprocess.call(["mount"] + mount_options + [nfs_path, mount_point],
194193
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
195194

196195
if result == 0:
@@ -2176,4 +2175,4 @@ def get_next_scheduled_backup(self):
21762175

21772176
except Exception as e:
21782177
xbmc.log(f"{ADDON_ID}: Error calculating next backup time: {str(e)}", xbmc.LOGERROR)
2179-
return "Unknown"
2178+
return "Unknown"

service.libreelec.backupper/resources/lib/remote_browser.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,20 @@ def browse_with_kodi_browser(self, protocol_name, mode='backup'):
160160
# Remove trailing slash if present
161161
if path.endswith('/'):
162162
path = path[:-1]
163-
163+
164+
# Convert from smb://server/share format to server:/share format
165+
if '/' in path:
166+
parts = path.split('/', 1)
167+
server = parts[0]
168+
share = parts[1]
169+
# Convert to the expected format: server:/share
170+
expected_path = f"{server}:{share}" if share else server
171+
else:
172+
expected_path = path
173+
164174
# Update the remote path setting
165-
self.remote_path = path
166-
ADDON.setSetting('remote_path', path)
175+
self.remote_path = expected_path
176+
ADDON.setSetting('remote_path', expected_path)
167177
# Force settings save immediately
168178
xbmc.executebuiltin('UpdateLocalAddons')
169179
xbmc.sleep(200) # Brief pause to ensure settings are saved
@@ -605,7 +615,7 @@ def _test_nfs_connection(self):
605615
subprocess.call(["umount", mount_point], stderr=subprocess.DEVNULL)
606616

607617
# Try to mount with proper options
608-
mount_options = ["-t", "nfs", "-o", "soft,timeo=10,retrans=2"]
618+
mount_options = ["-t", "nfs", "-o", "soft,timeo=10,retrans=2,nolock"]
609619
result = subprocess.call(["mount"] + mount_options + [self.remote_path, mount_point],
610620
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
611621

@@ -1253,4 +1263,4 @@ def main():
12531263
browser.browse()
12541264

12551265
if __name__ == "__main__":
1256-
main()
1266+
main()

0 commit comments

Comments
 (0)