CloudStorage: Log download failures (#7834)

Re #7354
This commit is contained in:
NiLuJe
2021-06-12 21:11:53 +02:00
committed by GitHub
parent 002b4d4be9
commit 6b31b160a2
2 changed files with 10 additions and 4 deletions

View File

@@ -84,7 +84,7 @@ end
function DropBoxApi:downloadFile(path, token, local_path)
local data1 = "{\"path\": \"" .. path .. "\"}"
socketutil:set_timeout(socketutil.FILE_BLOCK_TIMEOUT, socketutil.FILE_TOTAL_TIMEOUT)
local code_return = socket.skip(1, http.request{
local code, _, status = socket.skip(1, http.request{
url = API_DOWNLOAD_FILE,
method = "GET",
headers = {
@@ -94,7 +94,10 @@ function DropBoxApi:downloadFile(path, token, local_path)
sink = ltn12.sink.file(io.open(local_path, "w")),
})
socketutil:reset_timeout()
return code_return
if code ~= 200 then
logger.warn("DropBoxApi: Download failure:", status or code or "network unreachable")
end
return code
end
-- folder_mode - set to true when we want to see only folder.

View File

@@ -158,7 +158,7 @@ end
function WebDavApi:downloadFile(file_url, user, pass, local_path)
socketutil:set_timeout(socketutil.FILE_BLOCK_TIMEOUT, socketutil.FILE_TOTAL_TIMEOUT)
local code_return = socket.skip(1, http.request{
local code, _, status = socket.skip(1, http.request{
url = file_url,
method = "GET",
sink = ltn12.sink.file(io.open(local_path, "w")),
@@ -166,7 +166,10 @@ function WebDavApi:downloadFile(file_url, user, pass, local_path)
password = pass,
})
socketutil:reset_timeout()
return code_return
if code ~= 200 then
logger.warn("WebDavApi: Download failure:", status or code or "network unreachable")
end
return code
end
return WebDavApi