Skip to content

Commit

Permalink
Guard against scenario when an account has been deactivated and the o…
Browse files Browse the repository at this point in the history
…utline tries to index itself
  • Loading branch information
vincode-io committed Mar 17, 2021
1 parent 8bfe13d commit dc971ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Templeton/Sources/Templeton/Outline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ public final class Outline: RowContainer, OPMLImporter, Identifiable, Equatable,
public func load() {
guard rowsFile == nil else { return }
rowsFile = RowsFile(outline: self)
rowsFile!.load()
rowsFile?.load()
}

public func save() {
Expand Down
7 changes: 5 additions & 2 deletions Templeton/Sources/Templeton/RowsFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ final class RowsFile {
save: { [weak self] in self?.saveCallback() })
private var lastModificationDate: Date?

init(outline: Outline) {
init?(outline: Outline) {
guard let account = outline.account else {
return nil
}
self.outline = outline
let localAccountFolder = AccountManager.shared.accountsFolder.appendingPathComponent(outline.account!.type.folderName)
let localAccountFolder = AccountManager.shared.accountsFolder.appendingPathComponent(account.type.folderName)
fileURL = localAccountFolder.appendingPathComponent("\(outline.id.documentUUID).plist")
}

Expand Down

0 comments on commit dc971ce

Please sign in to comment.