fix: allocate playthrough identity only on demand

This commit is contained in:
MaxTomahawk
2026-08-07 15:01:18 +02:00
parent 6e94625f2a
commit 49954ec4ad
6 changed files with 80 additions and 39 deletions
+9 -2
View File
@@ -57,11 +57,18 @@ function Storage:_scope(game)
local save = game and game.save
local meta = save and save.meta
local version = save and save.version
local playthroughId = meta and meta.playthroughId
if not (save and validSegment(version) and validSegment(playthroughId)) then
if not (save and validSegment(version)) then
return failure("not_in_playthrough",
"Storage is available only inside an identified playthrough.")
end
local playthroughId = meta and meta.playthroughId
if not validSegment(playthroughId) then
playthroughId = SaveData.ensurePlaythroughId(save, self.injectedFs)
end
if not validSegment(playthroughId) then
return failure("not_in_playthrough",
"Storage could not identify the active playthrough.")
end
local fs = SaveData.persistenceFs(self.injectedFs)
if not (fs and fs.read and fs.write and fs.getInfo) then
return failure("storage_unavailable", "The persistence backend is unavailable.")