Skip to content

Commit 81df0a6

Browse files
authored
Code Quality: Introduced App.Utils.Storage namespace for storage functionalities (#12902)
1 parent b5b2150 commit 81df0a6

File tree

124 files changed

+333
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+333
-603
lines changed

src/Files.App/App.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Files.App.Extensions;
88
using Files.App.Utils;
99
using Files.App.Utils.Cloud;
10-
using Files.App.Utils.FilesystemHistory;
1110
using Files.App.Helpers;
1211
using Files.App.Services;
1312
using Files.App.Services.DateTimeFormatter;

src/Files.App/Data/Factories/SecurityAdvancedAccessControlItemFactory.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License. See the LICENSE.
33

44
using Files.App.Extensions;
5-
using Files.App.Utils.Security;
65
using System.Collections.Generic;
76
using System.Collections.ObjectModel;
87

src/Files.App/Data/Items/ListedItem.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License. See the LICENSE.
33

44
using Files.App.Utils.Cloud;
5-
using Files.App.Utils.StorageItems;
65
using Files.App.ViewModels.Properties;
76
using Files.Core.Helpers;
87
using Files.Core.ViewModels.FileTags;

src/Files.App/Data/Models/ItemViewModel.cs

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

4-
using Files.App.Helpers.StorageCache;
4+
using Files.App.Utils.Cloud;
5+
using Files.App.Utils.Shell;
6+
using Files.App.Storage.FtpStorage;
57
using Files.App.ViewModels.Previews;
68
using Files.Core.Services.SizeProvider;
79
using LibGit2Sharp;
@@ -36,7 +38,7 @@ public sealed class ItemViewModel : ObservableObject, IDisposable
3638
private readonly AsyncManualResetEvent gitChangedEvent;
3739
private readonly DispatcherQueue dispatcherQueue;
3840
private readonly JsonElement defaultJson = JsonSerializer.SerializeToElement("{}");
39-
private readonly IFileListCache fileListCache = FileListCacheController.GetInstance();
41+
private readonly IStorageCacheController fileListCache = StorageCacheController.GetInstance();
4042
private readonly string folderTypeTextLocalized = "Folder".GetLocalizedResource();
4143

4244
private Task? aProcessQueueAction;

src/Files.App/Extensions/ShellNewEntryExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License. See the LICENSE.
33

44
using Files.App.Utils;
5-
using Files.App.Utils.StorageItems;
65
using Files.App.Helpers;
76
using Files.App.Utils.Shell;
87
using Files.Shared;

src/Files.App/GlobalUsings.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,20 @@
1919
global using global::CommunityToolkit.Mvvm.Input;
2020
global using global::CommunityToolkit.Mvvm.Messaging;
2121

22-
// Files Front-end
22+
// Files.App
2323
global using global::Files.App.Helpers;
2424
global using global::Files.App.Extensions;
2525
global using global::Files.App.Utils;
2626
global using global::Files.App.Utils.Archives;
2727
global using global::Files.App.Utils.Cloud;
28-
global using global::Files.App.Utils.FilesystemHistory;
2928
global using global::Files.App.Utils.FileTags;
3029
global using global::Files.App.Utils.Git;
3130
global using global::Files.App.Utils.Library;
3231
global using global::Files.App.Utils.RecentItem;
3332
global using global::Files.App.Utils.RecycleBin;
34-
global using global::Files.App.Utils.Search;
35-
global using global::Files.App.Utils.Security;
3633
global using global::Files.App.Utils.Serialization;
3734
global using global::Files.App.Utils.Shell;
38-
global using global::Files.App.Utils.StorageEnumerators;
39-
global using global::Files.App.Utils.StorageItems;
35+
global using global::Files.App.Utils.Storage;
4036
global using global::Files.App.Data.Attributes;
4137
global using global::Files.App.Data.Behaviors;
4238
global using global::Files.App.Data.Commands;

src/Files.App/Helpers/BitmapHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.Utils.StorageItems;
54
using Microsoft.UI.Xaml.Media.Imaging;
65
using System.IO;
76
using Windows.Graphics.Imaging;

src/Files.App/Helpers/Navigation/NavigationHelpers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using CommunityToolkit.Mvvm.DependencyInjection;
55
using Files.App.Extensions;
66
using Files.App.Utils;
7-
using Files.App.Utils.StorageItems;
87
using Files.App.Utils.Shell;
98
using Files.App.ViewModels;
109
using Files.App.Views;

src/Files.App/Helpers/ShareItemHelpers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using Files.App.Extensions;
55
using Files.App.Utils;
6-
using Files.App.Utils.StorageItems;
76
using System;
87
using System.Collections.Generic;
98
using System.Linq;

src/Files.App/Helpers/UI/UIFilesystemHelpers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License. See the LICENSE.
33

44
using Files.App.Dialogs;
5-
using Files.App.Utils.StorageItems;
65
using Files.App.Storage.FtpStorage;
76
using Files.App.ViewModels.Dialogs;
87
using Microsoft.Extensions.Logging;

src/Files.App/Services/QuickAccessService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.Utils.StorageItems;
54
using Files.App.Utils.Shell;
65
using Files.App.UserControls.Widgets;
76

src/Files.App/UserControls/SidebarControl.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Files.App.Data.Items;
99
using Files.App.Data.Models;
1010
using Files.App.Extensions;
11-
using Files.App.Utils.StorageItems;
1211
using Files.App.Helpers.ContextFlyouts;
1312
using Files.App.Services;
1413
using Files.App.Utils.Shell;
@@ -787,7 +786,7 @@ private async void NavigationViewFileTagItem_DragOver(object sender, DragEventAr
787786
var deferral = e.GetDeferral();
788787
e.Handled = true;
789788

790-
var storageItems = await Utils.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
789+
var storageItems = await FilesystemHelpers.GetDraggedStorageItems(e.DataView);
791790

792791
if (!storageItems.Any())
793792
{
@@ -820,7 +819,7 @@ private async void NavigationViewFileTag_Drop(object sender, DragEventArgs e)
820819

821820
var deferral = e.GetDeferral();
822821

823-
var storageItems = await Utils.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
822+
var storageItems = await FilesystemHelpers.GetDraggedStorageItems(e.DataView);
824823
foreach (var item in storageItems.Where(x => !string.IsNullOrEmpty(x.Path)))
825824
{
826825
var listedItem = new ListedItem(null)

src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using CommunityToolkit.WinUI;
66
using Files.App.Extensions;
77
using Files.App.Utils;
8-
using Files.App.Utils.StorageEnumerators;
9-
using Files.App.Utils.StorageItems;
108
using Files.App.Helpers;
119
using Files.App.Helpers.ContextFlyouts;
1210
using Files.App.ViewModels;

src/Files.App/Utils/Archives/ArchiveHelpers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using Files.App.Dialogs;
55
using Files.App.Utils.Archives;
6-
using Files.App.Utils.StorageItems;
76
using Files.App.ViewModels.Dialogs;
87
using Microsoft.UI.Xaml.Controls;
98
using System.IO;

src/Files.App/Utils/Archives/ZipHelpers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.Utils.StorageItems;
54
using Microsoft.Extensions.Logging;
65
using SevenZip;
76
using System.IO;

src/Files.App/Utils/Cloud/CloudDrivesDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using System.Runtime.Versioning;
1111
using System.Threading.Tasks;
1212

13-
namespace Files.App.Helpers
13+
namespace Files.App.Utils.Cloud
1414
{
1515
[SupportedOSPlatform("Windows10.0.10240")]
1616
public class CloudDrivesDetector

src/Files.App/Utils/WallpaperHelpers.cs renamed to src/Files.App/Utils/Global/WallpaperHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using Windows.Storage;
99
using Windows.System.UserProfile;
1010

11-
namespace Files.App.Helpers
11+
namespace Files.App.Utils
1212
{
1313
public static class WallpaperHelpers
1414
{

src/Files.App/Utils/RecentItem/RecentItem.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.Utils.StorageItems;
54
using Files.App.UserControls.Widgets;
65
using Microsoft.UI.Xaml.Media.Imaging;
76
using Windows.Storage;
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using System.Threading;
5-
using System.Threading.Tasks;
6-
7-
namespace Files.App.Helpers.StorageCache
4+
namespace Files.App.Utils.Storage
85
{
9-
internal interface IFileListCache
6+
internal interface IStorageCacheController
107
{
118
public ValueTask<string> ReadFileDisplayNameFromCache(string path, CancellationToken cancellationToken);
129

1310
public ValueTask SaveFileDisplayNameToCache(string path, string displayName);
1411
}
15-
}
12+
}

src/Files.App/Helpers/StorageCache/FileListCacheController.cs renamed to src/Files.App/Utils/Storage/Cache/StorageCacheController.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22
// Licensed under the MIT License. See the LICENSE.
33

44
using System.Collections.Concurrent;
5-
using System.Threading;
6-
using System.Threading.Tasks;
75

8-
namespace Files.App.Helpers.StorageCache
6+
namespace Files.App.Utils.Storage
97
{
10-
internal class FileListCacheController : IFileListCache
8+
internal class StorageCacheController : IStorageCacheController
119
{
12-
private static FileListCacheController instance;
10+
private static StorageCacheController instance;
1311

14-
public static FileListCacheController GetInstance()
12+
private readonly ConcurrentDictionary<string, string> fileNamesCache = new();
13+
14+
private StorageCacheController()
1515
{
16-
return instance ??= new FileListCacheController();
1716
}
1817

19-
private FileListCacheController()
18+
public static StorageCacheController GetInstance()
2019
{
20+
return instance ??= new StorageCacheController();
2121
}
2222

23-
private readonly ConcurrentDictionary<string, string> fileNamesCache = new();
24-
2523
public ValueTask<string> ReadFileDisplayNameFromCache(string path, CancellationToken cancellationToken)
2624
{
2725
return fileNamesCache.TryGetValue(path, out var displayName) ? ValueTask.FromResult(displayName) : ValueTask.FromResult(string.Empty);
@@ -38,4 +36,4 @@ public ValueTask SaveFileDisplayNameToCache(string path, string displayName)
3836
return ValueTask.CompletedTask;
3937
}
4038
}
41-
}
39+
}

src/Files.App/Helpers/StorageItemCollection/BlockingListEnumerator.cs renamed to src/Files.App/Utils/Storage/Collection/BlockingListEnumerator.cs

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

4-
using System.Collections;
5-
using System.Collections.Generic;
6-
7-
namespace Files.App.Helpers
4+
namespace Files.App.Utils.Storage
85
{
96
public class BlockingListEnumerator<T> : IEnumerator<T>
107
{
118
private readonly IList<T> m_Inner;
9+
1210
private readonly object m_Lock;
11+
1312
private T m_Current;
14-
private int m_Pos;
1513

16-
public BlockingListEnumerator(IList<T> inner, object @lock)
17-
{
18-
m_Inner = inner;
19-
m_Lock = @lock;
20-
m_Pos = -1;
21-
}
14+
private int m_Pos;
2215

2316
public T Current
2417
{
2518
get
2619
{
2720
lock (m_Lock)
28-
{
2921
return m_Current;
30-
}
3122
}
3223
}
3324

34-
object IEnumerator.Current => Current;
25+
object IEnumerator.Current
26+
=> Current;
27+
28+
public BlockingListEnumerator(IList<T> inner, object @lock)
29+
{
30+
m_Inner = inner;
31+
m_Lock = @lock;
32+
m_Pos = -1;
33+
}
3534

3635
public void Dispose()
3736
{

src/Files.App/Helpers/StorageItemCollection/BulkConcurrentObservableCollection.cs renamed to src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs

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

4-
using Files.Shared.Extensions;
5-
using System;
6-
using System.Collections;
7-
using System.Collections.Generic;
84
using System.Collections.Specialized;
9-
using System.ComponentModel;
10-
using System.Diagnostics;
11-
using System.Linq;
12-
using System.Threading;
135

14-
namespace Files.App.Helpers
6+
namespace Files.App.Utils.Storage
157
{
168
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
179
[DebuggerDisplay("Count = {Count}")]

src/Files.App/Helpers/StorageItemCollection/ConcurrentCollection.cs renamed to src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Files.App.Helpers
88
public class ConcurrentCollection<T> : ICollection<T>, IList<T>, ICollection, IList
99
{
1010
private readonly object syncRoot = new object();
11+
1112
private readonly List<T> collection = new List<T>();
1213

1314
public int Count
@@ -231,6 +232,7 @@ public void Sort(Comparison<T> comparison)
231232
public void Order(Func<List<T>, IEnumerable<T>> func)
232233
{
233234
IEnumerable<T> result;
235+
234236
lock (syncRoot)
235237
{
236238
result = func.Invoke(collection);
@@ -242,12 +244,14 @@ public void Order(Func<List<T>, IEnumerable<T>> func)
242244
public void OrderOne(Func<List<T>, IEnumerable<T>> func, T item)
243245
{
244246
IList<T> result;
247+
245248
lock (syncRoot)
246249
{
247250
result = func.Invoke(collection).ToList();
248251
}
249252

250253
Remove(item);
254+
251255
var index = result.IndexOf(item);
252256
if (index != -1)
253257
Insert(index, item);

0 commit comments

Comments
 (0)