feat: Add support for thumbnail inclusion in AI processing and enhance UI bindings
Some checks failed
Build Windows Avalonia / build (push) Failing after 1m48s
Build Windows Avalonia / release (push) Has been skipped

This commit is contained in:
MaddoScientisto 2026-05-09 17:53:15 +02:00
commit 7e105e3738
9 changed files with 235 additions and 27 deletions

View file

@ -34,6 +34,7 @@ public class AiExtractionService : IAiExtractionService
|| f.EndsWith(".png", StringComparison.OrdinalIgnoreCase)
|| f.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase)
|| f.EndsWith(".gif", StringComparison.OrdinalIgnoreCase))
.Where(f => request.IncludeThumbnails || !Path.GetFileName(f).StartsWith("tn_", StringComparison.OrdinalIgnoreCase))
.ToList();
var extractedResults = new List<AiResultItem>();
@ -44,6 +45,7 @@ public class AiExtractionService : IAiExtractionService
var processed = 0;
var total = imageFiles.Count;
var failed = 0;
Exception? firstFailure = null;
foreach (var file in imageFiles)
{
@ -58,6 +60,7 @@ public class AiExtractionService : IAiExtractionService
catch (Exception ex)
{
failed++;
firstFailure ??= ex;
_logger.LogWarning(ex, "Error processing AI OCR for {File}", file);
}
@ -72,7 +75,7 @@ public class AiExtractionService : IAiExtractionService
if (imageFiles.Count > 0 && failed == imageFiles.Count)
{
throw new InvalidOperationException($"AI OCR failed for all {imageFiles.Count} image(s). See previous log entries for details.");
throw new InvalidOperationException($"AI OCR failed for all {imageFiles.Count} image(s). See previous log entries for details.", firstFailure);
}
if (!string.IsNullOrWhiteSpace(request.CsvOutputPath))
@ -89,8 +92,9 @@ public class AiExtractionService : IAiExtractionService
sw.WriteLine("Path,Text");
foreach (var r in extractedResults)
{
var csvFileName = Path.GetFileName(r.Path ?? string.Empty);
var safeText = (r.Text ?? string.Empty).Replace("\"", "\"\"");
sw.WriteLine($"\"{r.Path}\",\"{safeText}\"");
sw.WriteLine($"\"{csvFileName}\",\"{safeText}\"");
}
}
catch (Exception ex)