Skip to content

Commit 6499dfc

Browse files
authored
Code Quality: Removed LiteDB (#15620)
1 parent c251273 commit 6499dfc

File tree

4 files changed

+0
-86
lines changed

4 files changed

+0
-86
lines changed

src/Files.App/Files.App.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
<PackageReference Include="FluentFTP" Version="43.0.1" />
7070
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
7171
<PackageReference Include="LibGit2Sharp" Version="0.30.0" />
72-
<PackageReference Include="LiteDB" Version="5.0.20" />
7372
<PackageReference Include="MessageFormat" Version="7.1.0" />
7473
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.6" />
7574
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />

src/Files.App/Helpers/Layout/LayoutPreferencesDatabase.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using LiteDB;
54
using Microsoft.Win32;
6-
using System.IO;
75
using System.Runtime.CompilerServices;
86
using Windows.ApplicationModel;
9-
using Windows.Storage;
107
using static Files.App.Helpers.LayoutPreferencesDatabaseItemRegistry;
118
using static Files.App.Helpers.RegistryHelpers;
129
using JsonSerializer = System.Text.Json.JsonSerializer;
@@ -17,26 +14,6 @@ public sealed class LayoutPreferencesDatabase
1714
{
1815
private readonly static string LayoutSettingsKey = @$"Software\Files Community\{Package.Current.Id.FullName}\v1\LayoutPreferences";
1916

20-
private readonly static string LayoutSettingsDbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "user_settings.db");
21-
private const string LayoutSettingsCollectionName = "layoutprefs";
22-
23-
static LayoutPreferencesDatabase()
24-
{
25-
if (File.Exists(LayoutSettingsDbPath))
26-
{
27-
using (var database = new LiteDatabase(new ConnectionString(LayoutSettingsDbPath)
28-
{
29-
Connection = ConnectionType.Direct,
30-
Upgrade = true
31-
}))
32-
{
33-
ImportCore(database.GetCollection<LayoutPreferencesDatabaseItem>(LayoutSettingsCollectionName).FindAll().ToArray());
34-
}
35-
36-
File.Delete(LayoutSettingsDbPath);
37-
}
38-
}
39-
4017
public LayoutPreferencesItem? GetPreferences(string filePath, ulong? frn)
4118
{
4219
return FindPreferences(filePath, frn)?.LayoutPreferencesManager;

src/Files.App/Utils/FileTags/FileTagsDatabase.cs

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using LiteDB;
54
using Microsoft.Win32;
6-
using System.IO;
75
using System.Runtime.CompilerServices;
8-
using System.Text;
96
using Windows.ApplicationModel;
10-
using Windows.Storage;
117
using JsonSerializer = System.Text.Json.JsonSerializer;
128
using static Files.App.Helpers.RegistryHelpers;
139
using static Files.App.Utils.FileTags.TaggedFileRegistry;
@@ -18,63 +14,6 @@ public sealed class FileTagsDatabase
1814
{
1915
private readonly static string FileTagsKey = @$"Software\Files Community\{Package.Current.Id.FullName}\v1\FileTags";
2016

21-
private readonly static string FileTagsDbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "filetags.db");
22-
private const string FileTagsCollectionName = "taggedfiles";
23-
24-
static FileTagsDatabase()
25-
{
26-
if (File.Exists(FileTagsDbPath))
27-
{
28-
SafetyExtensions.IgnoreExceptions(() => CheckDbVersion(FileTagsDbPath));
29-
30-
using (var database = new LiteDatabase(new ConnectionString(FileTagsDbPath)
31-
{
32-
Connection = ConnectionType.Direct,
33-
Upgrade = true
34-
}))
35-
{
36-
UpdateDb(database);
37-
ImportCore(database.GetCollection<TaggedFile>(FileTagsCollectionName).FindAll().ToArray());
38-
}
39-
40-
File.Delete(FileTagsDbPath);
41-
}
42-
}
43-
44-
private static void UpdateDb(LiteDatabase database)
45-
{
46-
if (database.UserVersion == 0)
47-
{
48-
var col = database.GetCollection(FileTagsCollectionName);
49-
foreach (var doc in col.FindAll())
50-
{
51-
doc["Tags"] = new BsonValue(new[] { doc["Tag"].AsString });
52-
doc.Remove("Tags");
53-
col.Update(doc);
54-
}
55-
database.UserVersion = 1;
56-
}
57-
}
58-
59-
// https://github.com/mbdavid/LiteDB/blob/master/LiteDB/Engine/Engine/Upgrade.cs
60-
private static void CheckDbVersion(string filename)
61-
{
62-
var buffer = new byte[8192 * 2];
63-
using (var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
64-
{
65-
// read first 16k
66-
stream.Read(buffer, 0, buffer.Length);
67-
68-
// checks if v7 (plain or encrypted)
69-
if (Encoding.UTF8.GetString(buffer, 25, "** This is a LiteDB file **".Length) == "** This is a LiteDB file **" &&
70-
buffer[52] == 7)
71-
{
72-
return; // version 4.1.4
73-
}
74-
}
75-
File.Delete(filename); // recreate DB with correct version
76-
}
77-
7817
public void SetTags(string filePath, ulong? frn, string[] tags)
7918
{
8019
using var filePathKey = Registry.CurrentUser.CreateSubKey(CombineKeys(FileTagsKey, filePath));

src/Files.App/ViewModels/Settings/AboutViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public AboutViewModel()
5858
new ("https://github.com/robinrodricks/FluentFTP", "FluentFTP"),
5959
new ("https://github.com/rickyah/ini-parser", "INI File Parser"),
6060
new ("https://github.com/libgit2/libgit2sharp", "libgit2sharp"),
61-
new ("https://github.com/mbdavid/LiteDB", "LiteDB"),
6261
new ("https://github.com/beto-rodriguez/LiveCharts2", "LiveCharts2"),
6362
new ("https://github.com/jeffijoe/messageformat.net", "MessageFormat"),
6463
new ("https://github.com/dotnet/efcore", "EF Core for SQLite"),

0 commit comments

Comments
 (0)