Skip to content

Commit

Permalink
Crash the app if we try to load a file version that is newer than we …
Browse files Browse the repository at this point in the history
…understand
  • Loading branch information
vincode-io committed Oct 27, 2021
1 parent 1f54495 commit 1aa8e5a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Templeton/Sources/Templeton/RowsFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct OutlineRows: Codable {

let allRows: [Row]

if fileVersion == 1 {
switch fileVersion {
case 1:
if let rowOrder = try? container.decode([EntityID].self, forKey: .rowOrder) {
self.rowOrder = rowOrder.map { $0.rowUUID}
} else {
Expand All @@ -43,7 +44,7 @@ struct OutlineRows: Codable {
} else {
allRows = [Row]()
}
} else {
case 2:
if let rowOrder = try? container.decode([String].self, forKey: .rowOrder) {
self.rowOrder = rowOrder
} else {
Expand All @@ -54,8 +55,10 @@ struct OutlineRows: Codable {
} else {
allRows = [Row]()
}
default:
fatalError("Unrecognized Row File Version")
}

self.keyedRows = allRows.reduce([String: Row]()) { result, row in
var mutableResult = result
mutableResult[row.id] = row
Expand Down

0 comments on commit 1aa8e5a

Please sign in to comment.