Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/lua/xml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function xml.LoadXMLFile(fileName)
local fileText = fileHnd:read("*a")
fileHnd:close()
if not fileText then
return nil, fileName.." file returns nil. OneDrive?"
return nil, fileName.." file returns nil"
elseif fileText == "" then
return nil, fileName.." file is empty"
end
Expand Down
10 changes: 6 additions & 4 deletions src/Modules/Build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1820,11 +1820,13 @@ end
function buildMode:LoadDB(xmlText, fileName)
-- Parse the XML
local dbXML, errMsg = common.xml.ParseXML(xmlText)
if not dbXML then
launch:ShowErrMsg("^1Error loading '%s': %s", fileName, errMsg)
if errMsg and errMsg:match(".*file returns nil") then
ConPrintf("Error: '%s'", errMsg)
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..errMsg..'"')
return true
elseif #dbXML == 0 then
main:OpenMessagePopup("Error", "Build file is empty, or error parsing xml.\n\n"..fileName)
elseif errMsg then
ConPrintf("Error: '%s'", errMsg)
launch:ShowErrMsg("^1"..errMsg)
return true
elseif dbXML[1].elem ~= "PathOfBuilding" then
launch:ShowErrMsg("^1Error parsing '%s': 'PathOfBuilding' root element missing", fileName)
Expand Down
4 changes: 4 additions & 0 deletions src/Modules/BuildList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ function listMode:BuildList()
if fileHnd then
local fileText = fileHnd:read("*a")
fileHnd:close()
if not fileText then
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..build.fullFileName..'"')
return
end
fileText = fileText:match("(<Build.->)")
if fileText then
local xml = common.xml.ParseXML(fileText.."</Build>")
Expand Down
21 changes: 19 additions & 2 deletions src/Modules/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ function main:Init()
self.uniqueDB = { list = { }, loading = true }
self.rareDB = { list = { }, loading = true }

self.saveSettingsOnExit = true

local function loadItemDBs()
for type, typeList in pairsYield(data.uniques) do
for _, raw in pairs(typeList) do
Expand Down Expand Up @@ -516,9 +518,15 @@ end

function main:LoadSettings(ignoreBuild)
local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml")
if errMsg and not errMsg:match(".*No such file or directory") then
if errMsg and errMsg:match(".*file returns nil") then
ConPrintf("Error: '%s'", errMsg)
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..errMsg..'"')
self.saveSettingsOnExit = false
return true
elseif errMsg and not errMsg:match(".*No such file or directory") then
ConPrintf("Error: '%s'", errMsg)
launch:ShowErrMsg("^1"..errMsg)
self.saveSettingsOnExit = false
return true
end
if not setXML then
Expand Down Expand Up @@ -656,9 +664,15 @@ end

function main:LoadSharedItems()
local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml")
if errMsg and not errMsg:match(".*No such file or directory") then
if errMsg and errMsg:match(".*file returns nil") then
ConPrintf("Error: '%s'", errMsg)
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..errMsg..'"')
self.saveSettingsOnExit = false
return true
elseif errMsg and not errMsg:match(".*No such file or directory") then
ConPrintf("Error: '%s'", errMsg)
launch:ShowErrMsg("^1"..errMsg)
self.saveSettingsOnExit = false
return true
end
if not setXML then
Expand Down Expand Up @@ -703,6 +717,9 @@ function main:LoadSharedItems()
end

function main:SaveSettings()
if not self.saveSettingsOnExit then
return
end
local setXML = { elem = "PathOfBuilding" }
local mode = { elem = "Mode", attrib = { mode = self.mode } }
for _, val in ipairs({ self:CallMode("GetArgs") }) do
Expand Down