Simplified GetDirectoryInfoCollection

This commit is contained in:
2022-08-14 10:42:28 -07:00
parent 0392de1920
commit b756859b61
12 changed files with 556 additions and 360 deletions

View File

@ -255,7 +255,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
{
List<D_Face> results = new();
if (_Configuration.PaddingLoops is null)
throw new Exception();
throw new NullReferenceException(nameof(_Configuration.PaddingLoops));
if (item.ImageFileHolder is null)
throw new NullReferenceException(nameof(item.ImageFileHolder));
if (_Configuration.NumberOfJitters is null)
@ -412,13 +412,17 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
_Populated = populated;
}
internal List<D_Face> GetFaces(Property.Models.Configuration configuration, string outputResolution, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Item item, A_Property property, FileHolder resizedFileHolder, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation)
internal List<D_Face> GetFaces(string dResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Item item, A_Property property, FileHolder resizedFileHolder, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation)
{
List<D_Face>? results;
if (item.Property?.Id is null)
throw new NullReferenceException(nameof(item.Property.Id));
if (_Configuration.PropertiesChangedForFaces is null)
throw new Exception();
throw new NullReferenceException(nameof(_Configuration.PropertiesChangedForFaces));
if (item.ImageFileHolder is null)
throw new NullReferenceException(nameof(item.ImageFileHolder));
if (string.IsNullOrEmpty(dResultsFullGroupDirectory))
throw new NullReferenceException(nameof(dResultsFullGroupDirectory));
string json;
D_Face face;
bool checkForOutputResolutionChange = false;
@ -426,13 +430,30 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "[]"), $"{item.ImageFileHolder.NameWithoutExtension}.json"));
if (!fileInfo.Exists)
string dCollectionFile = Path.Combine(dResultsFullGroupDirectory, "[]", "_ _ _", $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}.json");
if (fileInfo.Exists)
{
if (fileInfo.Directory?.Parent is null)
throw new Exception();
string parentCheck = Path.Combine(fileInfo.Directory.Parent.FullName, fileInfo.Name);
if (File.Exists(parentCheck))
File.Delete(parentCheck);
if (!File.Exists(dCollectionFile))
{
fileInfo.MoveTo(dCollectionFile);
fileInfo = new(dCollectionFile);
}
}
else
{
if (File.Exists(dCollectionFile))
fileInfo = new(dCollectionFile);
else
{
if (fileInfo.Directory?.Parent is null)
throw new Exception();
string parentCheck = Path.Combine(fileInfo.Directory.Parent.FullName, fileInfo.Name);
if (File.Exists(parentCheck))
{
File.Move(parentCheck, fileInfo.FullName);
fileInfo.Refresh();
}
}
}
if (!Directory.Exists(facesDirectory))
_ = Directory.CreateDirectory(facesDirectory);
@ -487,14 +508,16 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
return results;
}
internal void SaveFaces(Property.Models.Configuration configuration, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Item item, List<D_Face> faceCollection)
internal void SaveFaces(string dResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Item item, List<D_Face> faceCollection)
{
if (_Configuration.OverrideForFaceImages is null)
throw new Exception();
throw new NullReferenceException(nameof(_Configuration.OverrideForFaceImages));
if (item.ImageFileHolder is null)
throw new NullReferenceException(nameof(item.ImageFileHolder));
if (item.ResizedFileHolder is null)
throw new NullReferenceException(nameof(item.ResizedFileHolder));
if (string.IsNullOrEmpty(dResultsFullGroupDirectory))
throw new NullReferenceException(nameof(dResultsFullGroupDirectory));
FileInfo fileInfo;
bool check = false;
string parentCheck;
@ -533,7 +556,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
SaveFaces(faceCollection, item.ResizedFileHolder, imageFiles);
}
internal static void SaveShortcuts(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string[] juliePhares, long ticks, Dictionary<string, List<Person>> peopleCollection, PropertyLogic propertyLogic, string outputResolution, Item[] filteredItems)
internal static void SaveShortcuts(string[] juliePhares, string dResultsFullGroupDirectory, long ticks, Dictionary<string, List<Person>> peopleCollection, PropertyLogic propertyLogic, Item[] filteredItems)
{
Person person;
string fileName;
@ -541,7 +564,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
DateTime? minimumDateTime;
WindowsShortcut windowsShortcut;
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), $"({ticks})");
string dFacesContentDirectory = Path.Combine(dResultsFullGroupDirectory, $"({ticks})");
List<(Item, (string, Shared.Models.Properties.IFace?, (string, string, string, string))[])> collections = Item.GetCollection(propertyLogic, filteredItems, dFacesContentDirectory);
foreach ((Item item, (string personKey, Shared.Models.Properties.IFace? _, (string, string, string, string))[] collection) in collections)
{