diff --git a/plugins/wallabag.koplugin/main.lua b/plugins/wallabag.koplugin/main.lua index 2a53d21a4..416eeb4d6 100644 --- a/plugins/wallabag.koplugin/main.lua +++ b/plugins/wallabag.koplugin/main.lua @@ -667,6 +667,7 @@ function Wallabag:callAPI(method, apiurl, headers, body, filepath, quiet) -- raise error message when network is unavailable if resp_headers == nil then logger.dbg("Wallabag: Server error:", status or code) + self:removeFailedDownload(filepath) return nil, "network_error" end if code == 200 then @@ -693,11 +694,7 @@ function Wallabag:callAPI(method, apiurl, headers, body, filepath, quiet) end else if filepath ~= "" then - local entry_mode = lfs.attributes(filepath, "mode") - if entry_mode == "file" then - os.remove(filepath) - logger.dbg("Wallabag: Removed failed download:", filepath) - end + self:removeFailedDownload(filepath) elseif not quiet then UIManager:show(InfoMessage:new{ text = _("Communication with server failed."), }) @@ -708,6 +705,16 @@ function Wallabag:callAPI(method, apiurl, headers, body, filepath, quiet) end end +function Wallabag:removeFailedDownload(filepath) + if filepath ~= "" then + local entry_mode = lfs.attributes(filepath, "mode") + if entry_mode == "file" then + os.remove(filepath) + logger.dbg("Wallabag: Removed failed download:", filepath) + end + end +end + function Wallabag:synchronize() local info = InfoMessage:new{ text = _("Connecting…") } UIManager:show(info)