Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preemptive caching #2944

Merged
merged 33 commits into from
Feb 14, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
36eebd1
Merge pull request #1 from files-community/master
jakoss Dec 21, 2020
015ec81
Merge remote-tracking branch 'upstream/master'
jakoss Dec 23, 2020
b81ac01
Merge remote-tracking branch 'upstream/master'
jakoss Dec 28, 2020
1f8cd4b
Merge remote-tracking branch 'upstream/master'
jakoss Dec 29, 2020
fb837b9
Merge remote-tracking branch 'upstream/master'
jakoss Jan 7, 2021
bd8d18e
Merge remote-tracking branch 'upstream/master'
jakoss Jan 12, 2021
cab1dc6
Refactor Win32 storage enumeration into clean functions
jakoss Jan 12, 2021
cc09ff9
Refactor universal storage enumeration into clean functions
jakoss Jan 12, 2021
7d84025
Refactor universal items enumerator to batch reads
jakoss Jan 12, 2021
c78b455
Add preemptive caching
jakoss Jan 12, 2021
b8656ab
Fix crash on quicks forward navigation
jakoss Jan 12, 2021
931db91
Fix few styling issues
jakoss Jan 12, 2021
bfa8fbb
Add preemptive parallel limit setting
jakoss Jan 12, 2021
b944fc9
Merge remote-tracking branch 'upstream/master'
jakoss Jan 13, 2021
b6e9e8b
Merge branch 'master' into preemptive-caching
jakoss Jan 13, 2021
94c3947
Minor ui adjustements
jakoss Jan 13, 2021
f393b72
Update Files/Views/SettingsPages/Experimental.xaml
yaira2 Jan 13, 2021
741cf40
Update Files/Views/SettingsPages/Experimental.xaml
yaira2 Jan 13, 2021
091f5af
Merge remote-tracking branch 'upstream/master'
jakoss Jan 15, 2021
8ca2469
Merge branch 'master' into preemptive-caching
jakoss Jan 15, 2021
7a598ab
Style update
jakoss Jan 15, 2021
3877ba1
Merge remote-tracking branch 'upstream/main' into preemptive-caching
jakoss Jan 31, 2021
03a2481
Tackle the crash on startup issue
jakoss Jan 31, 2021
2a5e708
Cache only initial burst (32 items)
jakoss Jan 31, 2021
6c7f1b0
Merge remote-tracking branch 'upstream/main' into preemptive-caching
jakoss Feb 3, 2021
b5cb0c9
Merge remote-tracking branch 'upstream/main' into preemptive-caching
jakoss Feb 3, 2021
a30900f
Adjust settings
jakoss Feb 3, 2021
6b20e05
Merge main
gave92 Feb 14, 2021
353e6f5
[Missing: date created, localized name] Fix merge confict
gave92 Feb 14, 2021
6462b41
Merge remote-tracking branch 'origin/main' into rev_preemptive
gave92 Feb 14, 2021
14f091b
Add back creationdate
gave92 Feb 14, 2021
75f9a42
Turn off caching by default
gave92 Feb 14, 2021
f2e1f9a
Update Files/ViewModels/SettingsViewModel.cs
gave92 Feb 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion Files/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;

namespace Files.Extensions
{
Expand All @@ -12,5 +15,29 @@ internal static class EnumerableExtensions
/// <returns><see cref="IEnumerable{T}"/> with <paramref name="item"/></returns>
internal static IEnumerable<T> CreateEnumerable<T>(this T item) =>
new List<T>() { item };

/// <summary>
/// Executes given lambda parallely on given data set with max degree of parallelism set up
/// </summary>
/// <typeparam name="T">The item type</typeparam>
/// <param name="source">Data to process</param>
/// <param name="body">Lambda to execute on all items</param>
/// <param name="maxDegreeOfParallelism">Max degree of parallelism (-1 for unbounded execution)</param>
/// <returns></returns>
internal static Task AsyncParallelForEach<T>(this IEnumerable<T> source, Func<T, Task> body, int maxDegreeOfParallelism)
{
var options = new ExecutionDataflowBlockOptions
{
MaxDegreeOfParallelism = maxDegreeOfParallelism
};

var block = new ActionBlock<T>(body, options);

foreach (var item in source)
block.Post(item);

block.Complete();
return block.Completion;
}
}
}
21 changes: 21 additions & 0 deletions Files/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Threading.Tasks;

