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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user