Skip to content

Commit

Permalink
Removed instance from descriptor generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitribouniol committed Apr 12, 2024
1 parent e7e08be commit fe80499
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Sources/CodableDatastore/Datastore/Datastore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public actor Datastore<Format: DatastoreFormat, AccessMode: _AccessMode> {
// MARK: - Helper Methods

extension Datastore {
// TODO: Remove instance requirement from this method.
func updatedDescriptor(for instance: InstanceType) throws -> DatastoreDescriptor {
func generateUpdatedDescriptor() throws -> DatastoreDescriptor {
if let updatedDescriptor {
return updatedDescriptor
}
Expand Down Expand Up @@ -206,7 +205,7 @@ extension Datastore {
defer { index += 1 }
/// Use the first index to grab an up-to-date descriptor
if newDescriptor == nil {
let updatedDescriptor = try updatedDescriptor(for: instance)
let updatedDescriptor = try generateUpdatedDescriptor()
newDescriptor = updatedDescriptor

/// Check the primary index for compatibility.
Expand Down Expand Up @@ -774,7 +773,7 @@ extension Datastore where AccessMode == ReadWrite {
public func persist(_ instance: InstanceType, to idenfifier: IdentifierType) async throws -> InstanceType? {
try await warmupIfNeeded()

let updatedDescriptor = try self.updatedDescriptor(for: instance)
let updatedDescriptor = try self.generateUpdatedDescriptor()
let versionData = try Data(self.version)
let instanceData = try await self.encoder(instance)

Expand Down

0 comments on commit fe80499

Please sign in to comment.