Fail when trying to add a feed that isn't parsable. Fixes #2921
This commit is contained in:
parent
c35dabbc55
commit
022e4ae153
|
@ -668,7 +668,6 @@ private extension CloudKitAccountDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createRSSWebFeed(for account: Account, url: URL, editedName: String?, container: Container, completion: @escaping (Result<WebFeed, Error>) -> Void) {
|
func createRSSWebFeed(for account: Account, url: URL, editedName: String?, container: Container, completion: @escaping (Result<WebFeed, Error>) -> Void) {
|
||||||
BatchUpdate.shared.start()
|
|
||||||
refreshProgress.addToNumberOfTasksAndRemaining(5)
|
refreshProgress.addToNumberOfTasksAndRemaining(5)
|
||||||
FeedFinder.find(url: url) { result in
|
FeedFinder.find(url: url) { result in
|
||||||
|
|
||||||
|
@ -676,14 +675,12 @@ private extension CloudKitAccountDelegate {
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let feedSpecifiers):
|
case .success(let feedSpecifiers):
|
||||||
guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers), let url = URL(string: bestFeedSpecifier.urlString) else {
|
guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers), let url = URL(string: bestFeedSpecifier.urlString) else {
|
||||||
BatchUpdate.shared.end()
|
|
||||||
self.refreshProgress.completeTasks(4)
|
self.refreshProgress.completeTasks(4)
|
||||||
completion(.failure(AccountError.createErrorNotFound))
|
completion(.failure(AccountError.createErrorNotFound))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if account.hasWebFeed(withURL: bestFeedSpecifier.urlString) {
|
if account.hasWebFeed(withURL: bestFeedSpecifier.urlString) {
|
||||||
BatchUpdate.shared.end()
|
|
||||||
self.refreshProgress.completeTasks(4)
|
self.refreshProgress.completeTasks(4)
|
||||||
completion(.failure(AccountError.createErrorAlreadySubscribed))
|
completion(.failure(AccountError.createErrorAlreadySubscribed))
|
||||||
return
|
return
|
||||||
|
@ -700,7 +697,6 @@ private extension CloudKitAccountDelegate {
|
||||||
account.update(feed, with: parsedFeed) { result in
|
account.update(feed, with: parsedFeed) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
BatchUpdate.shared.end()
|
|
||||||
|
|
||||||
self.accountZone.createWebFeed(url: bestFeedSpecifier.urlString,
|
self.accountZone.createWebFeed(url: bestFeedSpecifier.urlString,
|
||||||
name: parsedFeed.title,
|
name: parsedFeed.title,
|
||||||
|
@ -724,21 +720,21 @@ private extension CloudKitAccountDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
BatchUpdate.shared.end()
|
container.removeWebFeed(feed)
|
||||||
self.refreshProgress.completeTasks(3)
|
self.refreshProgress.completeTasks(3)
|
||||||
completion(.failure(error))
|
completion(.failure(error))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.refreshProgress.completeTasks(4)
|
container.removeWebFeed(feed)
|
||||||
completion(.success(feed))
|
self.refreshProgress.completeTasks(3)
|
||||||
|
completion(.failure(AccountError.createErrorNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case .failure:
|
case .failure:
|
||||||
BatchUpdate.shared.end()
|
|
||||||
self.refreshProgress.completeTasks(4)
|
self.refreshProgress.completeTasks(4)
|
||||||
completion(.failure(AccountError.createErrorNotFound))
|
completion(.failure(AccountError.createErrorNotFound))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue