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
Rotate and flip: back from an older Filee they work again
SeoJCalive715960169153
diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.csindex 09398ef6..fcbec663 100644--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@ -372,13 +372,35 @@ internal static class SettingsMigrationschanged = true;}- // v11: rotate / flip presets and the "Rotate" / "Flip" groups that fan them out, on no donut.+ // v11: rotate / flip presets and the "Rotate" / "Flip" groups that fan them out, on no donut, after "Remove+ // background" as in a new library. Present already but saved since by a Filee before 11 (it reads and writes+ // schema 10, so back and forth between versions comes here again): that one dropped what it didn't know, the+ // rotation and the group, and left a preset that re-encodes unturned. Those parts are put back, the user's+ // own changes (name, quality, file names) stay.if (from < 11){- foreach (var preset in BuiltInData.ImageToolPresets().Where(p => presets.All(existing => existing.Id != p.Id)))+ var at = presets.FindIndex(p => p.Id == "remove-background");+ at = at < 0 ? presets.Count : at + 1;+ foreach (var tool in BuiltInData.ImageToolPresets()){- presets.Add(preset);- changed = true;+ if (presets.FirstOrDefault(p => p.Id == tool.Id) is not { } existing)+ {+ presets.Insert(Math.Min(at++, presets.Count), tool);+ changed = true;+ }+ else if (tool.IsGroup && !existing.IsGroup)+ {+ existing.Kind = PresetKind.Group;+ existing.SubPresetIds = [.. tool.SubPresetIds];+ existing.TargetFormat = tool.TargetFormat;+ changed = true;+ }+ else if (!tool.IsGroup && !existing.Image.TurnsOrMirrors)+ {+ existing.Image.Rotation = tool.Image.Rotation;+ existing.Image.Flip = tool.Image.Flip;+ changed = true;+ }}}diff --git a/tests/Filee.Core.Tests/UserDataStoreTests.cs b/tests/Filee.Core.Tests/UserDataStoreTests.csindex 713e1a55..6f74e43d 100644--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs@@ -288,6 +288,32 @@ public class UserDataStoreTestsAssert.Equal(ImageFlip.Horizontal, presets.Single(p => p.Id == "flip-horizontal").Image.Flip);Assert.DoesNotContain(profiles, p => p.PresetIds.Any(id => id.StartsWith("rotate") || id.StartsWith("flip")));Assert.False(SettingsMigrations.ApplyToLibrary(10, presets, profiles)); // once only+ // Where a new library has them: after "Remove background".+ var background = presets.FindIndex(p => p.Id == "remove-background");+ Assert.Equal("rotate-left", presets[background + 1].Id);+ }++ [Fact]+ public void Back_from_an_older_Filee_rotate_and_flip_work_again_and_keep_the_users_changes()+ {+ // What a Filee before 11 leaves after saving: kind, members and rotation dropped, the rest as it was.+ var presets = BuiltInData.CreatePresets();+ var left = presets.Single(p => p.Id == "rotate-left");+ left.Image.Rotation = ImageRotation.None;+ left.Name = "Turn left";+ var rotate = presets.Single(p => p.Id == "rotate");+ rotate.Kind = PresetKind.Convert;+ rotate.SubPresetIds = [];+ var profiles = BuiltInData.CreateProfiles();++ Assert.True(SettingsMigrations.ApplyToLibrary(10, presets, profiles));++ Assert.Equal(ImageRotation.Left90, left.Image.Rotation);+ Assert.Equal("Turn left", left.Name);+ Assert.True(rotate.IsGroup);+ Assert.Equal(["rotate-left", "rotate-right", "rotate-180"], rotate.SubPresetIds);+ Assert.Equal(Preset.GroupTarget, rotate.TargetFormat);+ Assert.Single(presets, p => p.Id == "rotate-left"); // repaired, not added twice}[Fact]