resolveDirMountFilter function

Future<PathFilter?> resolveDirMountFilter({
  1. required String localDir,
  2. PathFilter? explicit,
  3. String? ignoreFileName,
})

Resolves the effective PathFilter for a directory mount, mirroring omnydrive publish's .omnyignore handling.

When explicit is non-null (the caller passed --include/--exclude, or a derived whitelist) it wins unchanged — explicit filters override the ignore file entirely. Otherwise the ignore file named ignoreFileName (default omnyIgnoreFileName) is read from localDir and, if it yields any patterns, returned as the drive's default exclude set. A missing/empty file yields null (no filter), so the whole tree is published as before.

The resolved filter is computed once at the call site and passed to both the mount-reuse lookup and DriveManager.mountDirectory, so reuse matching and the persisted record agree (see DriveManager.findReusableDirMount).

Implementation

Future<PathFilter?> resolveDirMountFilter({
  required String localDir,
  PathFilter? explicit,
  String? ignoreFileName,
}) async {
  if (explicit != null) return explicit;
  final patterns = await loadOmnyIgnore(
    localDir,
    fileName: ignoreFileName ?? omnyIgnoreFileName,
  );
  if (patterns.isEmpty) return null;
  return PathFilter(exclude: patterns);
}