mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user