From 57cbde5901cfd9c5d637575ec3309cb87ab54659 Mon Sep 17 00:00:00 2001 From: mergen3107 <6279855+mergen3107@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:45:16 -0500 Subject: [PATCH] [plugin] Add folder check in move-to-archive (#11262) --- frontend/util.lua | 5 +++++ plugins/movetoarchive.koplugin/main.lua | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/util.lua b/frontend/util.lua index fe003dbaf..c75e7f43b 100644 --- a/frontend/util.lua +++ b/frontend/util.lua @@ -758,6 +758,11 @@ function util.pathExists(path) return lfs.attributes(path, "mode") ~= nil end +--- Checks if the given directory exists. +function util.directoryExists(path) + return lfs.attributes(path, "mode") == "directory" +end + --- As `mkdir -p`. -- Unlike [lfs.mkdir](https://keplerproject.github.io/luafilesystem/manual.html#mkdir)(), -- does not error if the directory already exists, and creates intermediate directories as needed. diff --git a/plugins/movetoarchive.koplugin/main.lua b/plugins/movetoarchive.koplugin/main.lua index 1f5469f29..0f85ed566 100644 --- a/plugins/movetoarchive.koplugin/main.lua +++ b/plugins/movetoarchive.koplugin/main.lua @@ -50,7 +50,7 @@ function MoveToArchive:addToMainMenu(menu_items) { text = _("Go to archive folder"), callback = function() - if self.archive_dir_path then + if self.archive_dir_path and util.directoryExists(self.archive_dir_path) then self:openFileBrowser(self.archive_dir_path) else self:showNoArchiveConfirmBox()