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.

Merge remote-tracking branch 'origin/main' into pr230-fix

KnifeLemone02a6b01f9ef
diff --cc src/Filee.Core/Settings/UserDataStore.cs
index 77a88240,c8bd5fb7..a0ec2bc8
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@@ -631,10 -632,33 +632,37 @@@ internal static class SettingsMigration
// of the user already takes them.
if (from < 24)
changed |= LearnExtensions(profiles, out _, ["potm"]);
+ // v26: interactive "Crop" tool, after "Remove background" as in a new library, on no donut: users add it in
+ // Settings → Toolbar. Present already but saved since by a Filee before 26: that one read the unknown
+ // kind as a Group, dropped the target format and left an empty group. Kind and target format are put back,
+ // the user's own changes (name, file name pattern) stay.
+ if (from < 26)
+ {
+ if (BuiltInData.CreatePresets().FirstOrDefault(p => p.Id == "tool-crop") is { } crop)
+ {
+ if (presets.FirstOrDefault(p => p.Id == "tool-crop") is not { } existing)
+ {
+ var at = presets.FindIndex(p => p.Id == "remove-background");
+ presets.Insert(at < 0 ? presets.Count : at + 1, crop);
+ changed = true;
+ }
+ else if (existing.Kind != PresetKind.Tool)
+ {
+ existing.Kind = PresetKind.Tool;
+ existing.TargetFormat = crop.TargetFormat;
+ existing.SubPresetIds = [];
+ changed = true;
+ }
+ }
+ }
+ // v27: OFD documents (.ofd; read only: e-invoices, official documents) open from the office donut, unless a
+ // donut of the user already takes them.
+ if (from < 27)
+ changed |= LearnExtensions(profiles, out _, ["ofd"]);
+ // v28: "One ZIP" on the archives donut after "Extract", to pack several archives into one. A donut
+ // the user filled up, or a library without the preset, stays as it is.
+ if (from < 28)
+ changed |= Offer(presets, profiles, "archives", "zip-all", "extract");
return changed;
}
diff --cc tests/Filee.Core.Tests/UserDataStoreTests.cs
index cb06ea7d,537969eb..d3e227b0
--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs
+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs
@@@ -756,29 -784,30 +784,53 @@@ public class UserDataStoreTest
Assert.DoesNotContain("potm", profiles.Single(p => p.Id == "presentations").Extensions);
}
+ [Fact]
+ public void Version_26_libraries_learn_ofd_on_the_office_donut_and_nothing_else()
+ {
+ // As written with schema 26: no OFD, and the user took RTF off the office donut.
+ var presets = BuiltInData.CreatePresets();
+ var profiles = BuiltInData.CreateProfiles();
+ var office = profiles.Single(p => p.Id == "office");
+ office.Extensions.RemoveAll(e => e is "ofd" or "rtf");
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(26, presets, profiles));
+
+ Assert.Contains("ofd", office.Extensions);
+ Assert.DoesNotContain("rtf", office.Extensions);
+ Assert.False(SettingsMigrations.ApplyToLibrary(26, presets, profiles)); // once only
+
+ // A donut of the user that already opens .ofd files keeps them.
+ profiles = BuiltInData.CreateProfiles();
+ profiles.Single(p => p.Id == "office").Extensions.Remove("ofd");
+ profiles.Insert(0, new ToolbarProfile { Id = "invoices", Name = "Invoices", Extensions = ["ofd"] });
+ Assert.False(SettingsMigrations.ApplyToLibrary(26, presets, profiles));
+ Assert.DoesNotContain("ofd", profiles.Single(p => p.Id == "office").Extensions);
+ }
+
+ [Fact]
+ public void Version_27_libraries_get_one_zip_on_the_archives_donut_after_extract()
+ {
+ var presets = BuiltInData.CreatePresets();
+ var profiles = BuiltInData.CreateProfiles();
+ var archives = profiles.Single(p => p.Id == "archives");
+ archives.PresetIds.Remove("zip-all");
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(27, presets, profiles));
+ Assert.Equal(["extract", "zip-all", "to-zip", "to-7z", "to-tgz", "to-tar"], archives.PresetIds);
+ Assert.False(SettingsMigrations.ApplyToLibrary(27, presets, profiles)); // once only
+
+ // A library without the preset (the user deleted it) doesn't get it back, and a full donut stays full.
+ presets.RemoveAll(p => p.Id == "zip-all");
+ archives.PresetIds.Remove("zip-all");
+ Assert.False(SettingsMigrations.ApplyToLibrary(27, presets, profiles));
+ Assert.DoesNotContain("zip-all", archives.PresetIds);
+
+ presets = BuiltInData.CreatePresets();
+ archives.PresetIds = [.. presets.Where(p => p.Id != "zip-all").Take(ToolbarProfile.MaxSlices).Select(p => p.Id)];
+ Assert.False(SettingsMigrations.ApplyToLibrary(27, presets, profiles));
+ Assert.DoesNotContain("zip-all", archives.PresetIds);
+ }
+
[Fact]
public void Version_15_libraries_get_the_tracing_presets_on_the_images_donut_after_pdf()
{