forget method

Future<void> forget(
  1. ProjectBundle bundle
)

Deletes every configuration's index of bundle, whose root may no longer exist, such as a removed worktree, with its writer.lock and the directories that leaves empty. Throws index-busy, and deletes nothing, while an operation indexes any of them or a current pointer cannot be removed; a search reading one meanwhile then reports it missing.

A lock file is deleted while it is held (on Windows, which deletes no open file, right after its release), and an operation that opened it just before locks the path again once it has the lock (WayfinderFileLock), so it still excludes the next. A generation a reader on Windows still has open stays, with its lock file, for a later prune or publication to delete.

Implementation

Future<void> forget(ProjectBundle bundle) => _admit(() async {
  final root = await _canonicalPath(bundle.root);
  if (root == null) return;
  final directory = Directory(
    p.join(await _bundlesDirectory(), _rootKey(root)),
  );
  if (!await directory.exists()) return;
  await _forget([directory]);
});