Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

fix(ocr): clean temp scans on text-only and ungate standalone image ocr

smjrifle0cb5e5629a9b
diff --git a/src/Filee.Engines/Ocr/ImageOcrConverter.cs b/src/Filee.Engines/Ocr/ImageOcrConverter.cs
index 259c1049..5ca18689 100644
--- a/src/Filee.Engines/Ocr/ImageOcrConverter.cs
+++ b/src/Filee.Engines/Ocr/ImageOcrConverter.cs
@@ -40,9 +40,9 @@ public sealed class ImageOcrConverter : IConverter
public async Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken)
{
- if (!step.Preset.Document.Ocr)
- throw new InvalidOperationException("OCR is disabled in preset settings.");
-
+ // Unlike PdfDocumentReader (where OCR is one option among several for an already-readable document),
+ // this converter exists only because OCR is the sole way to get text out of an image: Document.Ocr
+ // (off by default, so an ordinary PDF conversion isn't surprised by OCR) does not gate it.
var language = step.Preset.Document.OcrLanguage;
var engine = OcrEngineRegistry.GetDefault(language);
if (engine is null || !engine.IsAvailable)
diff --git a/src/Filee.Engines/Pdf/PdfDocumentReader.cs b/src/Filee.Engines/Pdf/PdfDocumentReader.cs
index 07337741..e5460307 100644
--- a/src/Filee.Engines/Pdf/PdfDocumentReader.cs
+++ b/src/Filee.Engines/Pdf/PdfDocumentReader.cs
@@ -412,7 +412,9 @@ internal sealed partial class PdfDocumentReader
}
finally
{
- if (isTempScan && words.Count > 0 && File.Exists(scanPath))
+ // Kept only when it's about to become content.ScanPath below (words.Count == 0, !_textOnly);
+ // every other outcome (OCR succeeded, or _textOnly never looks at ScanPath at all) is done with it.
+ if (isTempScan && (words.Count > 0 || _textOnly) && File.Exists(scanPath))
{
try { File.Delete(scanPath); } catch { }
}