Added FileHolder
This commit is contained in:
@ -3,25 +3,25 @@ namespace View_by_Distance.Property.Models;
|
||||
public class DirectoryInfo
|
||||
{
|
||||
|
||||
protected readonly FileInfo[] _SourceDirectoryFileInfoCollection;
|
||||
protected readonly FileHolder[] _SourceDirectoryFileHolderCollection;
|
||||
protected readonly string[] _FilteredSourceDirectoryFiles;
|
||||
protected readonly int _G;
|
||||
protected readonly bool[] _Moved;
|
||||
protected readonly bool?[] _Changed;
|
||||
protected readonly A_Property?[] _PropertyCollection;
|
||||
protected readonly FileInfo?[] _PropertyFileInfoCollection;
|
||||
protected readonly FileInfo?[] _PropertyFileHolderCollection;
|
||||
protected readonly int _R;
|
||||
protected readonly string _SourceDirectory;
|
||||
protected readonly bool[] _ValidImageFormatExtensionCollection;
|
||||
protected readonly bool[] _WrongYear;
|
||||
public FileInfo[] SourceDirectoryFileInfoCollection => _SourceDirectoryFileInfoCollection;
|
||||
[Obsolete($"Use {nameof(SourceDirectoryFileInfoCollection)}")]
|
||||
public FileHolder[] SourceDirectoryFileHolderCollection => _SourceDirectoryFileHolderCollection;
|
||||
[Obsolete($"Use {nameof(SourceDirectoryFileHolderCollection)}")]
|
||||
public string[] FilteredSourceDirectoryFiles => _FilteredSourceDirectoryFiles;
|
||||
public int G => _G;
|
||||
public bool[] Moved => _Moved;
|
||||
public bool?[] Changed => _Changed;
|
||||
public A_Property?[] PropertyCollection => _PropertyCollection;
|
||||
public FileInfo?[] PropertyFileInfoCollection => _PropertyFileInfoCollection;
|
||||
public FileInfo?[] PropertyFileHolderCollection => _PropertyFileHolderCollection;
|
||||
public int R => _R;
|
||||
public string SourceDirectory => _SourceDirectory;
|
||||
public bool[] ValidImageFormatExtensionCollection => _ValidImageFormatExtensionCollection;
|
||||
@ -39,8 +39,8 @@ public class DirectoryInfo
|
||||
_FilteredSourceDirectoryFiles = filteredSourceDirectoryFiles;
|
||||
_PropertyCollection = Enumerable.Repeat<A_Property?>(null, length).ToArray();
|
||||
_ValidImageFormatExtensionCollection = Enumerable.Repeat(false, length).ToArray();
|
||||
_PropertyFileInfoCollection = Enumerable.Repeat<FileInfo?>(null, length).ToArray();
|
||||
_SourceDirectoryFileInfoCollection = (from l in filteredSourceDirectoryFiles select new FileInfo(l)).ToArray();
|
||||
_PropertyFileHolderCollection = Enumerable.Repeat<FileInfo?>(null, length).ToArray();
|
||||
_SourceDirectoryFileHolderCollection = (from l in filteredSourceDirectoryFiles select new FileHolder(l)).ToArray();
|
||||
}
|
||||
|
||||
}
|
70
Property/Models/FileHolder.cs
Normal file
70
Property/Models/FileHolder.cs
Normal file
@ -0,0 +1,70 @@
|
||||
namespace View_by_Distance.Property.Models;
|
||||
|
||||
public class FileHolder
|
||||
{
|
||||
protected readonly DateTime _CreationTime;
|
||||
protected readonly string? _DirectoryName;
|
||||
protected readonly bool _Exists;
|
||||
protected readonly string _Extension;
|
||||
protected readonly string _FullName;
|
||||
protected readonly DateTime _LastWriteTime;
|
||||
protected readonly long? _Length;
|
||||
protected readonly string _Name;
|
||||
protected readonly string _NameWithoutExtension;
|
||||
public DateTime CreationTime => _CreationTime;
|
||||
public string? DirectoryName => _DirectoryName;
|
||||
public bool Exists => _Exists;
|
||||
public string Extension => _Extension;
|
||||
public string FullName => _FullName;
|
||||
public DateTime LastWriteTime => _LastWriteTime;
|
||||
public long? Length => _Length;
|
||||
public string Name => _Name;
|
||||
public string NameWithoutExtension => _NameWithoutExtension;
|
||||
|
||||
public FileHolder(DateTime creationTime, string? directoryName, bool exists, string extension, string fullName, DateTime lastWriteTime, long? length, string name, string nameWithoutExtension)
|
||||
{
|
||||
_CreationTime = creationTime;
|
||||
_DirectoryName = directoryName;
|
||||
_Exists = exists;
|
||||
_Extension = extension;
|
||||
_FullName = fullName;
|
||||
_LastWriteTime = lastWriteTime;
|
||||
_Length = length;
|
||||
_Name = name;
|
||||
_NameWithoutExtension = nameWithoutExtension;
|
||||
}
|
||||
|
||||
public FileHolder(string fileName)
|
||||
{
|
||||
FileInfo fileInfo = new(fileName);
|
||||
_CreationTime = fileInfo.CreationTime;
|
||||
_CreationTime = fileInfo.CreationTime;
|
||||
_DirectoryName = fileInfo.DirectoryName;
|
||||
_Exists = fileInfo.Exists;
|
||||
_Extension = fileInfo.Extension;
|
||||
_FullName = fileInfo.FullName;
|
||||
_LastWriteTime = fileInfo.LastWriteTime;
|
||||
if (fileInfo.Exists)
|
||||
_Length = fileInfo.Length;
|
||||
_Name = fileInfo.Name;
|
||||
_NameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
||||
}
|
||||
|
||||
public FileHolder(FileInfo fileInfo)
|
||||
{
|
||||
_CreationTime = fileInfo.CreationTime;
|
||||
_CreationTime = fileInfo.CreationTime;
|
||||
_DirectoryName = fileInfo.DirectoryName;
|
||||
_Exists = fileInfo.Exists;
|
||||
_Extension = fileInfo.Extension;
|
||||
_FullName = fileInfo.FullName;
|
||||
_LastWriteTime = fileInfo.LastWriteTime;
|
||||
if (fileInfo.Exists)
|
||||
_Length = fileInfo.Length;
|
||||
_Name = fileInfo.Name;
|
||||
_NameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
||||
}
|
||||
|
||||
public static FileHolder Refresh(FileHolder fileHolder) => new(fileHolder.FullName);
|
||||
|
||||
}
|
@ -10,7 +10,7 @@ public class PropertyHolder
|
||||
protected readonly bool? _Abandoned;
|
||||
protected readonly bool? _Changed;
|
||||
protected List<IFace> _Faces;
|
||||
protected readonly FileInfo? _ImageFileInfo;
|
||||
protected readonly FileHolder? _ImageFileHolder;
|
||||
protected readonly string _ImageFileNameWithoutExtension;
|
||||
protected readonly int _G;
|
||||
protected DateTime? _MinimumDateTime;
|
||||
@ -20,14 +20,14 @@ public class PropertyHolder
|
||||
protected A_Property? _Property;
|
||||
protected readonly int _R;
|
||||
protected readonly string _RelativePath;
|
||||
protected FileInfo? _ResizedFileInfo;
|
||||
protected FileHolder? _ResizedFileHolder;
|
||||
protected readonly string _SourceDirectory;
|
||||
protected readonly string _SourceDirectoryFile;
|
||||
protected bool? _ValidImageFormatExtension;
|
||||
public bool? Abandoned => _Abandoned;
|
||||
public bool? Changed => _Changed;
|
||||
public List<IFace> Faces => _Faces;
|
||||
public FileInfo? ImageFileInfo => _ImageFileInfo;
|
||||
public FileHolder? ImageFileHolder => _ImageFileHolder;
|
||||
public string ImageFileNameWithoutExtension => _ImageFileNameWithoutExtension;
|
||||
public int G => _G;
|
||||
public DateTime? MinimumDateTime => _MinimumDateTime;
|
||||
@ -37,7 +37,7 @@ public class PropertyHolder
|
||||
public A_Property? Property => _Property;
|
||||
public int R => _R;
|
||||
public string RelativePath => _RelativePath;
|
||||
public FileInfo? ResizedFileInfo => _ResizedFileInfo;
|
||||
public FileHolder? ResizedFileHolder => _ResizedFileHolder;
|
||||
public string SourceDirectory => _SourceDirectory;
|
||||
public string SourceDirectoryFile => _SourceDirectoryFile;
|
||||
public bool? ValidImageFormatExtension => _ValidImageFormatExtension;
|
||||
@ -55,7 +55,7 @@ public class PropertyHolder
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public PropertyHolder(int g, string sourceDirectory, string sourceDirectoryFile, string relativePath, int r, FileInfo? imageFileInfo, A_Property? property, bool? abandoned, bool? changed, bool? moved, bool? validImageFormatExtension)
|
||||
public PropertyHolder(int g, string sourceDirectory, string sourceDirectoryFile, string relativePath, int r, FileHolder? imageFileInfo, A_Property? property, bool? abandoned, bool? changed, bool? moved, bool? validImageFormatExtension)
|
||||
{
|
||||
_G = g;
|
||||
_R = r;
|
||||
@ -67,7 +67,7 @@ public class PropertyHolder
|
||||
_Abandoned = abandoned;
|
||||
_NoJson = abandoned is null;
|
||||
_RelativePath = relativePath;
|
||||
_ImageFileInfo = imageFileInfo;
|
||||
_ImageFileHolder = imageFileInfo;
|
||||
_SourceDirectory = sourceDirectory;
|
||||
_SourceDirectoryFile = sourceDirectoryFile;
|
||||
_ValidImageFormatExtension = validImageFormatExtension;
|
||||
@ -88,7 +88,7 @@ public class PropertyHolder
|
||||
|
||||
public static string GetWrongYearFlag(bool? isWrongYear) => isWrongYear is null ? "#" : isWrongYear.Value ? "~" : "=";
|
||||
|
||||
public void SetResizedFileInfo(FileInfo fileInfo) => _ResizedFileInfo = fileInfo;
|
||||
public void SetResizedFileHolder(FileHolder fileHolder) => _ResizedFileHolder = fileHolder;
|
||||
|
||||
public bool Any() => (_Abandoned.HasValue && _Abandoned.Value) || (_Changed.HasValue && _Changed.Value) || (_Moved.HasValue && _Moved.Value) || (_NoJson.HasValue && _NoJson.Value);
|
||||
|
||||
@ -98,6 +98,15 @@ public class PropertyHolder
|
||||
_MinimumDateTime = Stateless.A_Property.GetMinimumDateTime(property);
|
||||
}
|
||||
|
||||
public (bool?, string[]) IsWrongYear()
|
||||
{
|
||||
(bool?, string[]) result;
|
||||
if (_Property is null || _ImageFileHolder is null)
|
||||
throw new ArgumentNullException();
|
||||
result = _Property.IsWrongYear(_ImageFileHolder.FullName, _MinimumDateTime);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void AddToNamed(PropertyLogic propertyLogic, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
{
|
||||
bool? isWrongYear;
|
||||
@ -110,15 +119,15 @@ public class PropertyHolder
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
propertyHolder = filteredPropertyHolderCollection[i];
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
continue;
|
||||
if (propertyHolder.Property?.Id is null || propertyHolder.MinimumDateTime is null || propertyHolder.ResizedFileInfo is null)
|
||||
if (propertyHolder.Property?.Id is null || propertyHolder.MinimumDateTime is null || propertyHolder.ResizedFileHolder is null)
|
||||
continue;
|
||||
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.ContainsKey(propertyHolder.Property.Id.Value))
|
||||
continue;
|
||||
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(propertyHolder.Property);
|
||||
personKeys = propertyLogic.NamedFaceInfoDeterministicHashCodeIndices[propertyHolder.Property.Id.Value];
|
||||
(isWrongYear, _) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileInfo.FullName, minimumDateTime);
|
||||
(isWrongYear, _) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileHolder.FullName, minimumDateTime);
|
||||
for (int j = 0; j < personKeys.Length; j++)
|
||||
{
|
||||
segments = Shared.Models.Stateless.Methods.IPersonBirthday.GetSegments(personKeys[j]);
|
||||
@ -162,12 +171,12 @@ public class PropertyHolder
|
||||
copyFileName = string.Empty;
|
||||
copyDirectory = string.Empty;
|
||||
propertyHolder = filteredPropertyHolderCollection[i];
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
continue;
|
||||
relativePath = Path.GetDirectoryName($"C:{propertyHolder.RelativePath}");
|
||||
if (string.IsNullOrEmpty(relativePath) || relativePath.Length < 3)
|
||||
continue;
|
||||
if (propertyHolder.Property?.Id is null || propertyHolder.MinimumDateTime is null || propertyHolder.ResizedFileInfo is null)
|
||||
if (propertyHolder.Property?.Id is null || propertyHolder.MinimumDateTime is null || propertyHolder.ResizedFileHolder is null)
|
||||
continue;
|
||||
collection = new();
|
||||
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.ContainsKey(propertyHolder.Property.Id.Value))
|
||||
@ -179,7 +188,7 @@ public class PropertyHolder
|
||||
{
|
||||
faceCollection = propertyHolder.Faces;
|
||||
keys = propertyLogic.NamedFaceInfoDeterministicHashCodeIndices[propertyHolder.Property.Id.Value];
|
||||
(isWrongYear, _) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileInfo.FullName, propertyHolder.MinimumDateTime.Value);
|
||||
(isWrongYear, _) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileHolder.FullName, propertyHolder.MinimumDateTime.Value);
|
||||
isWrongYearFlag = GetWrongYearFlag(isWrongYear);
|
||||
subDirectoryName = $"{isWrongYearFlag}{propertyHolder.MinimumDateTime.Value:yyyy}";
|
||||
if (!faceCollection.Any())
|
||||
@ -209,7 +218,7 @@ public class PropertyHolder
|
||||
copyDirectory = Path.Combine(dFacesContentDirectory, "Images", personKey, subDirectoryName);
|
||||
else
|
||||
copyDirectory = Path.Combine(dFacesContentDirectory, "ImagesBut", personKey, subDirectoryName);
|
||||
copyFileName = Path.Combine(copyDirectory, $"{propertyHolder.Property.Id.Value}{propertyHolder.ResizedFileInfo.Extension}");
|
||||
copyFileName = Path.Combine(copyDirectory, $"{propertyHolder.Property.Id.Value}{propertyHolder.ResizedFileHolder.Extension}");
|
||||
}
|
||||
}
|
||||
shortcutFileName = Path.Combine(directory, $"{propertyHolder.Property.Id.Value}.lnk");
|
||||
@ -225,7 +234,7 @@ public class PropertyHolder
|
||||
return results;
|
||||
}
|
||||
|
||||
private static Dictionary<string, List<(string[], PersonBirthday, IFace)>> GetKeyValuePairs(string argZero, List<PropertyHolder[]> propertyHolderCollections, string eDistanceCollectionDirectory)
|
||||
public static Dictionary<string, List<(string[], PersonBirthday, IFace)>> GetKeyValuePairs(string argZero, List<PropertyHolder[]> propertyHolderCollections)
|
||||
{
|
||||
Dictionary<string, List<(string[], PersonBirthday, IFace)>> results = new();
|
||||
string key;
|
||||
@ -233,7 +242,7 @@ public class PropertyHolder
|
||||
TimeSpan? timeSpan;
|
||||
string[] directories;
|
||||
string isWrongYearFlag;
|
||||
string facePopulatedKey;
|
||||
const string facePopulatedKey = "Images";
|
||||
foreach (PropertyHolder[] propertyHolderCollection in propertyHolderCollections)
|
||||
{
|
||||
if (!propertyHolderCollection.Any())
|
||||
@ -242,24 +251,20 @@ public class PropertyHolder
|
||||
continue;
|
||||
foreach (PropertyHolder propertyHolder in propertyHolderCollection)
|
||||
{
|
||||
if (propertyHolder.ImageFileInfo is null || propertyHolder.Property is null || !propertyHolder.Named.Any())
|
||||
if (propertyHolder.ImageFileHolder is null || propertyHolder.Property is null || !propertyHolder.Named.Any())
|
||||
continue;
|
||||
foreach ((bool? isWrongYear, DateTime minimumDateTime, PersonBirthday personBirthday, double? pixelPercentage) in propertyHolder.Named)
|
||||
{
|
||||
if (propertyHolder.MinimumDateTime is null)
|
||||
continue;
|
||||
if (pixelPercentage is null && (propertyHolder.Named.Count != 1 || propertyHolder.Faces.Count != 1))
|
||||
continue;
|
||||
foreach (IFace face in propertyHolder.Faces)
|
||||
{
|
||||
if (!face.Populated)
|
||||
continue;
|
||||
if (pixelPercentage.HasValue && pixelPercentage.Value != face.Location.PixelPercentage)
|
||||
continue;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
timeSpan = Shared.Models.Stateless.Methods.IPersonBirthday.GetTimeSpan(minimumDateTime, isWrongYear, personBirthday);
|
||||
if (face.Populated)
|
||||
facePopulatedKey = "Images";
|
||||
else
|
||||
facePopulatedKey = "ImagesBut";
|
||||
if (timeSpan.HasValue && timeSpan.Value.Ticks < 0)
|
||||
directories = new string[] { string.Empty, facePopulatedKey, personKey, "!---" };
|
||||
else if (timeSpan.HasValue)
|
||||
@ -267,12 +272,11 @@ public class PropertyHolder
|
||||
else
|
||||
{
|
||||
isWrongYearFlag = GetWrongYearFlag(isWrongYear);
|
||||
directories = new string[] { string.Empty, facePopulatedKey, personKey, $"{isWrongYearFlag}{propertyHolder.MinimumDateTime.Value:yyyy}" };
|
||||
directories = new string[] { string.Empty, facePopulatedKey, personKey, $"{isWrongYearFlag}{minimumDateTime:yyyy}" };
|
||||
}
|
||||
key = string.Join('\t', directories);
|
||||
if (!results.ContainsKey(key))
|
||||
results.Add(key, new());
|
||||
directories[0] = eDistanceCollectionDirectory;
|
||||
results[key].Add(new(directories, personBirthday, face));
|
||||
if (pixelPercentage is null)
|
||||
break;
|
||||
@ -283,23 +287,4 @@ public class PropertyHolder
|
||||
return results;
|
||||
}
|
||||
|
||||
public static List<(string, PersonBirthday, IFace)[]> GetCollection(string argZero, List<PropertyHolder[]> propertyHolderCollections, string eDistanceCollectionDirectory)
|
||||
{
|
||||
List<(string, PersonBirthday, IFace)[]> results = new();
|
||||
string directory;
|
||||
List<(string, PersonBirthday, IFace)> group;
|
||||
Dictionary<string, List<(string[], PersonBirthday, IFace)>> keyValuePairs = GetKeyValuePairs(argZero, propertyHolderCollections, eDistanceCollectionDirectory);
|
||||
foreach (KeyValuePair<string, List<(string[], PersonBirthday, IFace)>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
group = new();
|
||||
foreach ((string[] directories, PersonBirthday personBirthday, IFace face) in keyValuePair.Value)
|
||||
{
|
||||
directory = Path.Combine(directories);
|
||||
group.Add(new(directory, personBirthday, face));
|
||||
}
|
||||
results.Add(group.ToArray());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
@ -160,15 +160,15 @@ public class PropertyLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public static List<DateTime> GetMetadataDateTimesByPattern(string dateTimeFormat, FileInfo filteredSourceDirectoryFileInfo)
|
||||
public static List<DateTime> GetMetadataDateTimesByPattern(string dateTimeFormat, FileHolder filteredSourceDirectoryFileHolder)
|
||||
{
|
||||
List<DateTime> results = GetMetadataDateTimesByPattern(dateTimeFormat, filteredSourceDirectoryFileInfo.FullName);
|
||||
List<DateTime> results = GetMetadataDateTimesByPattern(dateTimeFormat, filteredSourceDirectoryFileHolder.FullName);
|
||||
return results;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
private A_Property GetImageProperty(string angleBracket, FileInfo filteredSourceDirectoryFileInfo, bool populateId, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, int? id, List<int> indices)
|
||||
private A_Property GetImageProperty(string angleBracket, FileHolder filteredSourceDirectoryFileHolder, bool populateId, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, int? id, List<int> indices)
|
||||
{
|
||||
A_Property result;
|
||||
if (_Log is null)
|
||||
@ -178,6 +178,7 @@ public class PropertyLogic
|
||||
long ticks;
|
||||
byte[] bytes;
|
||||
string value;
|
||||
long fileLength;
|
||||
int encodingHash;
|
||||
int? width = null;
|
||||
int? height = null;
|
||||
@ -194,7 +195,7 @@ public class PropertyLogic
|
||||
if (!isValidImageFormatExtension && isValidMetadataExtensions)
|
||||
{
|
||||
dateTimeFormat = "ddd MMM dd HH:mm:ss yyyy";
|
||||
List<DateTime> dateTimes = GetMetadataDateTimesByPattern(dateTimeFormat, filteredSourceDirectoryFileInfo);
|
||||
List<DateTime> dateTimes = GetMetadataDateTimesByPattern(dateTimeFormat, filteredSourceDirectoryFileHolder);
|
||||
if (dateTimes.Any())
|
||||
dateTimeOriginal = dateTimes.Min();
|
||||
}
|
||||
@ -204,7 +205,7 @@ public class PropertyLogic
|
||||
throw new Exception("In order to keep six character indices at least one need to have an item!");
|
||||
try
|
||||
{
|
||||
using Image image = Image.FromFile(filteredSourceDirectoryFileInfo.FullName);
|
||||
using Image image = Image.FromFile(filteredSourceDirectoryFileHolder.FullName);
|
||||
if (populateId && (id is null || !indices.Any()))
|
||||
{
|
||||
using Bitmap bitmap = new(image);
|
||||
@ -224,7 +225,7 @@ public class PropertyLogic
|
||||
}
|
||||
if (_Configuration.WriteBitmapDataBytes.Value)
|
||||
{
|
||||
FileInfo contentFileInfo = new(Path.Combine(angleBracket.Replace("<>", "()"), filteredSourceDirectoryFileInfo.Name));
|
||||
FileInfo contentFileInfo = new(Path.Combine(angleBracket.Replace("<>", "()"), filteredSourceDirectoryFileHolder.Name));
|
||||
File.WriteAllBytes(Path.ChangeExtension(contentFileInfo.FullName, string.Empty), bytes);
|
||||
}
|
||||
if (_IndicesFromNew.ContainsKey(id.Value) && _IndicesFromNew[id.Value].Any())
|
||||
@ -325,12 +326,16 @@ public class PropertyLogic
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_Log.Info(string.Concat(new StackFrame().GetMethod()?.Name, " <", filteredSourceDirectoryFileInfo.Name, ">"));
|
||||
_Log.Info(string.Concat(new StackFrame().GetMethod()?.Name, " <", filteredSourceDirectoryFileHolder.Name, ">"));
|
||||
}
|
||||
}
|
||||
else
|
||||
dateTimeOriginal = null;
|
||||
result = new(filteredSourceDirectoryFileInfo.CreationTime, dateTime, dateTimeDigitized, dateTimeOriginal, filteredSourceDirectoryFileInfo.Length, gpsDateStamp, height, id, indices.ToArray(), filteredSourceDirectoryFileInfo.LastWriteTime, make, model, orientation, width);
|
||||
if (filteredSourceDirectoryFileHolder.Length is null)
|
||||
fileLength = 0;
|
||||
else
|
||||
fileLength = filteredSourceDirectoryFileHolder.Length.Value;
|
||||
result = new(filteredSourceDirectoryFileHolder.CreationTime, dateTime, dateTimeDigitized, dateTimeOriginal, fileLength, gpsDateStamp, height, id, indices.ToArray(), filteredSourceDirectoryFileHolder.LastWriteTime, make, model, orientation, width);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -393,8 +398,8 @@ public class PropertyLogic
|
||||
json = File.ReadAllText(fileInfo.FullName);
|
||||
try
|
||||
{
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
throw new ArgumentException($"{propertyHolder.ImageFileInfo} is null!");
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
throw new ArgumentException($"{propertyHolder.ImageFileHolder} is null!");
|
||||
bool check = true;
|
||||
A_Property? property = JsonSerializer.Deserialize<A_Property>(json);
|
||||
if (!isIgnoreExtension && isValidImageFormatExtension && ((populateId && property?.Id is null) || property?.Width is null || property?.Height is null))
|
||||
@ -403,7 +408,7 @@ public class PropertyLogic
|
||||
id = property?.Id;
|
||||
if (property is not null && property.Indices.Any())
|
||||
indices = property.Indices.ToList();
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileHolder, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
}
|
||||
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && !property.Indices.Any())
|
||||
{
|
||||
@ -411,22 +416,22 @@ public class PropertyLogic
|
||||
id = property?.Id;
|
||||
if (property is not null && property.Indices.Any())
|
||||
indices = property.Indices.ToList();
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileHolder, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
}
|
||||
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && property.LastWriteTime != propertyHolder.ImageFileInfo.LastWriteTime)
|
||||
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && property.LastWriteTime != propertyHolder.ImageFileHolder.LastWriteTime)
|
||||
{
|
||||
check = false;
|
||||
id = null;
|
||||
indices.Clear();
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileHolder, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
}
|
||||
if (!isIgnoreExtension && isValidImageFormatExtension && property?.Width is not null && property?.Height is not null && property.Width.Value == property.Height.Value && propertyHolder.ImageFileInfo.Exists)
|
||||
if (!isIgnoreExtension && isValidImageFormatExtension && property?.Width is not null && property?.Height is not null && property.Width.Value == property.Height.Value && propertyHolder.ImageFileHolder.Exists)
|
||||
{
|
||||
check = false;
|
||||
id = property?.Id;
|
||||
if (property is not null && property.Indices.Any())
|
||||
indices = property.Indices.ToList();
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
property = GetImageProperty(angleBracket, propertyHolder.ImageFileHolder, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
if (property?.Width is not null && property?.Height is not null && property.Width.Value != property.Height.Value)
|
||||
throw new Exception("Was square!");
|
||||
}
|
||||
@ -460,9 +465,9 @@ public class PropertyLogic
|
||||
}
|
||||
if (result is null)
|
||||
{
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
throw new ArgumentException($"{propertyHolder.ImageFileInfo} is null!");
|
||||
result = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
throw new ArgumentException($"{propertyHolder.ImageFileHolder} is null!");
|
||||
result = GetImageProperty(angleBracket, propertyHolder.ImageFileHolder, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
|
||||
json = JsonSerializer.Serialize(result, _WriteIndentedJsonSerializerOptions);
|
||||
if (populateId && IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches: true, compareBeforeWrite: true))
|
||||
{
|
||||
@ -511,14 +516,14 @@ public class PropertyLogic
|
||||
continue;
|
||||
if (propertyHolder.Property is null)
|
||||
continue;
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
continue;
|
||||
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(propertyHolder.Property);
|
||||
if (minimumDateTime > directoryMaximumOfMinimumDateTime)
|
||||
directoryMaximumOfMinimumDateTime = minimumDateTime;
|
||||
if (minimumDateTime != propertyHolder.ImageFileInfo.CreationTime)
|
||||
if (minimumDateTime != propertyHolder.ImageFileHolder.CreationTime)
|
||||
{
|
||||
(isWrongYear, matches) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileInfo.FullName, minimumDateTime);
|
||||
(isWrongYear, matches) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileHolder.FullName, minimumDateTime);
|
||||
if (isWrongYear is null || !isWrongYear.Value)
|
||||
dateTime = minimumDateTime;
|
||||
else
|
||||
@ -529,18 +534,18 @@ public class PropertyLogic
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{ File.SetCreationTime(propertyHolder.ImageFileInfo.FullName, dateTime); }
|
||||
{ File.SetCreationTime(propertyHolder.ImageFileHolder.FullName, dateTime); }
|
||||
catch (Exception)
|
||||
{ }
|
||||
}
|
||||
if (!_VerifyToSeason.Contains(sourceDirectory))
|
||||
continue;
|
||||
if (!propertyHolder.ImageFileInfo.FullName.Contains("zzz ") && !propertyHolder.ImageFileInfo.FullName.Contains("Camera ") && propertyHolder.Property.DateTimeOriginal.HasValue)
|
||||
if (!propertyHolder.ImageFileHolder.FullName.Contains("zzz ") && !propertyHolder.ImageFileHolder.FullName.Contains("Camera ") && propertyHolder.Property.DateTimeOriginal.HasValue)
|
||||
{
|
||||
TimeSpan timeSpan = new(propertyHolder.Property.DateTimeOriginal.Value.Ticks - propertyHolder.Property.LastWriteTime.Ticks);
|
||||
if (timeSpan.TotalHours > 6)
|
||||
{
|
||||
_Log.Warning($"*** propertyHolder.FileInfo.FullName <{propertyHolder.ImageFileInfo.FullName}>");
|
||||
_Log.Warning($"*** propertyHolder.FileInfo.FullName <{propertyHolder.ImageFileHolder.FullName}>");
|
||||
_Log.Warning($"*** DateTimeOriginal <{propertyHolder.Property.DateTimeOriginal.Value}>");
|
||||
_Log.Warning($"*** LastWriteTime <{propertyHolder.Property.LastWriteTime}>");
|
||||
_Log.Warning($"*** TotalHours <{timeSpan.TotalHours}>");
|
||||
@ -562,35 +567,35 @@ public class PropertyLogic
|
||||
result = true;
|
||||
if (!Directory.Exists(destinationDirectory))
|
||||
_ = Directory.CreateDirectory(destinationDirectory);
|
||||
destinationFile = Path.Combine(destinationDirectory, propertyHolder.ImageFileInfo.Name);
|
||||
destinationFile = Path.Combine(destinationDirectory, propertyHolder.ImageFileHolder.Name);
|
||||
if (File.Exists(destinationFile))
|
||||
{
|
||||
if (destinationFile.EndsWith(".jpg", ignoreCase: true, CultureInfo.CurrentCulture))
|
||||
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.ImageFileInfo.Name, ".jpeg"));
|
||||
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.ImageFileHolder.Name, ".jpeg"));
|
||||
else if (destinationFile.EndsWith(".jpeg", ignoreCase: true, CultureInfo.CurrentCulture))
|
||||
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.ImageFileInfo.Name, ".jpg"));
|
||||
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.ImageFileHolder.Name, ".jpg"));
|
||||
}
|
||||
if (File.Exists(destinationFile))
|
||||
{
|
||||
_Log.Information($"*** source <{propertyHolder.ImageFileInfo.FullName}>");
|
||||
_Log.Information($"*** source <{propertyHolder.ImageFileHolder.FullName}>");
|
||||
_Log.Information($"*** destination <{destinationFile}>");
|
||||
if (propertyHolder.ImageFileInfo.Exists)
|
||||
if (propertyHolder.ImageFileHolder.Exists)
|
||||
{
|
||||
deleteFile = Path.ChangeExtension(propertyHolder.ImageFileInfo.FullName, ".delete");
|
||||
deleteFile = Path.ChangeExtension(propertyHolder.ImageFileHolder.FullName, ".delete");
|
||||
if (File.Exists(deleteFile))
|
||||
File.Delete(deleteFile);
|
||||
File.Move(propertyHolder.ImageFileInfo.FullName, deleteFile);
|
||||
File.Move(propertyHolder.ImageFileHolder.FullName, deleteFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Move(propertyHolder.ImageFileInfo.FullName, destinationFile);
|
||||
if (propertyHolder.ImageFileInfo.Exists)
|
||||
File.Move(propertyHolder.ImageFileHolder.FullName, destinationFile);
|
||||
if (propertyHolder.ImageFileHolder.Exists)
|
||||
{
|
||||
deleteFile = Path.ChangeExtension(propertyHolder.ImageFileInfo.FullName, ".delete");
|
||||
deleteFile = Path.ChangeExtension(propertyHolder.ImageFileHolder.FullName, ".delete");
|
||||
if (File.Exists(deleteFile))
|
||||
File.Delete(deleteFile);
|
||||
File.Move(propertyHolder.ImageFileInfo.FullName, deleteFile);
|
||||
File.Move(propertyHolder.ImageFileHolder.FullName, deleteFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -603,24 +608,26 @@ public class PropertyLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ParallelForWork(bool firstPass, string angleBracket, string sourceDirectory, List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, PropertyHolder propertyHolder)
|
||||
private void ParallelForWork(bool firstPass, string angleBracket, string sourceDirectory, List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, List<Tuple<string, DateTime>> sourceDirectoryChanges, PropertyHolder propertyHolder)
|
||||
{
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
throw new ArgumentNullException(nameof(propertyHolder.ImageFileInfo));
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
throw new ArgumentNullException(nameof(propertyHolder.ImageFileHolder));
|
||||
A_Property property;
|
||||
List<string> parseExceptions = new();
|
||||
string extensionLowered = propertyHolder.ImageFileInfo.Extension.ToLower();
|
||||
string extensionLowered = propertyHolder.ImageFileHolder.Extension.ToLower();
|
||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(extensionLowered);
|
||||
bool isValidImageFormatExtension = _Configuration.ValidImageFormatExtensions.Contains(extensionLowered);
|
||||
lock (propertyHolder)
|
||||
propertyHolder.SetValidImageFormatExtension(isValidImageFormatExtension);
|
||||
bool isIgnoreExtension = isValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(extensionLowered);
|
||||
string filteredSourceDirectoryFileExtensionLowered = Path.Combine(sourceDirectory, $"{propertyHolder.ImageFileNameWithoutExtension}{extensionLowered}");
|
||||
if (isValidImageFormatExtension && propertyHolder.ImageFileInfo.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && propertyHolder.ImageFileInfo.FullName != filteredSourceDirectoryFileExtensionLowered)
|
||||
File.Move(propertyHolder.ImageFileInfo.FullName, filteredSourceDirectoryFileExtensionLowered);
|
||||
if (isValidImageFormatExtension && propertyHolder.ImageFileHolder.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && propertyHolder.ImageFileHolder.FullName != filteredSourceDirectoryFileExtensionLowered)
|
||||
File.Move(propertyHolder.ImageFileHolder.FullName, filteredSourceDirectoryFileExtensionLowered);
|
||||
if (propertyHolder.Changed is null || propertyHolder.Changed.Value || propertyHolder.Property is null)
|
||||
{
|
||||
property = GetPropertyOfPrivate(angleBracket, propertyHolder, firstPass, filteredSourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, extensionLowered);
|
||||
lock (sourceDirectoryChanges)
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
||||
lock (propertyHolder)
|
||||
propertyHolder.Update(property);
|
||||
}
|
||||
@ -631,7 +638,8 @@ public class PropertyLogic
|
||||
List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples = new();
|
||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _MaxDegreeOfParallelism };
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
using ProgressBar progressBar = new(filteredPropertyHolderCollection.Length, $"{r + 1:000}.{g} / {propertyHolderCollectionsCount:000}) {filteredPropertyHolderCollection.Length:000} file(s) - {totalSeconds} total second(s) - {sourceDirectory}", options);
|
||||
string message = $"{r + 1:000}.{g} / {propertyHolderCollectionsCount:000}) {filteredPropertyHolderCollection.Length:000} file(s) - {totalSeconds} total second(s) - {sourceDirectory}";
|
||||
using ProgressBar progressBar = new(filteredPropertyHolderCollection.Length, message, options);
|
||||
_ = Parallel.For(0, filteredPropertyHolderCollection.Length, parallelOptions, i =>
|
||||
{
|
||||
try
|
||||
@ -639,8 +647,9 @@ public class PropertyLogic
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
List<Tuple<string, DateTime>> collection;
|
||||
ParallelForWork(firstPass, angleBracket, sourceDirectory, filteredSourceDirectoryFileTuples, filteredPropertyHolderCollection[i]);
|
||||
progressBar.Tick();
|
||||
ParallelForWork(firstPass, angleBracket, sourceDirectory, sourceDirectoryChanges, filteredSourceDirectoryFileTuples, filteredPropertyHolderCollection[i]);
|
||||
if (i == 0 || sourceDirectoryChanges.Any())
|
||||
progressBar.Tick();
|
||||
lock (filteredSourceDirectoryFileTuples)
|
||||
collection = (from l in filteredSourceDirectoryFileTuples where l.Item2 > dateTime select l).ToList();
|
||||
lock (sourceDirectoryChanges)
|
||||
@ -699,7 +708,7 @@ public class PropertyLogic
|
||||
if (firstPass)
|
||||
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.NoJson is null || !l.NoJson.Value && (l.Changed is null || l.Changed.Value) select l).ToArray();
|
||||
else
|
||||
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.ImageFileInfo is not null && !_Configuration.IgnoreExtensions.Contains(l.ImageFileInfo.Extension) select l).ToArray();
|
||||
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.ImageFileHolder is not null && !_Configuration.IgnoreExtensions.Contains(l.ImageFileHolder.Extension) select l).ToArray();
|
||||
if (!filteredPropertyHolderCollection.Any())
|
||||
continue;
|
||||
g = filteredPropertyHolderCollection[0].G;
|
||||
@ -734,10 +743,10 @@ public class PropertyLogic
|
||||
public A_Property GetProperty(string angleBracket, PropertyHolder propertyHolder, List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, List<string> parseExceptions)
|
||||
{
|
||||
A_Property result;
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
throw new ArgumentException($"{propertyHolder.ImageFileInfo} is null!");
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
throw new ArgumentException($"{propertyHolder.ImageFileHolder} is null!");
|
||||
bool firstPass = false;
|
||||
string extensionLowered = propertyHolder.ImageFileInfo.Extension.ToLower();
|
||||
string extensionLowered = propertyHolder.ImageFileHolder.Extension.ToLower();
|
||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(extensionLowered);
|
||||
bool isValidImageFormatExtension = _Configuration.ValidImageFormatExtensions.Contains(extensionLowered);
|
||||
bool isIgnoreExtension = isValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(extensionLowered);
|
||||
@ -769,7 +778,7 @@ public class PropertyLogic
|
||||
}
|
||||
if (!Directory.Exists(propertyDirectory))
|
||||
_ = Directory.CreateDirectory(propertyDirectory);
|
||||
for (int i = 0; i < group.SourceDirectoryFileInfoCollection.Length; i++)
|
||||
for (int i = 0; i < group.SourceDirectoryFileHolderCollection.Length; i++)
|
||||
{
|
||||
property = group.PropertyCollection[i];
|
||||
if (property?.Id is null)
|
||||
|
@ -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