namespace Files.Extensions
{
internal static class TaskExtensions
{
#pragma warning disable RCS1175 // Unused this parameter.
#pragma warning disable IDE0060 // Remove unused parameter
/// <summary>
/// This function is to explicitly state that we know that we're runnign task without awaiting.
/// This makes visual studio to drop warning, but the programmer intent is still clearly stated.
/// </summary>
/// <param name="task"></param>
internal static void Forget(this Task task)
{
// do nothing, just forget about the task
}
#pragma warning restore IDE0060 // Remove unused parameter
#pragma warning restore RCS1175 // Unused this parameter.
}
}
6 changes: 5 additions & 1 deletion Files/Files.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@
<Compile Include="Converters\UInt32ToString.cs" />
<Compile Include="DataModels\ShellNewEntry.cs" />
<Compile Include="Enums\FolderLayoutModes.cs" />
<Compile Include="Extensions\TaskExtensions.cs" />
<Compile Include="Filesystem\FolderHelpers.cs" />
<Compile Include="Filesystem\StorageEnumerators\UniversalStorageEnumerator.cs" />
<Compile Include="Filesystem\StorageEnumerators\Win32StorageEnumerator.cs" />
<Compile Include="Helpers\AppUpdater.cs" />
<Compile Include="DataModels\DefaultLanguageModel.cs" />
<Compile Include="Enums\FileOperationType.cs" />
Expand Down Expand Up @@ -947,4 +951,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ await DialogDisplayHelper.ShowDialogAsync(
}
if (fsCopyResult)
{
if (associatedInstance.FilesystemViewModel.CheckFolderForHiddenAttribute(source.Path))
if (FolderHelpers.CheckFolderForHiddenAttribute(source.Path))
{
// The source folder was hidden, apply hidden attribute to destination
NativeFileOperationsHelper.SetFileAttribute(fsCopyResult.Result.Path, FileAttributes.Hidden);
Expand Down
60 changes: 60 additions & 0 deletions Files/Filesystem/FolderHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;
using static Files.Helpers.NativeFindStorageItemHelper;
using FileAttributes = System.IO.FileAttributes;

namespace Files.Filesystem
{
public static class FolderHelpers
{
public static bool CheckFolderAccessWithWin32(string path)
{
FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS.FindExInfoBasic;
int additionalFlags = FIND_FIRST_EX_LARGE_FETCH;
IntPtr hFileTsk = FindFirstFileExFromApp(path + "\\*.*", findInfoLevel, out WIN32_FIND_DATA findDataTsk, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero,
additionalFlags);
if (hFileTsk.ToInt64() != -1)
{
FindClose(hFileTsk);
return true;
}
return false;
}

public static bool CheckFolderForHiddenAttribute(string path)
{
if (string.IsNullOrEmpty(path))
{
return false;
}
FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS.FindExInfoBasic;
int additionalFlags = FIND_FIRST_EX_LARGE_FETCH;
IntPtr hFileTsk = FindFirstFileExFromApp(path + "\\*.*", findInfoLevel, out WIN32_FIND_DATA findDataTsk, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero,
additionalFlags);
if (hFileTsk.ToInt64() == -1)
{
return false;
}
var isHidden = ((FileAttributes)findDataTsk.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden;
FindClose(hFileTsk);
return isHidden;
}

public static async Task<bool> CheckBitlockerStatusAsync(StorageFolder rootFolder, string path)
{
if (rootFolder == null || rootFolder.Properties == null)
{
return false;
}
if (Path.IsPathRooted(path) && Path.GetPathRoot(path) == path)
{
IDictionary<string, object> extraProperties = await rootFolder.Properties.RetrievePropertiesAsync(new string[] { "System.Volume.BitLockerProtection" });
return (int?)extraProperties["System.Volume.BitLockerProtection"] == 6; // Drive is bitlocker protected and locked
}
return false;
}
}
}
Loading