Skip to content

Commit e4d8f32

Browse files
Updated current snapshot accessors to be less ambiguous
1 parent c11c9f4 commit e4d8f32

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/CodableDatastore/Persistence/Disk Persistence/DiskPersistence.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ extension DiskPersistence {
327327
/// - Parameter dateUpdate: The method to which to update the date of the main store with.
328328
/// - Parameter updater: An updater that takes a reference to the current ``Snapshot``, and will forward the returned value to the caller.
329329
/// - Returns: The value returned from the `accessor`.
330-
func withCurrentSnapshot<T>(
330+
func updatingCurrentSnapshot<T>(
331331
dateUpdate: ModificationUpdate = .updateOnWrite,
332332
updater: @escaping (_ snapshot: Snapshot<AccessMode>) async throws -> T
333333
) async throws -> T where AccessMode == ReadWrite {
@@ -343,7 +343,7 @@ extension DiskPersistence {
343343
/// - Parameter accessor: An accessor that takes a reference to the current ``Snapshot``, and will forward the returned value to the caller.
344344
/// - Returns: The value returned from the `accessor`.
345345
@_disfavoredOverload
346-
func withCurrentSnapshot<T>(
346+
func readingCurrentSnapshot<T>(
347347
accessor: @escaping (_ snapshot: Snapshot<AccessMode>) async throws -> T
348348
) async throws -> T {
349349
try await updateCurrentSnapshot(accessor: accessor).value
@@ -418,7 +418,7 @@ extension DiskPersistence {
418418
throw DatastoreInterfaceError.datastoreNotFound
419419
}
420420
if let self = self as? DiskPersistence<ReadWrite> {
421-
let (datastore, rootID) = try await self.withCurrentSnapshot { snapshot in
421+
let (datastore, rootID) = try await self.updatingCurrentSnapshot { snapshot in
422422
try await snapshot.updatingManifest { snapshotManifest, currentIteration in
423423
let (datastore, root) = await snapshot.loadDatastore(for: datastoreKey, from: currentIteration)
424424
currentIteration.dataStores[datastoreKey.rawValue] = .init(key: datastoreKey, id: datastore.id, root: root)
@@ -427,7 +427,7 @@ extension DiskPersistence {
427427
}
428428
return (datastore as! DiskPersistence<AccessMode>.Datastore, rootID)
429429
} else {
430-
return try await withCurrentSnapshot { snapshot in
430+
return try await readingCurrentSnapshot { snapshot in
431431
try await snapshot.readingManifest { snapshotManifest, currentIteration in
432432
await snapshot.loadDatastore(for: datastoreKey, from: currentIteration)
433433
}
@@ -466,7 +466,7 @@ extension DiskPersistence {
466466
addedDatastoreRoots: Set<DatastoreRootIdentifier>,
467467
removedDatastoreRoots: Set<DatastoreRootIdentifier>
468468
) async throws {
469-
let containsEdits = try await withCurrentSnapshot { snapshot in
469+
let containsEdits = try await readingCurrentSnapshot { snapshot in
470470
try await snapshot.readingManifest { manifest, iteration in
471471
for (key, root) in roots {
472472
guard iteration.dataStores[key.rawValue]?.root == root.id
@@ -484,7 +484,7 @@ extension DiskPersistence {
484484
else { throw DiskPersistenceError.cannotWrite }
485485

486486
/// If we are read-write, apply the updated root objects to the snapshot.
487-
try await self.withCurrentSnapshot { snapshot in
487+
try await self.updatingCurrentSnapshot { snapshot in
488488
try await snapshot.updatingManifest { manifest, iteration in
489489
iteration.actionName = actionName
490490
iteration.addedDatastoreRoots = addedDatastoreRoots

0 commit comments

Comments
 (0)