Skip to content

Commit c4ba03f

Browse files
committed
use GetCloudProvider
1 parent 8f85a76 commit c4ba03f

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

src/HeadlessWrapper.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function PCall(func, ...)
146146
return nil, unpack(ret)
147147
else
148148
return ret[2]
149-
end
149+
end
150150
end
151151
function ConPrintf(fmt, ...)
152152
-- Optional
@@ -162,6 +162,14 @@ function Restart() end
162162
function Exit() end
163163
function TakeScreenshot() end
164164

165+
---@return string? provider
166+
---@return string? version
167+
---@return number? status
168+
function GetCloudProvider(fullPath)
169+
return nil, nil, nil
170+
end
171+
172+
165173
local l_require = require
166174
function require(name)
167175
-- Hack to stop it looking for lcurl, which we don't really need

src/Modules/Build.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ do
18141814
if int and (int > 14 or int > self.calcsTab.mainOutput.Int) then
18151815
t_insert(req, s_format("%s%d ^x7F7F7FInt", main:StatColor(int, intBase, self.calcsTab.mainOutput.Int), int))
18161816
end
1817-
end
1817+
end
18181818
if req[1] then
18191819
local fontSizeBig = main.showFlavourText and 18 or 16
18201820
tooltip:AddLine(fontSizeBig, "^x7F7F7FRequires "..table.concat(req, "^x7F7F7F, "), "FONTIN SC")
@@ -1828,10 +1828,9 @@ function buildMode:LoadDB(xmlText, fileName)
18281828
-- Parse the XML
18291829
local dbXML, errMsg = common.xml.ParseXML(xmlText)
18301830
if errMsg and errMsg:match(".*file returns nil") then
1831-
main:OpenOneDriveErrPopup(fileName)
1831+
main:OpenCloudErrorPopup(fileName)
18321832
return true
18331833
elseif errMsg then
1834-
ConPrintf("Error: '%s'", errMsg)
18351834
launch:ShowErrMsg("^1"..errMsg)
18361835
return true
18371836
elseif dbXML[1].elem ~= "PathOfBuilding" then

src/Modules/BuildList.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function listMode:BuildList()
217217
local fileText = fileHnd:read("*a")
218218
fileHnd:close()
219219
if not fileText then
220-
main:OpenOneDriveErrPopup(build.fullFileName)
220+
main:OpenCloudErrorPopup(build.fullFileName)
221221
return
222222
end
223223
fileText = fileText:match("(<Build.->)")

src/Modules/Main.lua

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ function main:Init()
112112
self.POESESSID = ""
113113
self.showPublicBuilds = true
114114
self.showFlavourText = true
115+
self.errorReadingSettings = false
115116

116117
if not SetDPIScaleOverridePercent then SetDPIScaleOverridePercent = function(scale) end end
117118

@@ -143,8 +144,6 @@ function main:Init()
143144
self.uniqueDB = { list = { }, loading = true }
144145
self.rareDB = { list = { }, loading = true }
145146

146-
self.saveSettingsOnExit = true
147-
148147
local function loadItemDBs()
149148
for type, typeList in pairsYield(data.uniques) do
150149
for _, raw in pairs(typeList) do
@@ -517,14 +516,17 @@ function main:CallMode(func, ...)
517516
end
518517

519518
function main:LoadSettings(ignoreBuild)
519+
if self.errorReadingSettings then
520+
return true
521+
end
520522
local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml")
521523
if errMsg and errMsg:match(".*file returns nil") then
522-
self:OpenOneDriveErrPopup(self.userPath.."Settings.xml")
524+
self.errorReadingSettings = true
525+
self:OpenCloudErrorPopup(self.userPath.."Settings.xml")
523526
return true
524527
elseif errMsg and not errMsg:match(".*No such file or directory") then
525-
ConPrintf("Error: '%s'", errMsg)
528+
self.errorReadingSettings = true
526529
launch:ShowErrMsg("^1"..errMsg)
527-
self.saveSettingsOnExit = false
528530
return true
529531
end
530532
if not setXML then
@@ -661,14 +663,17 @@ function main:LoadSettings(ignoreBuild)
661663
end
662664

663665
function main:LoadSharedItems()
666+
if self.errorReadingSettings then
667+
return true
668+
end
664669
local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml")
665670
if errMsg and errMsg:match(".*file returns nil") then
666-
self:OpenOneDriveErrPopup(self.userPath.."Settings.xml")
671+
self.errorReadingSettings = true
672+
self:OpenCloudErrorPopup(self.userPath.."Settings.xml")
667673
return true
668674
elseif errMsg and not errMsg:match(".*No such file or directory") then
669-
ConPrintf("Error: '%s'", errMsg)
675+
self.errorReadingSettings = true
670676
launch:ShowErrMsg("^1"..errMsg)
671-
self.saveSettingsOnExit = false
672677
return true
673678
end
674679
if not setXML then
@@ -713,7 +718,8 @@ function main:LoadSharedItems()
713718
end
714719

715720
function main:SaveSettings()
716-
if not self.saveSettingsOnExit then
721+
ConPrintf("self.errorReadingSettings: %s", self.errorReadingSettings)
722+
if self.errorReadingSettings then
717723
return
718724
end
719725
local setXML = { elem = "PathOfBuilding" }
@@ -1566,15 +1572,19 @@ function main:OpenNewFolderPopup(path, onClose)
15661572
main:OpenPopup(370, 100, "New Folder", controls, "create", "edit", "cancel")
15671573
end
15681574

1569-
---Shows a OneDrive-specific read error popup with a help button that opens a browser to PoB's GitHub wiki.
1570-
function main:OpenOneDriveErrPopup(fileName)
1571-
ConPrintf("Error: OneDrive: file unreadable: %s", fileName or "?")
1575+
-- Show an error popup if a file cannot be read due to cloud provider unavailability.
1576+
-- Help button opens a URL to PoB's GitHub wiki.
1577+
function main:OpenCloudErrorPopup(fileName)
1578+
local provider, _, status = GetCloudProvider(fileName)
1579+
ConPrintf('Error: file offline "%s" provider: "%s" status: "%s"',
1580+
fileName or "?", provider, status)
15721581
fileName = fileName and "\n\n^8'"..fileName.."'" or ""
1573-
local longVersion = "^8v"..launch.versionNumber..(launch.versionBranch == "dev" and " (Dev)" or launch.versionBranch == "beta" and " (Beta)" or "")
1574-
local title = " Cannot read file "
1575-
local msg = "\nMake sure OneDrive is running then restart "..APP_NAME.." and try again."..fileName.."\n\n"..longVersion
1576-
local url = "https://github.com/PathOfBuildingCommunity/PathOfBuilding/wiki/OneDrive"
1577-
self.saveSettingsOnExit = false
1582+
local pobVersion = "^8v"..launch.versionNumber..(launch.versionBranch == "dev" and " (Dev)" or launch.versionBranch == "beta" and " (Beta)" or "")
1583+
local title = " Error "
1584+
provider = provider or "your cloud provider"
1585+
local msg = "\nCannot read file.\n\nMake sure "..provider.." is running then restart "..APP_NAME.." and try again."..
1586+
fileName.."\n\n"..pobVersion
1587+
local url = "https://github.com/PathOfBuildingCommunity/PathOfBuilding/wiki/CloudError"
15781588
local controls = { }
15791589
local numMsgLines = 0
15801590
for line in string.gmatch(msg .. "\n", "([^\n]*)\n") do

0 commit comments

Comments
 (0)