Added FileHolder
This commit is contained in:
@ -116,14 +116,14 @@ public static class A_Property
|
||||
return results;
|
||||
}
|
||||
|
||||
public static List<(int g, string sourceDirectory, FileInfo[] sourceDirectoryFiles, int r)> GetFileInfoGroupCollection(Models.Configuration configuration, bool reverse, string searchPattern, List<string> topDirectories)
|
||||
public static List<(int g, string sourceDirectory, FileHolder[] sourceDirectoryFiles, int r)> GetFileHolderGroupCollection(Models.Configuration configuration, bool reverse, string searchPattern, List<string> topDirectories)
|
||||
{
|
||||
if (configuration.MaxImagesInDirectoryForTopLevelFirstPass is null)
|
||||
throw new ArgumentNullException(nameof(configuration.MaxImagesInDirectoryForTopLevelFirstPass));
|
||||
List<(int g, string sourceDirectory, FileInfo[] sourceDirectoryFiles, int r)> results = new();
|
||||
List<(int g, string sourceDirectory, FileHolder[] sourceDirectoryFiles, int r)> results = new();
|
||||
List<(int g, string sourceDirectory, string[] sourceDirectoryFiles, int r)>? collection = GetGroupCollection(configuration.RootDirectory, searchPattern, topDirectories, configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value, reverse);
|
||||
foreach ((int g, string sourceDirectory, string[] sourceDirectoryFiles, int r) in collection)
|
||||
results.Add(new(g, sourceDirectory, (from l in sourceDirectoryFiles select new FileInfo(l)).ToArray(), r));
|
||||
results.Add(new(g, sourceDirectory, (from l in sourceDirectoryFiles select new FileHolder(l)).ToArray(), r));
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ public static class A_Property
|
||||
return results;
|
||||
}
|
||||
|
||||
private static List<PropertyHolder[]> Populate(Models.Configuration configuration, string aPropertySingletonDirectory, List<(int, string, FileInfo[], int)> fileInfoGroupCollection, List<(int, string, List<(string, Models.A_Property?)>, int)> collectionFromJson)
|
||||
private static List<PropertyHolder[]> Populate(Models.Configuration configuration, string aPropertySingletonDirectory, List<(int, string, FileHolder[], int)> fileHolderGroupCollection, List<(int, string, List<(string, Models.A_Property?)>, int)> collectionFromJson)
|
||||
{
|
||||
List<PropertyHolder[]> results = new();
|
||||
if (configuration.PropertiesChangedForProperty is null)
|
||||
@ -144,17 +144,17 @@ public static class A_Property
|
||||
int length;
|
||||
string inferred;
|
||||
string relativePath;
|
||||
FileInfo keyFileInfo;
|
||||
FileHolder keyFileHolder;
|
||||
string keySourceDirectory;
|
||||
List<PropertyHolder> propertyHolderCollection;
|
||||
Dictionary<string, (string SourceDirectory, FileInfo FileInfo)> fileInfoKeyValuePairs = new();
|
||||
Dictionary<string, (string SourceDirectory, FileHolder FileHolder)> fileHolderKeyValuePairs = new();
|
||||
length = configuration.RootDirectory.Length;
|
||||
foreach ((int g, string sourceDirectory, FileInfo[] sourceDirectoryFileInfoCollection, int r) in fileInfoGroupCollection)
|
||||
foreach ((int g, string sourceDirectory, FileHolder[] sourceDirectoryFileHolderCollection, int r) in fileHolderGroupCollection)
|
||||
{
|
||||
foreach (FileInfo sourceDirectoryFileInfo in sourceDirectoryFileInfoCollection)
|
||||
foreach (FileHolder sourceDirectoryFileHolder in sourceDirectoryFileHolderCollection)
|
||||
{
|
||||
relativePath = $"{XPath.GetRelativePath(sourceDirectoryFileInfo.FullName, length)}.json";
|
||||
fileInfoKeyValuePairs.Add(relativePath, new(sourceDirectory, sourceDirectoryFileInfo));
|
||||
relativePath = $"{XPath.GetRelativePath(sourceDirectoryFileHolder.FullName, length)}.json";
|
||||
fileHolderKeyValuePairs.Add(relativePath, new(sourceDirectory, sourceDirectoryFileHolder));
|
||||
}
|
||||
}
|
||||
length = aPropertySingletonDirectory.Length;
|
||||
@ -166,53 +166,53 @@ public static class A_Property
|
||||
foreach ((string sourceDirectoryFile, Models.A_Property? property) in collection)
|
||||
{
|
||||
relativePath = XPath.GetRelativePath(sourceDirectoryFile, length);
|
||||
if (!fileInfoKeyValuePairs.ContainsKey(relativePath))
|
||||
if (!fileHolderKeyValuePairs.ContainsKey(relativePath))
|
||||
{
|
||||
inferred = string.Concat(configuration.RootDirectory, relativePath);
|
||||
keyFileInfo = new(inferred[..^5]);
|
||||
if (keyFileInfo.Extension is ".json")
|
||||
keyFileHolder = new(inferred[..^5]);
|
||||
if (keyFileHolder.Extension is ".json")
|
||||
continue;
|
||||
keySourceDirectory = string.Concat(keyFileInfo.DirectoryName);
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, true, null, null, null));
|
||||
keySourceDirectory = string.Concat(keyFileHolder.DirectoryName);
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileHolder, property, true, null, null, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
keyFileInfo = fileInfoKeyValuePairs[relativePath].FileInfo;
|
||||
keySourceDirectory = fileInfoKeyValuePairs[relativePath].SourceDirectory;
|
||||
if (!fileInfoKeyValuePairs.Remove(relativePath))
|
||||
keyFileHolder = fileHolderKeyValuePairs[relativePath].FileHolder;
|
||||
keySourceDirectory = fileHolderKeyValuePairs[relativePath].SourceDirectory;
|
||||
if (!fileHolderKeyValuePairs.Remove(relativePath))
|
||||
throw new Exception();
|
||||
if (keyFileInfo.Extension is ".json")
|
||||
if (keyFileHolder.Extension is ".json")
|
||||
continue;
|
||||
if (property?.Id is null || property?.Width is null || property?.Height is null)
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, null, null, null));
|
||||
else if (configuration.PropertiesChangedForProperty.Value || property.LastWriteTime != keyFileInfo.LastWriteTime || property.FileSize != keyFileInfo.Length)
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, true, null, null));
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileHolder, property, false, null, null, null));
|
||||
else if (configuration.PropertiesChangedForProperty.Value || property.LastWriteTime != keyFileHolder.LastWriteTime || property.FileSize != keyFileHolder.Length)
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileHolder, property, false, true, null, null));
|
||||
else
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, false, null, null));
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileHolder, property, false, false, null, null));
|
||||
}
|
||||
}
|
||||
if (propertyHolderCollection.Any())
|
||||
results.Add(propertyHolderCollection.ToArray());
|
||||
}
|
||||
length = configuration.RootDirectory.Length;
|
||||
foreach ((int g, string sourceDirectory, FileInfo[] sourceDirectoryFileInfoCollection, int r) in fileInfoGroupCollection)
|
||||
foreach ((int g, string sourceDirectory, FileHolder[] sourceDirectoryFileHolderCollection, int r) in fileHolderGroupCollection)
|
||||
{
|
||||
propertyHolderCollection = new();
|
||||
foreach (FileInfo sourceDirectoryFileInfo in sourceDirectoryFileInfoCollection)
|
||||
foreach (FileHolder sourceDirectoryFileHolder in sourceDirectoryFileHolderCollection)
|
||||
{
|
||||
relativePath = $"{XPath.GetRelativePath(sourceDirectoryFileInfo.FullName, length)}.json";
|
||||
if (!fileInfoKeyValuePairs.ContainsKey(relativePath))
|
||||
relativePath = $"{XPath.GetRelativePath(sourceDirectoryFileHolder.FullName, length)}.json";
|
||||
if (!fileHolderKeyValuePairs.ContainsKey(relativePath))
|
||||
continue;
|
||||
if (!fileInfoKeyValuePairs.Remove(relativePath))
|
||||
if (!fileHolderKeyValuePairs.Remove(relativePath))
|
||||
throw new Exception();
|
||||
if (sourceDirectoryFileInfo.Extension is ".json")
|
||||
if (sourceDirectoryFileHolder.Extension is ".json")
|
||||
continue;
|
||||
propertyHolderCollection.Add(new(g, sourceDirectory, relativePath, sourceDirectoryFileInfo.FullName, r, sourceDirectoryFileInfo, null, null, null, null, null));
|
||||
propertyHolderCollection.Add(new(g, sourceDirectory, relativePath, sourceDirectoryFileHolder.FullName, r, sourceDirectoryFileHolder, null, null, null, null, null));
|
||||
}
|
||||
if (propertyHolderCollection.Any())
|
||||
results.Add(propertyHolderCollection.ToArray());
|
||||
}
|
||||
if (fileInfoKeyValuePairs.Any())
|
||||
if (fileHolderKeyValuePairs.Any())
|
||||
throw new Exception();
|
||||
results = (from l in results orderby l[0].G, l[0].R select l).ToList();
|
||||
return results;
|
||||
@ -243,13 +243,13 @@ public static class A_Property
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
List<string> topDirectories = new();
|
||||
List<(int g, string sourceDirectory, string[] sourceDirectoryFiles, int r)> jsonCollection;
|
||||
List<(int g, string sourceDirectory, FileInfo[] sourceDirectoryFiles, int r)> fileInfoGroupCollection;
|
||||
List<(int g, string sourceDirectory, FileHolder[] sourceDirectoryFiles, int r)> fileHolderGroupCollection;
|
||||
string aPropertySingletonDirectory = IResult.GetResultsDateGroupDirectory(configuration, nameof(A_Property), "{}");
|
||||
List<(int g, string sourceDirectory, List<(string sourceDirectoryFile, Models.A_Property? property)> collection, int r)> collectionFromJson;
|
||||
jsonCollection = GetJsonGroupCollection(aPropertySingletonDirectory);
|
||||
fileInfoGroupCollection = GetFileInfoGroupCollection(configuration, reverse, searchPattern, topDirectories);
|
||||
fileHolderGroupCollection = GetFileHolderGroupCollection(configuration, reverse, searchPattern, topDirectories);
|
||||
collectionFromJson = GetCollection(aPropertySingletonDirectory, jsonCollection);
|
||||
results = Populate(configuration, aPropertySingletonDirectory, fileInfoGroupCollection, collectionFromJson);
|
||||
results = Populate(configuration, aPropertySingletonDirectory, fileHolderGroupCollection, collectionFromJson);
|
||||
propertyLogic.ParallelWork(configuration, model, predictorModel, ticks, results, firstPass: false);
|
||||
if (propertyLogic.ExceptionsDirectories.Any())
|
||||
throw new Exception();
|
||||
|
Reference in New Issue
Block a user