You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// let rootObject = trackedRootObjects[identifier]?.value ?? RootObject(datastore: self, id: identifier, rootObject: rootObjectManifest) // TODO: Investigate why this is commented out
163
+
164
+
/// Collect the indexes and related manifests we'll be deleting.
165
+
/// - For indexes, only collect the ones we'll be deleting since the ones we are keeping won't be making references to other deletable assets.
166
+
/// - For the manifests, we'll be deleting the entries that are being removed (relative to the direction we are removing from, so the removed ones from the oldest edge, and the added ones from the newest edge, as determined by the caller), while we'll be checking for pages to remove from entries that have just been added, but only when removing from the oldest edge. We only do this for the oldest edge because pages that have been "removed" from the newest edge are actually being _restored_ and not replaced, which maintains symmetry in a non-obvious way.
/// Enforce the retention policy on the persistence immediately.
572
+
///
573
+
/// - Note: Transaction retention policies are enforced after ever write transaction, so calling this method directly is often unecessary. However, it can be useful if the user requires disk resources immediately.
574
+
publicfunc enforceRetentionPolicy()async{
575
+
// TODO: Don't create any snapshots if they don't exist yet
576
+
letinfo=try?awaitself.readingCurrentSnapshot{ snapshot in
577
+
tryawait snapshot.readingManifest{ manifest, iteration in
/// Update the next snapshot iteration we should be checking, and cancel the existing task so we can move on to checking this iteration.
597
+
snapshotIterationPruningTask.cancel()
598
+
return
599
+
}
600
+
601
+
/// Update the next snapshot iteration we should be checking, and enqueue a task since we know one isn't currently running.
602
+
checkNextSnapshotIterationCandidateForPruning()
603
+
}
604
+
605
+
/// Private method to check the next candidate for pruning.
606
+
///
607
+
/// First, this method walks down the linked list defining the iteration chain, from newest to oldest, and collects the iterations that should be pruned. Then, it iterates that list in reverse (from oldest to newest) actually removing the iterations as they are encountered.
608
+
/// - Note: This method should only ever be called when it is known that no `snapshotIterationPruningTask` is ongoing (it is nil), or when one just finishes.
/// Walk the successor candidates all the way back up so newer iterations are pruned before the ones that reference them. We pull items off from the end, and add new ones to the beginning to make sure they stay in graph order.
/// Await any cleanup since the last complete write transaction to the persistence.
690
+
///
691
+
/// - Note: An application is not required to await cleanup, as it'll be eventually completed on future runs. It is however useful in cases when disk resources must be cleared before progressing to another step.
0 commit comments