Show folder names immediately and refresh stale index sizes without walking the whole drive.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 11:21:20 +02:00
parent 6fc7506eb7
commit e2916aef9c
88 changed files with 5373 additions and 544 deletions

View File

@@ -0,0 +1,44 @@
using Explorer.Domain;
namespace Explorer.Application;
public static class BackgroundMaintenancePlanner
{
public static Source? NextLocalScan(
IEnumerable<Source> sources,
DateTimeOffset utc,
IReadOnlySet<long>? alreadyQueued = null)
{
var cutoff = utc - TimeSpan.FromDays(AppConstants.IdleRescanAfterDays);
return EligibleLocal(sources, alreadyQueued)
.Where(source => source.Status == SourceStatus.Stale
|| source.LastIndexedUtc is null
|| source.LastIndexedUtc < cutoff)
.OrderBy(source => source.Status == SourceStatus.Stale ? 0 : 1)
.ThenBy(source => source.LastIndexedUtc ?? DateTimeOffset.MinValue)
.FirstOrDefault();
}
public static Source? NextLocalVerify(
IEnumerable<Source> sources,
IReadOnlySet<long>? alreadyQueued = null)
=> EligibleLocal(sources, alreadyQueued)
.OrderBy(source => source.Status == SourceStatus.Stale ? 0 : 1)
.ThenBy(source => source.LastIndexedUtc ?? DateTimeOffset.MinValue)
.FirstOrDefault();
public static Source? NextHashCollisionSource(
IEnumerable<Source> sources,
IReadOnlySet<long>? alreadyEnqueued = null)
=> EligibleLocal(sources, alreadyEnqueued)
.OrderBy(source => source.LastIndexedUtc ?? DateTimeOffset.MinValue)
.FirstOrDefault();
private static IEnumerable<Source> EligibleLocal(IEnumerable<Source> sources, IReadOnlySet<long>? skip)
=> sources.Where(source =>
source.Kind == SourceKind.NtfsLocal
&& source.IsIndexed
&& source.Status is SourceStatus.Online or SourceStatus.Stale
&& !string.IsNullOrWhiteSpace(source.LastRootPath)
&& (skip is null || !skip.Contains(source.Id)));
}