Skip to content
Permalink
Browse files

"Remove read articles" instead "remove all"

  • Loading branch information...
mwoz123
mwoz123 committed Feb 16, 2018
1 parent e943548 commit 6ecd191c2d6568f204e92563d11f8d9afe87f132
Showing with 11 additions and 8 deletions.
  1. +11 −8 plugins/send2ebook.koplugin/main.lua
@@ -1,4 +1,5 @@
local DataStorage = require("datastorage")
local DocSettings = require("frontend/docsettings")
local ReadHistory = require("readhistory")
local FFIUtil = require("ffi/util")
local FtpApi = require("apps/cloudstorage/ftpapi")
@@ -85,8 +86,8 @@ function Send2Ebook:addToMainMenu(menu_items)
end,
},
{
text = _("Remove all from download folder"),
callback = function() self:removeNewsButKeepConfig() end,
text = _("Remove read articles"),
callback = function() self:removeReadActicles() end,

This comment has been minimized.

Copy link
@Frenzie

Frenzie Feb 16, 2018

Member

Does this need to be an anonymous function of would it work as self.removeReadArticles?

This comment has been minimized.

Copy link
@mwoz123

mwoz123 Feb 17, 2018

Contributor

without this wrap function, it's started right after top menu is opened. You don't have to even choose "Remove read articles", so that's wrong.

This comment has been minimized.

Copy link
@Frenzie

Frenzie Feb 18, 2018

Member

I'm not saying self.blabla() (execution) but self.blabla (reference).

},
{
text = _("Set custom download directory"),
@@ -161,16 +162,18 @@ function Send2Ebook:process()
Send2Ebook:afterWifiAction()
end

function Send2Ebook:removeNewsButKeepConfig()
function Send2Ebook:removeReadActicles()
logger.dbg("Send2Ebook: Removing news from :", download_dir_path)
for entry in lfs.dir(download_dir_path) do
if entry ~= "." and entry ~= ".." and entry ~= ftp_connection_config_file then
local entry_path = download_dir_path .. "/" .. entry
local entry_mode = lfs.attributes(entry_path, "mode")
if entry_mode == "file" then
ffi.C.remove(entry_path)
elseif entry_mode == "directory" then
FFIUtil.purgeDir(entry_path)
if DocSettings:hasSidecarFile(entry_path) then
local entry_mode = lfs.attributes(entry_path, "mode")
if entry_mode == "file" then
ffi.C.remove(entry_path)

This comment has been minimized.

Copy link
@Frenzie

Frenzie Feb 16, 2018

Member

Why not simply os.remove?

elseif entry_mode == "directory" then
FFIUtil.purgeDir(entry_path)
end
end
end
end

0 comments on commit 6ecd191

Please sign in to comment.
You can’t perform that action at this time.