From 27bf5b59dd980c19439c023356fd039a788c5375 Mon Sep 17 00:00:00 2001 From: John Beard Date: Fri, 27 Aug 2021 08:40:14 +0100 Subject: [PATCH] Add slash to WebDAV starting URL if missing (#8137) If this is not done, the URL when the file is downloaded will be something like hostdir/path, rather than host/dir/path. Also add a debug log to make it more clear when a bogus URL is being fetched, --- frontend/apps/cloudstorage/webdav.lua | 8 ++++++++ frontend/apps/cloudstorage/webdavapi.lua | 1 + 2 files changed, 9 insertions(+) diff --git a/frontend/apps/cloudstorage/webdav.lua b/frontend/apps/cloudstorage/webdav.lua index 044b52b3f..ffb3ec8b1 100644 --- a/frontend/apps/cloudstorage/webdav.lua +++ b/frontend/apps/cloudstorage/webdav.lua @@ -126,6 +126,14 @@ The start folder is appended to the server path.]]) text = text_button_ok, callback = function() local fields = MultiInputDialog:getFields() + + -- make sure the URL is a valid path + if fields[5] ~= "" then + if string.sub(fields[5], 1, 1) ~= '/' then + fields[5] = '/' .. fields[5] + end + end + if fields[1] ~= "" and fields[2] ~= "" then if item then -- edit diff --git a/frontend/apps/cloudstorage/webdavapi.lua b/frontend/apps/cloudstorage/webdavapi.lua index edd5f5330..995a501c3 100644 --- a/frontend/apps/cloudstorage/webdavapi.lua +++ b/frontend/apps/cloudstorage/webdavapi.lua @@ -164,6 +164,7 @@ end function WebDavApi:downloadFile(file_url, user, pass, local_path) socketutil:set_timeout(socketutil.FILE_BLOCK_TIMEOUT, socketutil.FILE_TOTAL_TIMEOUT) + logger.dbg("WebDavApi: downloading file: ", file_url) local code, _, status = socket.skip(1, http.request{ url = file_url, method = "GET",