mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Startup: Unbreak last_file when the file is missing
Fix #9887, likely a regression since #9669
This commit is contained in:
59
reader.lua
59
reader.lua
@@ -271,15 +271,11 @@ end
|
||||
local exit_code
|
||||
if file then
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
UIManager:nextTick(function()
|
||||
ReaderUI:showReader(file)
|
||||
end)
|
||||
ReaderUI:showReader(file)
|
||||
exit_code = UIManager:run()
|
||||
elseif directory then
|
||||
local FileManager = require("apps/filemanager/filemanager")
|
||||
UIManager:nextTick(function()
|
||||
FileManager:showFiles(directory)
|
||||
end)
|
||||
FileManager:showFiles(directory)
|
||||
exit_code = UIManager:run()
|
||||
else
|
||||
local QuickStart = require("ui/quickstart")
|
||||
@@ -290,47 +286,38 @@ else
|
||||
|
||||
if start_with == "last" and last_file and lfs.attributes(last_file, "mode") ~= "file" then
|
||||
UIManager:show(retryLastFile())
|
||||
-- no exit code as something else will be run after this.
|
||||
UIManager:run()
|
||||
-- We'll want to return from this without actually quitting,
|
||||
-- so this is a slightly mangled UIManager:run() call to coerce the main loop into submission...
|
||||
-- We'll call :run properly in either of the following branches once returning.
|
||||
UIManager:runOnce()
|
||||
end
|
||||
if start_with == "last" and last_file then
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
UIManager:nextTick(function()
|
||||
-- Instantiate RD
|
||||
ReaderUI:showReader(last_file)
|
||||
end)
|
||||
-- Instantiate RD
|
||||
ReaderUI:showReader(last_file)
|
||||
exit_code = UIManager:run()
|
||||
else
|
||||
local FileManager = require("apps/filemanager/filemanager")
|
||||
local home_dir =
|
||||
G_reader_settings:readSetting("home_dir") or Device.home_dir or lfs.currentdir()
|
||||
UIManager:nextTick(function()
|
||||
-- Instantiate FM
|
||||
FileManager:showFiles(home_dir)
|
||||
end)
|
||||
local home_dir = G_reader_settings:readSetting("home_dir") or Device.home_dir or lfs.currentdir()
|
||||
-- Instantiate FM
|
||||
FileManager:showFiles(home_dir)
|
||||
-- Always open FM modules on top of filemanager, so closing 'em doesn't result in an exit
|
||||
-- because of an empty widget stack, and so they can interact with the FM instance as expected.
|
||||
if start_with == "history" then
|
||||
local FileManagerHistory = require("apps/filemanager/filemanagerhistory")
|
||||
UIManager:nextTick(function()
|
||||
FileManagerHistory:new{
|
||||
ui = FileManager.instance,
|
||||
}:onShowHist()
|
||||
end)
|
||||
FileManagerHistory:new{
|
||||
ui = FileManager.instance,
|
||||
}:onShowHist()
|
||||
elseif start_with == "favorites" then
|
||||
local FileManagerCollection = require("apps/filemanager/filemanagercollection")
|
||||
UIManager:nextTick(function()
|
||||
FileManagerCollection:new{
|
||||
ui = FileManager.instance,
|
||||
}:onShowColl("favorites")
|
||||
end)
|
||||
FileManagerCollection:new{
|
||||
ui = FileManager.instance,
|
||||
}:onShowColl("favorites")
|
||||
elseif start_with == "folder_shortcuts" then
|
||||
local FileManagerShortcuts = require("apps/filemanager/filemanagershortcuts")
|
||||
UIManager:nextTick(function()
|
||||
FileManagerShortcuts:new{
|
||||
ui = FileManager.instance,
|
||||
}:onShowFolderShortcutsDialog()
|
||||
end)
|
||||
FileManagerShortcuts:new{
|
||||
ui = FileManager.instance,
|
||||
}:onShowFolderShortcutsDialog()
|
||||
end
|
||||
exit_code = UIManager:run()
|
||||
end
|
||||
@@ -342,8 +329,10 @@ local function exitReader()
|
||||
local ko_exit = os.getenv("KO_EXIT_CODE")
|
||||
if ko_exit then
|
||||
local fo = io.open(ko_exit, "w+")
|
||||
fo:write(tostring(exit_code))
|
||||
fo:close()
|
||||
if fo then
|
||||
fo:write(tostring(exit_code))
|
||||
fo:close()
|
||||
end
|
||||
end
|
||||
|
||||
local ReaderActivityIndicator =
|
||||
|
||||
Reference in New Issue
Block a user