Persist file categories on the index and classify archives and unknown types during idle maintenance.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-28 11:37:29 +02:00
parent b33a78dbbe
commit 222b5d9969
42 changed files with 1719 additions and 80 deletions

View File

@@ -132,6 +132,40 @@ public class ReorganizePlannerTests
Assert.Null(fs.GetItem(@"C:\Pictures\photo.jpg"));
}
[Fact]
public void Prefers_indexed_archive_contents_over_extension()
{
var fs = Tree()
.Dir(@"C:\Downloads")
.File(@"C:\Downloads\photos.zip", 4, T0)
.Dir(@"C:\Pictures")
.Dir(@"C:\Archive");
var indexed = new Dictionary<string, IndexEntry>(StringComparer.OrdinalIgnoreCase)
{
["photos.zip"] = new IndexEntry
{
Name = "photos.zip",
NameNorm = "photos.zip",
PathRel = "photos.zip",
Category = FileCategory.Photos,
CategorySource = CategorySources.ArchiveContents,
CategoryReason = "Archive contents are mostly photos."
}
};
var plan = new ReorganizePlanner().Build(
@"C:\Downloads",
Map(),
fs,
_ => true,
_ => false,
now: T0,
pathExists: _ => false,
indexedByName: indexed);
Assert.Contains(plan.Operations, o => o.SourcePath.EndsWith("photos.zip") && o.DestinationPath == @"C:\Pictures\photos.zip");
Assert.DoesNotContain(plan.Operations, o => o.DestinationPath == @"C:\Archive\photos.zip");
}
private static OperationPlan Build(
IFileSystemEnumerator fs,
Action<OrganizeDestinations>? configure = null,