namespace XFEToolBox.Client.Core.Search; public sealed record FileIndexOptions { private IReadOnlyList? roots; public string CacheDirectory { get; init; } = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "XFEToolBox", "CrossVersion", "FileSearchIndex"); // Explicit test/custom scopes must not probe every drive while options are constructed. // The service resolves the default scope once on its initialization worker. public IReadOnlyList Roots { get => roots ?? GetDefaultRoots(); init => roots = value; } public int MaxParallelism { get; init; } = 2; public TimeSpan ReconciliationInterval { get; init; } = TimeSpan.FromMinutes(15); public TimeSpan WatchDebounce { get; init; } = TimeSpan.FromMilliseconds(250); public TimeSpan CachedVerificationDelay { get; init; } = TimeSpan.FromMinutes(2); /// /// Experimental metadata warmup. Off by default until real-volume benchmarks justify /// the extra MFT pass and hard-link verification. Never requests elevation. /// public bool EnableNtfsWarmup { get; init; } public static IReadOnlyList GetDefaultRoots() { var roots = new List(); var profile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); if (Directory.Exists(profile)) roots.Add(profile); foreach (var drive in DriveInfo.GetDrives()) { try { if (drive.DriveType == DriveType.Fixed && drive.IsReady) roots.Add(drive.RootDirectory.FullName); } catch (Exception exception) when (exception is IOException or UnauthorizedAccessException) { // A disconnected or inaccessible drive does not prevent other drives being searched. } } return roots.Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); } internal static IEnumerable GetPriorityDirectories() { yield return Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); yield return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var profile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); if (!string.IsNullOrEmpty(profile)) yield return Path.Combine(profile, "Downloads"); } } public sealed record FileIndexStatus( bool IsScanning, int IndexedCount, int SkippedDirectories, string? CurrentRoot, DateTimeOffset? LastUpdatedUtc, string? Error) { public bool UsingCachedSnapshot { get; init; } public bool VerificationPending { get; init; } public bool IsReconciling { get; init; } public bool IsNativeWarmup { get; init; } }