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
Recent conversions list failed files with the reason, and Retry converts them again
KnifeLemon83d2243290a2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8425f664..5b041c5a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,22 @@ version it publishes under "What's Changed" in the GitHub release notes, above tAdd a `## <version>` section before tagging a release. Write what someone using Filee notices: what's new, where tofind it, what it does and doesn't do.+## 1.8.0++### New++- **Failed files at a glance, and a retry.** When files of a conversion fail, Recent conversions on the Home page+ lists them with the reason (click "2 failed" to open the list; names and reasons can be selected and copied).+ **Retry** converts the files that failed again with the same settings and save location, even after the preset+ was changed or deleted. Files that are no longer there are left out. The progress card that pops up after a+ conversion has the same **Retry** button. Conversions from watch folders are listed and retried the same way;+ a retried file stays in the watched folder, also when the folder moves originals to "originals".++### Documentation++- docs/ENGINES.md said Filee never uses engines installed on the computer. It does, as the last choice after a copy+ you picked and Filee's own: that is how FFmpeg and Ghostscript are found on macOS. The order is now described.+## 1.7.2### Fixesdiff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex 1ce57b39..6c5308f8 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -37,9 +37,19 @@ All built-in document readers are registered in one place, `Hwp/Hwpx/DocumentReawhich formats need Pandoc). The HWPX writer and the DOCX writer take their input formats from it: adding a readerthere is one line and makes both writers (and every route through them) accept the format.-Filee never uses software installed on the system (Microsoft Office, an installed LibreOffice, programs on `PATH`):-every engine is built in, bundled or downloaded into Filee's own folder, so a conversion behaves the same on every-PC. Running from source, the repository's `engines/` folder (filled by `build/fetch-engines.ps1`) is used.+Every engine is built in, bundled with the installer or downloaded into Filee's own folder, so a conversion behaves+the same on every PC. An external engine is looked for in this order:++1. a copy the user picked in Settings → *Engines*;+2. Filee's own copy (bundled or downloaded);+3. a copy already on the computer: on `PATH`, in Homebrew's and the usual Unix folders, or where the LibreOffice,+ calibre and Ghostscript installers put it. Settings → *Engines* shows it as "Found on this PC", with a note when+ its version is older than the one Filee downloads.++Where Filee has no download of an engine (FFmpeg and Ghostscript on macOS, LibreOffice and Ghostscript on Linux),+step 3 is how it is found. Microsoft Office+and Hancom Office are never used, even when installed. Running from source, the repository's `engines/` folder+(filled by `build/fetch-engines.ps1`) is used.## Optional enginesdiff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 18e834f8..d133badd 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -30,6 +30,7 @@"home.open_folder": "Open folder","home.clear_history": "Clear","home.files": "{0} files",+ "home.failed_files": "{0} failed","donut.center_drag": "Bring files here","donut.files_same": "{0} × {1}",@@ -428,6 +429,7 @@"about.title": "About","about.updates": "Updates","common.search": "Search",+ "common.retry": "Retry","about.version": "Version {0}","about.license": "Filee is free software under the MIT license.","about.notices": "Third-party notices",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 54ba5f1f..9c475d69 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -30,6 +30,7 @@"home.open_folder": "폴더 열기","home.clear_history": "지우기","home.files": "파일 {0}개",+ "home.failed_files": "{0}개 실패","donut.center_drag": "파일을 이쪽으로","donut.files_same": "{1} {0}개",@@ -428,6 +429,7 @@"about.title": "정보","about.updates": "업데이트","common.search": "검색",+ "common.retry": "다시 시도","about.version": "버전 {0}","about.license": "Filee는 MIT 라이선스의 무료 소프트웨어예요.","about.notices": "서드파티 고지",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex eb3125f5..a5d07a0b 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -30,6 +30,7 @@"home.open_folder": "打开文件夹","home.clear_history": "清除","home.files": "{0} 个文件",+ "home.failed_files": "{0} 个失败","donut.center_drag": "把文件拖到这里","donut.files_same": "{0} 个 {1}",@@ -428,6 +429,7 @@"about.title": "关于","about.updates": "更新","common.search": "搜索",+ "common.retry": "重试","about.version": "版本 {0}","about.license": "Filee 是基于 MIT 许可证的免费软件。","about.notices": "第三方声明",diff --git a/src/Filee.App/Services/ConversionService.cs b/src/Filee.App/Services/ConversionService.csindex 51be5f72..328715c1 100644--- a/src/Filee.App/Services/ConversionService.cs+++ b/src/Filee.App/Services/ConversionService.cs@@ -63,7 +63,7 @@ public sealed class ConversionService// A preset on "Default" saves where Settings > General says (read now, so a changed default applies at once).preset = _store.Settings.WithDefaultOutput(preset);var job = _queue.Enqueue(files, preset, _loc.DisplayName(preset));- var vm = new JobViewModel(job, _loc, _platform, Remove);+ var vm = new JobViewModel(job, _loc, _platform, Remove, RetryFailed);_byId[job.Id] = vm;Jobs.Insert(0, vm);if (showInToast)@@ -71,6 +71,23 @@ public sealed class ConversionServicereturn vm;}+ /// <summary>+ /// Converts files that failed again with the preset their job ran with (shown in the toast). Files that are no+ /// longer there are left out.+ /// </summary>+ /// <returns>The new job, or null when none of the files is left.</returns>+ public JobViewModel? Retry(IEnumerable<string> sources, Preset preset) =>+ Start(sources.Where(Exists).Distinct(StringComparer.Ordinal).ToList(), preset);++ /// <summary>True when a source file (or folder) is still where it was.</summary>+ public static bool Exists(string path) => File.Exists(path) || Directory.Exists(path);++ private void RetryFailed(JobViewModel vm)+ {+ Remove(vm);+ Retry(vm.FailedSources, vm.Job.Preset);+ }+/// <summary>/// Converts like <see cref="Start"/> (shown in the toast and history) and completes when the job has finished./// Callable from any thread; used by watch folders.diff --git a/src/Filee.App/ViewModels/FailureText.cs b/src/Filee.App/ViewModels/FailureText.csnew file mode 100644index 00000000..0c1ab2a2--- /dev/null+++ b/src/Filee.App/ViewModels/FailureText.cs@@ -0,0 +1,33 @@+// How a file that failed to convert is described in the toast and in Recent conversions.++using Filee.Core.Localization;++namespace Filee.App.ViewModels;++/// <summary>A failed file as listed: its name and the reason.</summary>+public sealed record FailureItem(string Name, string Reason);++internal static class FailureText+{+ /// <summary>"Conversion failed (detail)" in the current language.</summary>+ public static string Reason(ILocalizer loc, string? key, string? detail) =>+ loc[key ?? "error.conversion_failed"] + (string.IsNullOrWhiteSpace(detail) ? "" : $" ({detail})");++ /// <summary>+ /// Reads a "file: error.key detail" line as Filee 1.7 and earlier saved it in the history.+ /// </summary>+ public static FailureItem FromLegacy(ILocalizer loc, string line)+ {+ var colon = line.IndexOf(": ", StringComparison.Ordinal);+ if (colon < 0)+ return new FailureItem(line, Reason(loc, null, null));+ var name = line[..colon];+ var rest = line[(colon + 2)..].Trim();+ if (!rest.StartsWith("error.", StringComparison.Ordinal))+ return new FailureItem(name, Reason(loc, null, rest));+ var space = rest.IndexOf(' ');+ return space < 0+ ? new FailureItem(name, Reason(loc, rest, null))+ : new FailureItem(name, Reason(loc, rest[..space], rest[(space + 1)..]));+ }+}diff --git a/src/Filee.App/ViewModels/JobViewModel.cs b/src/Filee.App/ViewModels/JobViewModel.csindex 0e5867f9..3044df29 100644--- a/src/Filee.App/ViewModels/JobViewModel.cs+++ b/src/Filee.App/ViewModels/JobViewModel.cs@@ -13,14 +13,17 @@ public sealed partial class JobViewModel : ObservableObjectprivate readonly ILocalizer _loc;private readonly IPlatformServices _platform;private readonly Action<JobViewModel> _dismiss;+ private readonly Action<JobViewModel>? _retry;private int _refreshPending;- public JobViewModel(ConversionJob job, ILocalizer loc, IPlatformServices platform, Action<JobViewModel> dismiss)+ public JobViewModel(ConversionJob job, ILocalizer loc, IPlatformServices platform, Action<JobViewModel> dismiss,+ Action<JobViewModel>? retry = null){Job = job;_loc = loc;_platform = platform;_dismiss = dismiss;+ _retry = retry;var what = job.Sources.Count == 1 ? Path.GetFileName(job.Sources[0]) : loc.Format("home.files", job.Sources.Count);Title = loc.Format("toast.converting", what, job.PresetDisplayName);Refresh();@@ -36,6 +39,10 @@ public sealed partial class JobViewModel : ObservableObject[ObservableProperty] private bool _hasErrors;[ObservableProperty] private bool _hasOutputs;[ObservableProperty] private string? _errorDetails;+ [ObservableProperty] private bool _canRetry;++ /// <summary>Source files that failed.</summary>+ public IEnumerable<string> FailedSources => Job.Files.Where(f => f.State == FileState.Failed).Select(f => f.SourcePath);/// <summary>Marks a refresh as pending; returns false if one is already queued (coalesces UI updates).</summary>internal bool TryMarkPending() => Interlocked.Exchange(ref _refreshPending, 1) == 0;@@ -51,7 +58,8 @@ public sealed partial class JobViewModel : ObservableObjectvar failed = Job.Files.Where(f => f.State == FileState.Failed).ToList();HasErrors = failed.Count > 0;ErrorDetails = failed.Count == 0 ? null : string.Join(Environment.NewLine,- failed.Select(f => $"{Path.GetFileName(f.SourcePath)} — {_loc[f.ErrorKey ?? "error.conversion_failed"]}{(f.ErrorDetail is null ? "" : $" ({f.ErrorDetail})")}"));+ failed.Select(f => $"{Path.GetFileName(f.SourcePath)} — {FailureText.Reason(_loc, f.ErrorKey, f.ErrorDetail)}"));+ CanRetry = _retry is not null && !IsRunning && failed.Count > 0;Status = Job.State switch{@@ -77,4 +85,8 @@ public sealed partial class JobViewModel : ObservableObject[RelayCommand]private void Dismiss() => _dismiss(this);++ /// <summary>Converts the files that failed again (a new job in the toast in place of this one).</summary>+ [RelayCommand]+ private void Retry() => _retry?.Invoke(this);}diff --git a/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs b/src/Filee.App/ViewModels/Pages/HomePageViewModel.csindex 9384c8af..e1308ffc 100644--- a/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs+++ b/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs@@ -13,33 +13,67 @@ using Filee.Core.Settings;namespace Filee.App.ViewModels.Pages;-public sealed partial class HistoryItemViewModel(HistoryEntry entry, ILocalizer loc, IPlatformServices platform) : ObservableObject+public sealed partial class HistoryItemViewModel : ObservableObject{- public string Title { get; } = entry.PresetName;+ private readonly HistoryEntry _entry;+ private readonly IPlatformServices _platform;+ private readonly ConversionService? _conversions;++ public HistoryItemViewModel(HistoryEntry entry, ILocalizer loc, IPlatformServices platform, ConversionService? conversions = null)+ {+ _entry = entry;+ _platform = platform;+ _conversions = conversions;+ Title = entry.PresetName;+ Subtitle = entry.Sources.Count == 1 ? Path.GetFileName(entry.Sources[0]) : loc.Format("home.files", entry.Sources.Count);+ Time = entry.FinishedAt.Date == DateTime.Today ? entry.FinishedAt.ToString("t") : entry.FinishedAt.ToString("d");+ Failures = entry.Failures.Count > 0+ ? entry.Failures.Select(f => new FailureItem(Path.GetFileName(f.Source), FailureText.Reason(loc, f.ErrorKey, f.ErrorDetail))).ToList()+ : entry.Errors.Select(line => FailureText.FromLegacy(loc, line)).ToList();+ HasErrors = Failures.Count > 0 || entry.State == JobState.Failed;+ FailureSummary = loc.Format("home.failed_files", Failures.Count);+ HasOutputs = entry.Outputs.Any(ConversionService.Exists);+ // Only entries that remember their preset (Filee 1.8 and later) and still have a failed file to convert.+ CanRetry = conversions is not null && entry.Preset is not null && entry.Failures.Any(f => ConversionService.Exists(f.Source));+ }++ public string Title { get; }+ public string Subtitle { get; }+ public string Time { get; }+ public bool HasErrors { get; }+ public bool HasOutputs { get; }++ /// <summary>The files that failed and why.</summary>+ public IReadOnlyList<FailureItem> Failures { get; }++ public bool HasFailures => Failures.Count > 0;- public string Subtitle { get; } = entry.Sources.Count == 1- ? Path.GetFileName(entry.Sources[0])- : loc.Format("home.files", entry.Sources.Count);+ /// <summary>"2 files failed": the button that shows the list.</summary>+ public string FailureSummary { get; }- public string Time { get; } = entry.FinishedAt.Date == DateTime.Today- ? entry.FinishedAt.ToString("t")- : entry.FinishedAt.ToString("d");+ public bool CanRetry { get; }- public bool Succeeded { get; } = entry.State == JobState.Completed;- public bool HasErrors { get; } = entry.Errors.Count > 0 || entry.State == JobState.Failed;- public string? Errors { get; } = entry.Errors.Count == 0 ? null : string.Join(Environment.NewLine, entry.Errors);- public bool HasOutputs { get; } = entry.Outputs.Any(Exists);+ [ObservableProperty] private bool _showFailures;++ [RelayCommand]+ private void ToggleFailures() => ShowFailures = !ShowFailures;++ /// <summary>Converts the failed files again the way the job ran them; progress shows in the toast.</summary>+ [RelayCommand]+ private void Retry()+ {+ if (_conversions is not null && _entry.Preset is not null)+ _conversions.Retry(_entry.Failures.Select(f => f.Source), _entry.Preset);+ }[RelayCommand]private void OpenFolder(){// An output may be a folder ("Extract"): revealing it opens the extracted files.- var output = entry.Outputs.FirstOrDefault(Exists);+ var output = _entry.Outputs.FirstOrDefault(ConversionService.Exists);if (output is not null)- platform.RevealInFileManager(output);+ _platform.RevealInFileManager(output);}-- private static bool Exists(string path) => File.Exists(path) || Directory.Exists(path);}public sealed partial class HomePageViewModel : ObservableObject, IDisposable@@ -48,13 +82,16 @@ public sealed partial class HomePageViewModel : ObservableObject, IDisposableprivate readonly ILocalizer _loc;private readonly IPlatformServices _platform;private readonly Services.Triggers.TriggerService? _triggers;+ private readonly ConversionService? _conversions;- public HomePageViewModel(UserDataStore store, ILocalizer loc, IPlatformServices platform, Services.Triggers.TriggerService? triggers = null)+ public HomePageViewModel(UserDataStore store, ILocalizer loc, IPlatformServices platform, Services.Triggers.TriggerService? triggers = null,+ ConversionService? conversions = null){_store = store;_loc = loc;_platform = platform;_triggers = triggers;+ _conversions = conversions;if (triggers is not null)triggers.StatusChanged += OnTriggerStatusChanged;var drag = store.Settings.Triggers.FirstOrDefault(t => t.Enabled && t.Kind == TriggerKind.Drag);@@ -94,7 +131,7 @@ public sealed partial class HomePageViewModel : ObservableObject, IDisposable{History.Clear();foreach (var entry in _store.History.Take(40))- History.Add(new HistoryItemViewModel(entry, _loc, _platform));+ History.Add(new HistoryItemViewModel(entry, _loc, _platform, _conversions));IsEmpty = History.Count == 0;}diff --git a/src/Filee.App/Views/Pages/HomePage.axaml b/src/Filee.App/Views/Pages/HomePage.axamlindex c4d1acb7..4eab3558 100644--- a/src/Filee.App/Views/Pages/HomePage.axaml+++ b/src/Filee.App/Views/Pages/HomePage.axaml@@ -1,6 +1,7 @@<UserControl xmlns="https://github.com/avaloniaui"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:vm="using:Filee.App.ViewModels.Pages"+ xmlns:app="using:Filee.App.ViewModels"x:Class="Filee.App.Views.Pages.HomePage"x:DataType="vm:HomePageViewModel"><UserControl.Styles>@@ -17,6 +18,12 @@<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" /><Setter Property="RenderTransform" Value="scale(1.015)" /></Style>+ <Style Selector="PathIcon.chevron">+ <Setter Property="RenderTransform" Value="rotate(0deg)" />+ </Style>+ <Style Selector="PathIcon.chevron.open">+ <Setter Property="RenderTransform" Value="rotate(90deg)" />+ </Style></UserControl.Styles><StackPanel Spacing="22">@@ -62,29 +69,63 @@<ItemsControl.ItemTemplate><DataTemplate x:DataType="vm:HistoryItemViewModel"><Border Classes="card" Padding="14,10">- <DockPanel>- <Button DockPanel.Dock="Right" Command="{Binding OpenFolderCommand}" IsVisible="{Binding HasOutputs}" Padding="10,5">- <StackPanel Orientation="Horizontal" Spacing="6">- <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Folder}" />- <TextBlock Text="{DynamicResource home.open_folder}" />+ <StackPanel Spacing="8">+ <DockPanel>+ <Button DockPanel.Dock="Right" Command="{Binding OpenFolderCommand}" IsVisible="{Binding HasOutputs}" Padding="10,5">+ <StackPanel Orientation="Horizontal" Spacing="6">+ <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Folder}" />+ <TextBlock Text="{DynamicResource home.open_folder}" />+ </StackPanel>+ </Button>+ <Border DockPanel.Dock="Left" Width="32" Height="32" CornerRadius="999" Margin="0,0,12,0"+ Background="{DynamicResource AccentSoftBrush}">+ <Panel>+ <PathIcon Width="15" Height="15" Data="{StaticResource Icon.Check}" Foreground="{DynamicResource AccentStrongBrush}" IsVisible="{Binding !HasErrors}" />+ <PathIcon Width="15" Height="15" Data="{StaticResource Icon.Alert}" Foreground="{DynamicResource DangerBrush}" IsVisible="{Binding HasErrors}" />+ </Panel>+ </Border>+ <StackPanel VerticalAlignment="Center">+ <TextBlock FontWeight="SemiBold" Text="{Binding Title}" />+ <StackPanel Orientation="Horizontal" Spacing="8">+ <TextBlock Classes="caption" Text="{Binding Subtitle}" TextTrimming="CharacterEllipsis" MaxWidth="420" />+ <TextBlock Classes="caption" Text="·" />+ <TextBlock Classes="caption" Text="{Binding Time}" />+ </StackPanel></StackPanel>- </Button>- <Border DockPanel.Dock="Left" Width="32" Height="32" CornerRadius="999" Margin="0,0,12,0"- Background="{DynamicResource AccentSoftBrush}">- <Panel>- <PathIcon Width="15" Height="15" Data="{StaticResource Icon.Check}" Foreground="{DynamicResource AccentStrongBrush}" IsVisible="{Binding !HasErrors}" />- <PathIcon Width="15" Height="15" Data="{StaticResource Icon.Alert}" Foreground="{DynamicResource DangerBrush}" IsVisible="{Binding HasErrors}" />- </Panel>- </Border>- <StackPanel VerticalAlignment="Center" ToolTip.Tip="{Binding Errors}">- <TextBlock FontWeight="SemiBold" Text="{Binding Title}" />- <StackPanel Orientation="Horizontal" Spacing="8">- <TextBlock Classes="caption" Text="{Binding Subtitle}" TextTrimming="CharacterEllipsis" MaxWidth="420" />- <TextBlock Classes="caption" Text="·" />- <TextBlock Classes="caption" Text="{Binding Time}" />- </StackPanel>- </StackPanel>- </DockPanel>+ </DockPanel>++ <!-- Failed files: the list on demand, and converting them again -->+ <DockPanel IsVisible="{Binding HasFailures}" Margin="44,0,0,0">+ <Button DockPanel.Dock="Right" Command="{Binding RetryCommand}" IsVisible="{Binding CanRetry}" Padding="10,5">+ <StackPanel Orientation="Horizontal" Spacing="6">+ <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Refresh}" />+ <TextBlock Text="{DynamicResource common.retry}" />+ </StackPanel>+ </Button>+ <Button Classes="ghost" Command="{Binding ToggleFailuresCommand}" Padding="6,4" HorizontalAlignment="Left">+ <StackPanel Orientation="Horizontal" Spacing="6">+ <PathIcon Classes="chevron" Classes.open="{Binding ShowFailures}" Width="12" Height="12"+ Data="{StaticResource Icon.ChevronRight}" />+ <TextBlock Classes="caption danger" Text="{Binding FailureSummary}" />+ </StackPanel>+ </Button>+ </DockPanel>+ <ItemsControl ItemsSource="{Binding Failures}" IsVisible="{Binding ShowFailures}" Margin="50,0,0,2">+ <ItemsControl.ItemsPanel>+ <ItemsPanelTemplate>+ <StackPanel Spacing="4" />+ </ItemsPanelTemplate>+ </ItemsControl.ItemsPanel>+ <ItemsControl.ItemTemplate>+ <DataTemplate x:DataType="app:FailureItem">+ <StackPanel>+ <SelectableTextBlock Classes="caption" FontWeight="SemiBold" Text="{Binding Name}" TextWrapping="Wrap" />+ <SelectableTextBlock Classes="caption danger" Text="{Binding Reason}" TextWrapping="Wrap" />+ </StackPanel>+ </DataTemplate>+ </ItemsControl.ItemTemplate>+ </ItemsControl>+ </StackPanel></Border></DataTemplate></ItemsControl.ItemTemplate>diff --git a/src/Filee.App/Views/ToastWindow.axaml b/src/Filee.App/Views/ToastWindow.axamlindex e140b8f2..390c9f91 100644--- a/src/Filee.App/Views/ToastWindow.axaml+++ b/src/Filee.App/Views/ToastWindow.axaml@@ -66,6 +66,12 @@<DockPanel><StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Spacing="6"><Button Content="{DynamicResource toast.cancel}" Command="{Binding CancelCommand}" IsVisible="{Binding IsRunning}" Padding="10,4" />+ <Button Command="{Binding RetryCommand}" IsVisible="{Binding CanRetry}" Padding="10,4">+ <StackPanel Orientation="Horizontal" Spacing="6">+ <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Refresh}" />+ <TextBlock Text="{DynamicResource common.retry}" />+ </StackPanel>+ </Button><Button Classes="accent" Command="{Binding OpenFolderCommand}" IsVisible="{Binding HasOutputs}" Padding="10,4"><StackPanel Orientation="Horizontal" Spacing="6"><PathIcon Width="13" Height="13" Data="{StaticResource Icon.Folder}" />diff --git a/src/Filee.Core/History/HistoryEntry.cs b/src/Filee.Core/History/HistoryEntry.csindex 63e71894..a05063c9 100644--- a/src/Filee.Core/History/HistoryEntry.cs+++ b/src/Filee.Core/History/HistoryEntry.cs@@ -1,6 +1,7 @@// A finished conversion job as shown on the Home page ("Recent conversions").using Filee.Core.Conversion;+using Filee.Core.Presets;namespace Filee.Core.History;@@ -15,21 +16,48 @@ public sealed class HistoryEntrypublic List<string> Sources { get; set; } = [];public List<string> Outputs { get; set; } = [];- /// <summary>"source: error" lines for failed files.</summary>+ /// <summary>Files that failed, with the reason.</summary>+ public List<HistoryFailure> Failures { get; set; } = [];++ /// <summary>+ /// The preset as the job ran it (save location already decided, a watch folder's output folder included), kept+ /// when files failed: they can be converted again the same way even after the preset was changed or deleted.+ /// </summary>+ public Preset? Preset { get; set; }++ /// <summary>"file: error" lines written by Filee 1.7 and earlier; read for entries without <see cref="Failures"/>.</summary>public List<string> Errors { get; set; } = [];- public static HistoryEntry From(ConversionJob job) => new()+ public static HistoryEntry From(ConversionJob job){- JobId = job.Id,- FinishedAt = DateTime.Now,- PresetId = job.Preset.Id,- PresetName = job.PresetDisplayName,- State = job.State,- Sources = [.. job.Sources],- Outputs = [.. job.Outputs],- Errors = job.Files+ var failures = job.Files.Where(f => f.State == FileState.Failed)- .Select(f => $"{Path.GetFileName(f.SourcePath)}: {f.ErrorKey} {f.ErrorDetail}".Trim())- .ToList(),- };+ .Select(f => new HistoryFailure { Source = f.SourcePath, ErrorKey = f.ErrorKey, ErrorDetail = f.ErrorDetail })+ .ToList();+ return new HistoryEntry+ {+ JobId = job.Id,+ FinishedAt = DateTime.Now,+ PresetId = job.Preset.Id,+ PresetName = job.PresetDisplayName,+ State = job.State,+ Sources = [.. job.Sources],+ Outputs = [.. job.Outputs],+ Failures = failures,+ Preset = failures.Count > 0 ? job.Preset.Clone() : null,+ };+ }+}++/// <summary>A file a job couldn't convert.</summary>+public sealed class HistoryFailure+{+ /// <summary>Full path of the source file.</summary>+ public string Source { get; set; } = "";++ /// <summary>Localization key of the reason (e.g. <c>error.no_route</c>).</summary>+ public string? ErrorKey { get; set; }++ /// <summary>Detail of the reason (an engine's message, the formats of a missing route).</summary>+ public string? ErrorDetail { get; set; }}diff --git a/tests/Filee.App.Tests/FailedFilesTests.cs b/tests/Filee.App.Tests/FailedFilesTests.csnew file mode 100644index 00000000..88681bf7--- /dev/null+++ b/tests/Filee.App.Tests/FailedFilesTests.cs@@ -0,0 +1,73 @@+// Recent conversions list the files that failed with their reason and can convert them again.++using Avalonia.Headless.XUnit;+using Filee.App.Services;+using Filee.App.ViewModels.Pages;+using Filee.Core.Conversion;+using Filee.Core.History;+using Filee.Core.Localization;+using Filee.Core.Platform;+using Filee.Core.Presets;++namespace Filee.App.Tests;++public class FailedFilesTests+{+ [AvaloniaFact]+ public void Failures_saved_by_older_versions_are_listed_in_the_current_language()+ {+ TestServices.EnsureInitialized("ko");+ var entry = new HistoryEntry+ {+ PresetName = "PNG",+ State = JobState.CompletedWithErrors,+ Sources = ["photo.jpg", "notes.xyz"],+ Errors = ["notes.xyz: error.unsupported_source xyz"],+ };++ var item = new HistoryItemViewModel(entry, AppHost.Get<ILocalizer>(), AppHost.Get<IPlatformServices>(), AppHost.Get<ConversionService>());++ var failure = Assert.Single(item.Failures);+ Assert.Equal("notes.xyz", failure.Name);+ Assert.Equal($"{AppHost.Get<ILocalizer>()["error.unsupported_source"]} (xyz)", failure.Reason);+ Assert.Equal("1개 실패", item.FailureSummary);+ Assert.False(item.CanRetry); // no preset saved: nothing to retry with+ }++ [AvaloniaFact]+ public void Retry_converts_the_failed_files_that_are_still_there_with_the_saved_preset()+ {+ TestServices.EnsureInitialized("en");+ var folder = Directory.CreateTempSubdirectory("filee-retry-").FullName;+ try+ {+ var kept = Path.Combine(folder, "kept.png");+ File.WriteAllBytes(kept, [0x89, 0x50, 0x4E, 0x47]);+ var gone = Path.Combine(folder, "gone.png");+ var preset = new Preset { Id = "jpg-70", Name = "JPG 70%", TargetFormat = "jpg", Output = { Location = OutputLocation.CustomFolder, CustomFolder = Path.Combine(folder, "out") } };+ var entry = new HistoryEntry+ {+ PresetName = "JPG 70%",+ State = JobState.Failed,+ Sources = [kept, gone],+ Failures = [new HistoryFailure { Source = kept, ErrorKey = "error.conversion_failed" }, new HistoryFailure { Source = gone }],+ Preset = preset,+ };+ var conversions = AppHost.Get<ConversionService>();+ var item = new HistoryItemViewModel(entry, AppHost.Get<ILocalizer>(), AppHost.Get<IPlatformServices>(), conversions);+ Assert.True(item.CanRetry);++ item.RetryCommand.Execute(null);++ var job = conversions.Jobs[0].Job;+ Assert.Equal([kept], job.Sources);+ Assert.Equal("jpg", job.Preset.TargetFormat);+ Assert.Equal(Path.Combine(folder, "out"), job.Preset.Output.CustomFolder);+ job.Cancel();+ }+ finally+ {+ try { Directory.Delete(folder, true); } catch (IOException) { }+ }+ }+}diff --git a/tests/Filee.App.Tests/RenderTests.cs b/tests/Filee.App.Tests/RenderTests.csindex a10795ce..cdb3e26c 100644--- a/tests/Filee.App.Tests/RenderTests.cs+++ b/tests/Filee.App.Tests/RenderTests.cs@@ -74,6 +74,52 @@ public class RenderTests}}+ [AvaloniaTheory]+ [InlineData("en")]+ [InlineData("ko")]+ public void Home_page_lists_failed_files_with_a_retry_button(string language)+ {+ TestServices.EnsureInitialized(language);+ var store = AppHost.Get<Filee.Core.Settings.UserDataStore>();+ var folder = Directory.CreateTempSubdirectory("filee-home-").FullName;+ var scan = Path.Combine(folder, "scan-0412.heic");+ File.WriteAllBytes(scan, [0]);+ var entry = new Filee.Core.History.HistoryEntry+ {+ FinishedAt = DateTime.Now,+ PresetName = "PDF",+ State = Filee.Core.Conversion.JobState.CompletedWithErrors,+ Sources = [Path.Combine(folder, "report.docx"), scan, Path.Combine(folder, "notes.xyz")],+ Failures =+ [+ new() { Source = scan, ErrorKey = "error.conversion_failed", ErrorDetail = "HEIC decoder: unexpected end of file" },+ new() { Source = Path.Combine(folder, "notes.xyz"), ErrorKey = "error.unsupported_source", ErrorDetail = "xyz" },+ ],+ Preset = new Filee.Core.Presets.Preset { TargetFormat = "pdf" },+ };+ store.AddHistory(entry);+ try+ {+ var vm = new MainWindowViewModel(AppHost.Services, AppHost.Get<Filee.Core.Localization.ILocalizer>(), AppHost.Get<UpdateService>());+ vm.Navigate("home");+ var window = new MainWindow { DataContext = vm, Width = 1080, Height = 820 };+ window.Show();+ Pump();++ var item = ((Filee.App.ViewModels.Pages.HomePageViewModel)vm.CurrentPage).History[0];+ Assert.True(item.CanRetry);+ item.ToggleFailuresCommand.Execute(null);+ Pump();+ Save(window, $"page-home-failed-{language}.png");+ window.Close();+ }+ finally+ {+ store.ClearHistory(); // also on disk: the next test's application loads the history again+ try { Directory.Delete(folder, true); } catch (IOException) { }+ }+ }+[AvaloniaFact]public void Engines_page_shows_versions_descriptions_and_download_speed(){diff --git a/tests/Filee.Core.Tests/HistoryEntryTests.cs b/tests/Filee.Core.Tests/HistoryEntryTests.csnew file mode 100644index 00000000..8778d4bd--- /dev/null+++ b/tests/Filee.Core.Tests/HistoryEntryTests.cs@@ -0,0 +1,54 @@+// Recent conversions remember which files failed, why, and the preset they ran with, so they can be converted again.++using Filee.Core.Conversion;+using Filee.Core.History;+using Filee.Core.Presets;+using Filee.Core.Settings;++namespace Filee.Core.Tests;++public class HistoryEntryTests+{+ [Fact]+ public async Task Failed_files_are_kept_with_their_reason_and_the_preset_as_it_ran()+ {+ using var dir = new TempDir();+ var photo = dir.File("photo.jpg");+ var notes = dir.File("notes.xyz");+ var output = Path.Combine(dir.Path, "out");+ await using var queue = new JobQueue(new ConverterCatalog([new FakeConverter("magick", new ConversionEdge("jpg", "png"))]));+ var preset = new Preset { Id = "to-png", TargetFormat = "png", Output = { Location = OutputLocation.CustomFolder, CustomFolder = output } };+ var job = new ConversionJob([photo, notes], preset, "PNG");+ await queue.RunAsync(job);++ var store = new UserDataStore(dir.Path);+ store.Load();+ store.AddHistory(HistoryEntry.From(job));+ var reloaded = new UserDataStore(dir.Path);+ reloaded.Load();+ var entry = Assert.Single(reloaded.History);++ Assert.Equal(JobState.CompletedWithErrors, entry.State);+ var failure = Assert.Single(entry.Failures);+ Assert.Equal(notes, failure.Source);+ Assert.Equal("error.unsupported_source", failure.ErrorKey);+ Assert.Equal("png", entry.Preset!.TargetFormat);+ Assert.Equal(OutputLocation.CustomFolder, entry.Preset.Output.Location);+ Assert.Equal(output, entry.Preset.Output.CustomFolder);+ }++ [Fact]+ public async Task A_job_without_failures_keeps_no_preset()+ {+ using var dir = new TempDir();+ var photo = dir.File("photo.jpg");+ await using var queue = new JobQueue(new ConverterCatalog([new FakeConverter("magick", new ConversionEdge("jpg", "png"))]));+ var job = new ConversionJob([photo], new Preset { TargetFormat = "png" }, "PNG");+ await queue.RunAsync(job);++ var entry = HistoryEntry.From(job);++ Assert.Empty(entry.Failures);+ Assert.Null(entry.Preset);+ }+}