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.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
chore: separate LibreOffice and Ghostscript version probing for dedicated PR
Alenboshcf388bdec143
diff --git a/src/Filee.Engines/Office/LibreOfficeConverter.cs b/src/Filee.Engines/Office/LibreOfficeConverter.csindex 6ef958ad..68aa84d1 100644--- a/src/Filee.Engines/Office/LibreOfficeConverter.cs+++ b/src/Filee.Engines/Office/LibreOfficeConverter.cs@@ -17,8 +17,6 @@// * Its ZIP reader refuses some containers other readers open (Tencent Docs exports, issue #141), saying only "source// file could not be loaded": an Office Open XML / OpenDocument file is tried once more as a repacked copy.-using System.Collections.Concurrent;-using System.Diagnostics;using Filee.Core.Conversion;using Filee.Core.Formats;using Filee.Engines.Infrastructure;@@ -98,50 +96,11 @@ public sealed class LibreOfficeConverter : IConverterreturn _soffice is null? EngineStatus.Unavailable("engine.reason.not_installed"): !EngineEnvironment.UsesFileesCopy("libreoffice")- ? EngineStatus.Available(_soffice, VersionOf(_soffice) + (_hasHwpFilter ? " · H2Orestart" : ""))+ ? EngineStatus.Available(_soffice, _hasHwpFilter ? "H2Orestart" : null): EngineStatus.Available(_soffice, EngineVersions.Component("libreoffice")+ (_hasHwpFilter ? $" · H2Orestart {EngineVersions.Component("h2orestart")}" : ""));}- private static readonly ConcurrentDictionary<string, string> Versions = new();-- private static string VersionOf(string soffice) =>- Versions.GetOrAdd($"{soffice}|{SafeLastWriteTicks(soffice)}", _ =>- {- try- {- using var process = Process.Start(new ProcessStartInfo(soffice, "--version")- {- UseShellExecute = false,- CreateNoWindow = true,- RedirectStandardOutput = true,- RedirectStandardError = true,- });- if (process is null) return "LibreOffice";- if (!process.WaitForExit(3000))- {- process.Kill(entireProcessTree: true);- return "LibreOffice";- }- if (process.ExitCode != 0) return "LibreOffice";- var line = process.StandardOutput.ReadLine()?.Trim();- if (string.IsNullOrWhiteSpace(line)) return "LibreOffice";- return line.StartsWith("LibreOffice", StringComparison.OrdinalIgnoreCase)- ? line- : (char.IsDigit(line[0]) || line.StartsWith('v') || line.StartsWith('V') ? $"LibreOffice {line}" : "LibreOffice");- }- catch- {- return "LibreOffice";- }- });-- private static long SafeLastWriteTicks(string path)- {- try { return File.GetLastWriteTimeUtc(path).Ticks; }- catch { return 0; }- }-public async Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken){var soffice = _soffice ?? throw new InvalidOperationException("LibreOffice was not found.");diff --git a/src/Filee.Engines/Vector/GhostscriptConverter.cs b/src/Filee.Engines/Vector/GhostscriptConverter.csindex 35c8fde8..06f06f5a 100644--- a/src/Filee.Engines/Vector/GhostscriptConverter.cs+++ b/src/Filee.Engines/Vector/GhostscriptConverter.cs@@ -4,8 +4,6 @@// SVG → EPS, …) is planned through PDF or PNG by the route planner. "Compress PDF" may also run a PDF through pdfwrite// (PdfSharpConverter calls CompressPdfAsync; there is no PDF → PDF edge here, so routes don't change).-using System.Collections.Concurrent;-using System.Diagnostics;using Filee.Core.Conversion;using Filee.Core.Presets;using Filee.Engines.Infrastructure;@@ -50,52 +48,10 @@ public sealed class GhostscriptConverter : IConverter, IImageTransformernew("ps", "png"),];- private static readonly ConcurrentDictionary<string, string> Versions = new();-public EngineStatus GetStatus(){_executable = Locate();- return _executable is null- ? EngineStatus.Unavailable("engine.reason.not_installed")- : EngineStatus.Available(_executable, EngineEnvironment.UsesFileesCopy("ghostscript")- ? EngineVersions.Component("ghostscript")- : VersionOf(_executable));- }-- private static string? VersionOf(string gs) =>- Versions.GetOrAdd($"{gs}|{SafeLastWriteTicks(gs)}", _ =>- {- try- {- using var process = Process.Start(new ProcessStartInfo(gs, "--version")- {- UseShellExecute = false,- CreateNoWindow = true,- RedirectStandardOutput = true,- RedirectStandardError = true,- });- if (process is null) return "Ghostscript";- if (!process.WaitForExit(3000))- {- process.Kill(entireProcessTree: true);- return "Ghostscript";- }- if (process.ExitCode != 0) return "Ghostscript";- var line = process.StandardOutput.ReadLine()?.Trim();- return !string.IsNullOrWhiteSpace(line) && (char.IsDigit(line[0]) || line.StartsWith('v') || line.StartsWith('V'))- ? $"Ghostscript {line}"- : "Ghostscript";- }- catch- {- return "Ghostscript";- }- });-- private static long SafeLastWriteTicks(string path)- {- try { return File.GetLastWriteTimeUtc(path).Ticks; }- catch { return 0; }+ return _executable is null ? EngineStatus.Unavailable("engine.reason.not_installed") : EngineStatus.Available(_executable, EngineEnvironment.UsesFileesCopy("ghostscript") ? EngineVersions.Component("ghostscript") : null);}public async Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken)