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()