mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Add custom context menu setting for findfile plugin and improve the search speed.
This commit is contained in:
@@ -39,7 +39,7 @@ namespace Wox.Plugin.FindFile.MFTSearch
|
||||
{
|
||||
if (string.IsNullOrEmpty(item)) return new List<MFTSearchRecord>();
|
||||
|
||||
List<USNRecord> found = cache.FindByName(item);
|
||||
List<USNRecord> found = cache.FindByName(item,100);
|
||||
found.ForEach(x => FillPath(x.VolumeName, x, cache));
|
||||
return found.ConvertAll(o => new MFTSearchRecord(o));
|
||||
}
|
||||
|
||||
@@ -71,17 +71,22 @@ namespace Wox.Plugin.FindFile.MFTSearch
|
||||
}
|
||||
}
|
||||
|
||||
public List<USNRecord> FindByName(string filename)
|
||||
public List<USNRecord> FindByName(string filename, long maxResult = -1)
|
||||
{
|
||||
filename = filename.ToLower();
|
||||
var fileQuery = from filesInVolumeDic in VolumeRecords.Values
|
||||
from eachFilePair in filesInVolumeDic
|
||||
where eachFilePair.Value.Name.ToLower().Contains(filename)
|
||||
select eachFilePair.Value;
|
||||
|
||||
List<USNRecord> result = new List<USNRecord>();
|
||||
|
||||
result.AddRange(fileQuery);
|
||||
foreach (Dictionary<ulong, USNRecord> dictionary in VolumeRecords.Values)
|
||||
{
|
||||
foreach (var usnRecord in dictionary)
|
||||
{
|
||||
if (usnRecord.Value.Name.IndexOf(filename, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
{
|
||||
result.Add(usnRecord.Value);
|
||||
if (maxResult > 0 && result.Count() >= maxResult) break;
|
||||
}
|
||||
if (maxResult > 0 && result.Count() >= maxResult) break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user