Fix CoreData concurrency things
This commit is contained in:
parent
dd71c06257
commit
61f073109c
|
@ -0,0 +1,104 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1320"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D6C687E7272CD27600874C10"
|
||||||
|
BuildableName = "Reader.app"
|
||||||
|
BlueprintName = "Reader"
|
||||||
|
ReferencedContainer = "container:Reader.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D6C68800272CD27700874C10"
|
||||||
|
BuildableName = "ReaderTests.xctest"
|
||||||
|
BlueprintName = "ReaderTests"
|
||||||
|
ReferencedContainer = "container:Reader.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D6C6880A272CD27700874C10"
|
||||||
|
BuildableName = "ReaderUITests.xctest"
|
||||||
|
BlueprintName = "ReaderUITests"
|
||||||
|
ReferencedContainer = "container:Reader.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D6C687E7272CD27600874C10"
|
||||||
|
BuildableName = "Reader.app"
|
||||||
|
BlueprintName = "Reader"
|
||||||
|
ReferencedContainer = "container:Reader.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<CommandLineArguments>
|
||||||
|
<CommandLineArgument
|
||||||
|
argument = "-com.apple.CoreData.ConcurrencyDebug 1"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</CommandLineArgument>
|
||||||
|
</CommandLineArguments>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D6C687E7272CD27600874C10"
|
||||||
|
BuildableName = "Reader.app"
|
||||||
|
BlueprintName = "Reader"
|
||||||
|
ReferencedContainer = "container:Reader.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
|
@ -39,6 +39,13 @@ class PersistentContainer: NSPersistentContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
private func saveViewContext() async throws {
|
||||||
|
if viewContext.hasChanges {
|
||||||
|
try viewContext.save()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func lastSyncDate() async throws -> Date? {
|
func lastSyncDate() async throws -> Date? {
|
||||||
return try await backgroundContext.perform {
|
return try await backgroundContext.perform {
|
||||||
let state = try self.backgroundContext.fetch(SyncState.fetchRequest()).first
|
let state = try self.backgroundContext.fetch(SyncState.fetchRequest()).first
|
||||||
|
@ -56,8 +63,8 @@ class PersistentContainer: NSPersistentContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
try self.backgroundContext.save()
|
try self.backgroundContext.save()
|
||||||
try self.viewContext.save()
|
|
||||||
}
|
}
|
||||||
|
try await self.saveViewContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
func sync(serverGroups: [Fervor.Group], serverFeeds: [Fervor.Feed]) async throws {
|
func sync(serverGroups: [Fervor.Group], serverFeeds: [Fervor.Feed]) async throws {
|
||||||
|
@ -87,9 +94,9 @@ class PersistentContainer: NSPersistentContainer {
|
||||||
|
|
||||||
if self.backgroundContext.hasChanges {
|
if self.backgroundContext.hasChanges {
|
||||||
try self.backgroundContext.save()
|
try self.backgroundContext.save()
|
||||||
try self.viewContext.save()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try await self.saveViewContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
func syncItems(_ syncUpdate: ItemsSyncUpdate) async throws {
|
func syncItems(_ syncUpdate: ItemsSyncUpdate) async throws {
|
||||||
|
@ -123,9 +130,9 @@ class PersistentContainer: NSPersistentContainer {
|
||||||
|
|
||||||
if self.backgroundContext.hasChanges {
|
if self.backgroundContext.hasChanges {
|
||||||
try self.backgroundContext.save()
|
try self.backgroundContext.save()
|
||||||
try self.viewContext.save()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try await self.saveViewContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue