mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Verifies source’s identifier doesn’t match existing sources when adding
This commit is contained in:
@@ -365,8 +365,12 @@ extension AppManager
|
||||
let action = await UIAlertAction(title: NSLocalizedString("Add Source", comment: ""), style: .default)
|
||||
try await presentingViewController.presentConfirmationAlert(title: title, message: message, primaryAction: action)
|
||||
|
||||
// Wait for fetch to finish before saving context.
|
||||
_ = try await fetchedSource
|
||||
// Wait for fetch to finish before saving context to make
|
||||
// sure there isn't already a source with this identifier.
|
||||
let sourceExists = try await fetchedSource.isAdded
|
||||
|
||||
// This is just a sanity check, so pass nil for previousSourceName to keep code simple.
|
||||
guard !sourceExists else { throw SourceError.duplicate(source, previousSourceName: nil) }
|
||||
|
||||
try await context.performAsync {
|
||||
try context.save()
|
||||
|
||||
Reference in New Issue
Block a user