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:
@@ -48,6 +48,51 @@ public sealed class OrganizeDestinations
|
||||
_ => "Unknown"
|
||||
};
|
||||
|
||||
public static bool TryParse(string? value, out FileCategory category)
|
||||
{
|
||||
category = FileCategory.Unknown;
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var key = value.Trim().Replace(" ", "", StringComparison.Ordinal).Replace("_", "", StringComparison.Ordinal);
|
||||
if (Enum.TryParse(key, ignoreCase: true, out category) && category != FileCategory.Unknown)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
category = key.ToLowerInvariant() switch
|
||||
{
|
||||
"photo" or "photos" or "image" or "images" or "picture" or "pictures" => FileCategory.Photos,
|
||||
"video" or "videos" or "movie" or "movies" => FileCategory.Video,
|
||||
"audio" or "music" or "sound" => FileCategory.Audio,
|
||||
"doc" or "docs" or "document" or "documents" => FileCategory.Documents,
|
||||
"code" or "repo" or "repository" or "git" or "development" => FileCategory.CodeRepository,
|
||||
"installer" or "installers" or "setup" => FileCategory.Installer,
|
||||
"backup" or "backups" => FileCategory.Backup,
|
||||
"archive" or "archives" or "zip" => FileCategory.Archive,
|
||||
"system" or "systemdata" => FileCategory.SystemData,
|
||||
"build" or "buildoutput" => FileCategory.BuildOutput,
|
||||
"unknown" => FileCategory.Unknown,
|
||||
_ => (FileCategory)(-1)
|
||||
};
|
||||
return (int)category >= 0;
|
||||
}
|
||||
|
||||
public static readonly FileCategory[] UserChoices =
|
||||
[
|
||||
FileCategory.Photos,
|
||||
FileCategory.Video,
|
||||
FileCategory.Audio,
|
||||
FileCategory.Documents,
|
||||
FileCategory.Installer,
|
||||
FileCategory.Archive,
|
||||
FileCategory.Backup,
|
||||
FileCategory.CodeRepository,
|
||||
FileCategory.Unknown
|
||||
];
|
||||
|
||||
private static string? EmptyToNull(string value)
|
||||
=> string.IsNullOrWhiteSpace(value) ? null : value.Trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user