optimization for initial file list

This commit is contained in:
Bitl 2022-07-29 16:42:59 -07:00
parent c01b4965aa
commit cc14235219
2 changed files with 40 additions and 3 deletions

View File

@ -2920,21 +2920,56 @@ public class GlobalFuncs
public static void CreateInitialFileListIfNeededMulti()
{
if (!File.Exists(GlobalPaths.ConfigDir + "\\InitialFileList.txt"))
string filePath = GlobalPaths.ConfigDir + "\\InitialFileList.txt";
if (!File.Exists(filePath))
{
Thread t = new Thread(CreateInitialFileList);
t.Start();
}
else
{
int lineCount = File.ReadLines(filePath).Count();
int fileCount = 0;
string filterPath = GlobalPaths.ConfigDir + @"\\" + GlobalPaths.InitialFileListIgnoreFilterName;
string[] fileListToIgnore = File.ReadAllLines(filterPath);
DirectoryInfo dinfo = new DirectoryInfo(GlobalPaths.RootPath);
FileInfo[] Files = dinfo.GetFiles("*.*", SearchOption.AllDirectories);
foreach (FileInfo file in Files)
{
DirectoryInfo localdinfo = new DirectoryInfo(file.DirectoryName);
string directory = localdinfo.Name;
if (!fileListToIgnore.Contains(file.Name, StringComparer.InvariantCultureIgnoreCase) && !fileListToIgnore.Contains(directory, StringComparer.InvariantCultureIgnoreCase))
{
fileCount++;
}
else
{
continue;
}
}
//MessageBox.Show(lineCount + "\n" + fileCount);
if (lineCount != fileCount)
{
Thread t = new Thread(CreateInitialFileList);
t.Start();
}
}
}
private static void CreateInitialFileList()
{
string filterPath = GlobalPaths.ConfigDir + @"\\" + GlobalPaths.InitialFileListIgnoreFilterName;
string[] fileListToIgnore = File.ReadAllLines(filterPath);
string FileName = GlobalPaths.ConfigDir + "\\InitialFileList.txt";
using (var txt = File.CreateText(GlobalPaths.ConfigDir + "\\InitialFileList.txt"))
using (var txt = File.CreateText(FileName))
{
DirectoryInfo dinfo = new DirectoryInfo(GlobalPaths.BasePath);
DirectoryInfo dinfo = new DirectoryInfo(GlobalPaths.RootPath);
FileInfo[] Files = dinfo.GetFiles("*.*", SearchOption.AllDirectories);
foreach (FileInfo file in Files)
{

View File

@ -40,6 +40,8 @@ public partial class NovetusSDK : Form
#region Form Events
private void NovetusSDK_Load(object sender, EventArgs e)
{
GlobalFuncs.CreateInitialFileListIfNeededMulti();
if (!File.Exists(GlobalPaths.DataDir + "\\RSG.exe"))
{
DisableApp(SDKApps.ScriptGenerator);