Make sure that an account doesn't try persist to the disk in the time that it is logically deleted and when it is actually deallocated

This commit is contained in:
Maurice Parker 2019-05-31 08:05:26 -05:00
parent fec3c69f4a
commit 88b2775076
3 changed files with 7 additions and 4 deletions

View File

@ -61,6 +61,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return defaultName
}()
public var isDeleted = false
public var account: Account? {
return self
}
@ -760,19 +762,19 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
@objc func saveToDiskIfNeeded() {
if dirty {
if dirty && !isDeleted {
saveToDisk()
}
}
@objc func saveFeedMetadataIfNeeded() {
if feedMetadataDirty {
if feedMetadataDirty && !isDeleted {
saveFeedMetadata()
}
}
@objc func saveAccountMetadataIfNeeded() {
if metadataDirty {
if metadataDirty && !isDeleted {
saveAccountMetadata()
}
}

View File

@ -127,6 +127,7 @@ public final class AccountManager: UnreadCountProvider {
}
accountsDictionary.removeValue(forKey: account.accountID)
account.isDeleted = true
do {
try FileManager.default.removeItem(atPath: account.dataFolder)

View File

@ -29,7 +29,7 @@ class AddFeedWindowController : NSWindowController {
private var urlString: String?
private var initialName: String?
private var initialAccount: Account?
private weak var initialAccount: Account?
private var initialFolder: Folder?
private weak var delegate: AddFeedWindowControllerDelegate?
private var folderTreeController: TreeController!