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.

What's new: the installer passes the version it updated from

KnifeLemon106857d9800b
diff --git a/src/Filee.App/App.axaml.cs b/src/Filee.App/App.axaml.cs
index c7077c3d..d41bbee3 100644
--- a/src/Filee.App/App.axaml.cs
+++ b/src/Filee.App/App.axaml.cs
@@ -152,7 +152,7 @@ public partial class App : Application
AppHost.Get<WhatsNewService>().CheckAtStartup(
background: Program.Options.Background && !Program.Options.ShowSettings && !Program.Options.WhatsNew
|| Program.Options.ConvertFiles.Count > 0,
- updated: Program.Options.WhatsNew);
+ updated: Program.Options.WhatsNew, updatedFrom: Program.Options.UpdatedFrom);
HandleCommandLine(Program.Options, firstLaunch: true);
if (OperatingSystem.IsMacOS())
this.TryGetFeature<IActivatableLifetime>()?.Activated += (_, e) =>
diff --git a/src/Filee.App/Services/CommandLine.cs b/src/Filee.App/Services/CommandLine.cs
index 58dd1f79..eb17faab 100644
--- a/src/Filee.App/Services/CommandLine.cs
+++ b/src/Filee.App/Services/CommandLine.cs
@@ -1,8 +1,9 @@
// Command line options:
// Filee.exe open the main window
// Filee.exe --background start in the tray only (used by "start with Windows")
-// Filee.exe --whats-new with --background: show this version's "What's new" slides anyway, if they
-// are due (the installer after an update the user started)
+// Filee.exe --whats-new[=1.12.0] with --background: show this version's "What's new" slides anyway, if they
+// are due (the installer after an update the user started); the value is the
+// version updated from, which decides what is new
// Filee.exe --settings open the main window
// Filee.exe --convert a b ... open the donut for these files (Explorer context menu / Send To)
// Filee.exe --convert-list <file> same, with one path per line in a UTF-8 file (Windows 11 Explorer menu, for
@@ -27,6 +28,7 @@ namespace Filee.App.Services;
/// <param name="ContextMenu">Value of <c>--context-menu</c>; null when absent.</param>
/// <param name="Language">Value of <c>--language</c>; null when absent.</param>
/// <param name="WhatsNew"><c>--whats-new</c>: due slides show even when starting in the background.</param>
+/// <param name="UpdatedFrom">The value of <c>--whats-new</c>: the version the installer updated from; null when absent.</param>
public sealed record CommandLine(
bool Background,
bool ShowSettings,
@@ -38,7 +40,8 @@ public sealed record CommandLine(
bool? StartWithWindows = null,
bool? ContextMenu = null,
string? Language = null,
- bool WhatsNew = false)
+ bool WhatsNew = false,
+ string? UpdatedFrom = null)
{
/// <summary>File name prefix of list files written by FileeExplorerMenu.dll (LIST_PREFIX there) into %TEMP%.</summary>
public const string ListFilePrefix = "Filee-convert-";
@@ -58,6 +61,7 @@ public sealed record CommandLine(
bool? contextMenu = null;
string? language = null;
var whatsNew = false;
+ string? updatedFrom = null;
foreach (var arg in args)
{
@@ -95,6 +99,7 @@ public sealed record CommandLine(
break;
case "--whats-new":
whatsNew = true;
+ updatedFrom = string.IsNullOrWhiteSpace(value) ? null : value.Trim();
break;
case "--settings":
settings = true;
@@ -112,7 +117,7 @@ public sealed record CommandLine(
break;
}
}
- return new CommandLine(background, settings, files, listFile, quit, cleanup, engines, startWithWindows, contextMenu, language, whatsNew);
+ return new CommandLine(background, settings, files, listFile, quit, cleanup, engines, startWithWindows, contextMenu, language, whatsNew, updatedFrom);
}
/// <summary>"--Name=Value" → ("--name", "Value"); "--name" → ("--name", null).</summary>
diff --git a/src/Filee.App/Services/WhatsNewService.cs b/src/Filee.App/Services/WhatsNewService.cs
index 6c946c58..bc0b31d0 100644
--- a/src/Filee.App/Services/WhatsNewService.cs
+++ b/src/Filee.App/Services/WhatsNewService.cs
@@ -40,12 +40,16 @@ public sealed class WhatsNewService(UserDataStore store, WindowService windows,
internal readonly record struct Decision(SlideDeck? Show, Version? Remember);
/// <summary>The rules described at the top of this file, without side effects.</summary>
+ /// <param name="updatedFrom">
+ /// The version the installer updated from: what was running before, so it decides what is new over a remembered
+ /// version (going back to an older Filee and updating again shows the slides again).
+ /// </param>
internal static Decision Decide(string? seenSetting, bool firstRunCompleted, Version current, IEnumerable<SlideDeck> decks,
- bool updated = false)
+ bool updated = false, string? updatedFrom = null)
{
if (!firstRunCompleted && !updated)
return new Decision(null, current);
- var seen = SlideDeck.TryParseVersion(seenSetting);
+ var seen = SlideDeck.TryParseVersion(updatedFrom) ?? SlideDeck.TryParseVersion(seenSetting);
if (seen is not null && current <= seen)
return new Decision(null, null);
var deck = SlideDeck.Newest(decks, seen, current);
@@ -55,14 +59,15 @@ public sealed class WhatsNewService(UserDataStore store, WindowService windows,
/// <summary>
/// Called once at start-up, before the first run is marked complete. <paramref name="background"/> (started at
/// sign-in, or after an update without <c>--whats-new</c>) keeps the slides until the main window opens.
- /// <paramref name="updated"/>: the installer started Filee after an update (<c>--whats-new</c>).
+ /// <paramref name="updated"/>: the installer started Filee after an update (<c>--whats-new</c>), from
+ /// <paramref name="updatedFrom"/> when it says.
/// </summary>
- public void CheckAtStartup(bool background, bool updated = false)
+ public void CheckAtStartup(bool background, bool updated = false, string? updatedFrom = null)
{
Decision decision;
try
{
- decision = Decide(store.Settings.WhatsNewSeenVersion, store.Settings.FirstRunCompleted, CurrentVersion, Decks, updated);
+ decision = Decide(store.Settings.WhatsNewSeenVersion, store.Settings.FirstRunCompleted, CurrentVersion, Decks, updated, updatedFrom);
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
diff --git a/src/Filee.Setup/Installation/Installer.cs b/src/Filee.Setup/Installation/Installer.cs
index 5eceb860..70a74b2e 100644
--- a/src/Filee.Setup/Installation/Installer.cs
+++ b/src/Filee.Setup/Installation/Installer.cs
@@ -124,7 +124,7 @@ public sealed class Installer(SetupContext context, SetupPayload payload)
swap.Commit();
progress?.Report(new SetupProgress(SetupStep.Finishing, 1));
Log.Info("Done");
- var launch = choices.Portable ? null : new LaunchRequest(Path.Combine(folder, SetupNames.AppExe), LaunchArguments(choices, update));
+ var launch = choices.Portable ? null : new LaunchRequest(Path.Combine(folder, SetupNames.AppExe), LaunchArguments(choices, update, updatedFrom: previous?.Version));
return new InstallResult(launch, warnings);
}
catch (Exception ex) when (ex is not OutOfMemoryException)
@@ -171,16 +171,20 @@ public sealed class Installer(SetupContext context, SetupPayload payload)
/// <summary>
/// The arguments Filee starts with: the choices of a fresh install, or after an update the new version's "What's new"
/// slides, back in the tray (/SILENT, the app's own updater) or over the main window (<paramref name="shown"/>: the
- /// user clicked "Launch Filee").
+ /// user clicked "Launch Filee"). <paramref name="updatedFrom"/>, the version updated from, tells Filee what is new.
/// </summary>
- public static string LaunchArguments(InstallChoices choices, bool update, bool shown = false) => update
- ? shown ? "--whats-new" : "--background --whats-new"
+ public static string LaunchArguments(InstallChoices choices, bool update, bool shown = false, string? updatedFrom = null) => update
+ ? (shown ? "" : "--background ") + "--whats-new" + (IsVersion(updatedFrom) ? "=" + updatedFrom : "")
: $"--install-engines={string.Join(',', choices.Engines)} " +
$"--start-with-windows={OnOff(choices.Tasks.Startup)} --context-menu={OnOff(choices.Tasks.ContextMenu)}" +
(choices.LanguagePicked ? $" --language={choices.Language}" : "");
private static string OnOff(bool value) => value ? "on" : "off";
+ /// <summary>Digits and dots only: safe on a command line without quoting.</summary>
+ private static bool IsVersion(string? text) =>
+ !string.IsNullOrEmpty(text) && text.Length <= 32 && text.All(c => char.IsAsciiDigit(c) || c == '.');
+
private void CheckSpace(string folder)
{
try
diff --git a/src/Filee.Setup/ViewModels/SetupViewModel.cs b/src/Filee.Setup/ViewModels/SetupViewModel.cs
index 01ebc028..f756319a 100644
--- a/src/Filee.Setup/ViewModels/SetupViewModel.cs
+++ b/src/Filee.Setup/ViewModels/SetupViewModel.cs
@@ -319,7 +319,7 @@ public sealed partial class SetupViewModel : ObservableObject
private void LaunchAndClose()
{
Launch = IsUpdate && _result?.Launch is { } launch
- ? launch with { Arguments = Installer.LaunchArguments(_initial, update: true, shown: true) }
+ ? launch with { Arguments = Installer.LaunchArguments(_initial, update: true, shown: true, _previous?.Version) }
: _result?.Launch;
CloseRequested?.Invoke(this, EventArgs.Empty);
}
diff --git a/tests/Filee.App.Tests/WhatsNewTests.cs b/tests/Filee.App.Tests/WhatsNewTests.cs
index 39a1f8ee..2d075d20 100644
--- a/tests/Filee.App.Tests/WhatsNewTests.cs
+++ b/tests/Filee.App.Tests/WhatsNewTests.cs
@@ -228,6 +228,19 @@ public class WhatsNewTests
Assert.True(options.Background);
Assert.True(options.WhatsNew);
Assert.False(CommandLine.Parse(["--background"]).WhatsNew);
+ Assert.Null(options.UpdatedFrom);
+ Assert.Equal("1.12.0", CommandLine.Parse(["--whats-new=1.12.0"]).UpdatedFrom);
+ }
+
+ [Fact]
+ public void The_version_updated_from_decides_over_the_remembered_one()
+ {
+ // 2.0.0's slides were seen, Filee went back to 1.12.0 and was updated again: they are new again.
+ Assert.Equal(V2, WhatsNewService.Decide("2.0.0", true, V2, Decks, updated: true, updatedFrom: "1.12.0").Show?.Version);
+ // Reinstalling the same version shows nothing.
+ Assert.Equal(default, WhatsNewService.Decide(null, true, V2, Decks, updated: true, updatedFrom: "2.0.0"));
+ // Unreadable: the remembered version decides.
+ Assert.Equal(default, WhatsNewService.Decide("2.0.0", true, V2, Decks, updated: true, updatedFrom: "next"));
}
// ───────────────────────── The window ─────────────────────────
diff --git a/tests/Filee.Setup.Tests/InstallerTests.cs b/tests/Filee.Setup.Tests/InstallerTests.cs
index 4baa61da..8f3ca750 100644
--- a/tests/Filee.Setup.Tests/InstallerTests.cs
+++ b/tests/Filee.Setup.Tests/InstallerTests.cs
@@ -159,7 +159,7 @@ public class InstallerTests
Assert.True(File.Exists(Path.Combine(bench.Paths.CommonDesktop, "Filee.lnk")));
Assert.Contains($"register-menu {folder} False", bench.System.Calls);
// Back to the tray, as before the update, with the new version's "What's new" slides.
- Assert.Equal("--background --whats-new", result.Launch!.Arguments);
+ Assert.Equal("--background --whats-new=1.12.0", result.Launch!.Arguments);
}
[Fact]
@@ -320,9 +320,12 @@ public class InstallerTests
var updated = CommandLine.Parse(Installer.LaunchArguments(fresh, update: true).Split(' '));
Assert.True(updated.Background);
Assert.True(updated.WhatsNew);
- var shown = CommandLine.Parse(Installer.LaunchArguments(fresh, update: true, shown: true).Split(' '));
+ var shown = CommandLine.Parse(Installer.LaunchArguments(fresh, update: true, shown: true, updatedFrom: "1.12.0").Split(' '));
Assert.False(shown.Background);
Assert.True(shown.WhatsNew);
+ Assert.Equal("1.12.0", shown.UpdatedFrom);
+ // A version that isn't plain digits and dots stays off the command line.
+ Assert.Equal("--background --whats-new", Installer.LaunchArguments(fresh, update: true, updatedFrom: "1.0 \"--quit"));
Assert.False(CommandLine.Parse(Installer.LaunchArguments(fresh, update: false).Split(' ')).WhatsNew);
}
}