Remove ThumbHasher from Property
This commit is contained in:
parent
a0c880c7ba
commit
82143850ac
@ -202,11 +202,10 @@ public partial class DragDropMove : Form
|
|||||||
List<(string, int, DateTime)> results = new();
|
List<(string, int, DateTime)> results = new();
|
||||||
DateTime dateTime;
|
DateTime dateTime;
|
||||||
Shared.Models.Property property;
|
Shared.Models.Property property;
|
||||||
Shared.Models.Methods.IThumbHasher? thumbHasher = null;
|
|
||||||
string[] files = Directory.GetFiles(checkDirectory, "*", SearchOption.TopDirectoryOnly);
|
string[] files = Directory.GetFiles(checkDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
property = Property.Models.A_Property.GetImageProperty(thumbHasher, file);
|
property = Property.Models.A_Property.GetImageProperty(file);
|
||||||
if (property.Id is null || property.DateTimeOriginal is null)
|
if (property.Id is null || property.DateTimeOriginal is null)
|
||||||
continue;
|
continue;
|
||||||
dateTime = property.DateTimeOriginal.Value.AddTicks(ticks);
|
dateTime = property.DateTimeOriginal.Value.AddTicks(ticks);
|
||||||
@ -240,7 +239,6 @@ public partial class DragDropMove : Form
|
|||||||
ticks++;
|
ticks++;
|
||||||
|
|
||||||
}
|
}
|
||||||
Shared.Models.Methods.IThumbHasher? thumbHasher = null;
|
|
||||||
List<(string, int, DateTime)> collection = GetCollection(checkDirectory, minimumDateTime, maximumDateTime, ticks);
|
List<(string, int, DateTime)> collection = GetCollection(checkDirectory, minimumDateTime, maximumDateTime, ticks);
|
||||||
ConstructorInfo? constructorInfo = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, Array.Empty<Type>(), null) ?? throw new Exception();
|
ConstructorInfo? constructorInfo = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, Array.Empty<Type>(), null) ?? throw new Exception();
|
||||||
foreach ((string file, int id, DateTime dateTime) in collection)
|
foreach ((string file, int id, DateTime dateTime) in collection)
|
||||||
@ -255,7 +253,7 @@ public partial class DragDropMove : Form
|
|||||||
bitmap.SetPropertyItem(propertyItem);
|
bitmap.SetPropertyItem(propertyItem);
|
||||||
bitmap.Save(checkFile);
|
bitmap.Save(checkFile);
|
||||||
bitmap.Dispose();
|
bitmap.Dispose();
|
||||||
property = Property.Models.A_Property.GetImageProperty(thumbHasher, checkFile);
|
property = Property.Models.A_Property.GetImageProperty(checkFile);
|
||||||
if (property.Id is null || property.Id.Value != id)
|
if (property.Id is null || property.Id.Value != id)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
@ -290,11 +288,10 @@ public partial class DragDropMove : Form
|
|||||||
_Logger.Error("bad file(s) or target file(s) or maximum directory doesn't equal 1!");
|
_Logger.Error("bad file(s) or target file(s) or maximum directory doesn't equal 1!");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Shared.Models.Methods.IThumbHasher? thumbHasher = null;
|
|
||||||
DateTime minimumDateTime = DateTime.ParseExact(Path.GetFileName(minimumDirectory.First()), format, null, System.Globalization.DateTimeStyles.None);
|
DateTime minimumDateTime = DateTime.ParseExact(Path.GetFileName(minimumDirectory.First()), format, null, System.Globalization.DateTimeStyles.None);
|
||||||
DateTime maximumDateTime = DateTime.ParseExact(Path.GetFileName(maximumDirectory.First()), format, null, System.Globalization.DateTimeStyles.None).AddHours(23);
|
DateTime maximumDateTime = DateTime.ParseExact(Path.GetFileName(maximumDirectory.First()), format, null, System.Globalization.DateTimeStyles.None).AddHours(23);
|
||||||
Shared.Models.Property badProperty = Property.Models.A_Property.GetImageProperty(thumbHasher, badFiles.First());
|
Shared.Models.Property badProperty = Property.Models.A_Property.GetImageProperty(badFiles.First());
|
||||||
Shared.Models.Property targetProperty = Property.Models.A_Property.GetImageProperty(thumbHasher, targetFiles.First());
|
Shared.Models.Property targetProperty = Property.Models.A_Property.GetImageProperty(targetFiles.First());
|
||||||
if (badProperty.DateTimeOriginal is null || targetProperty.DateTimeOriginal is null)
|
if (badProperty.DateTimeOriginal is null || targetProperty.DateTimeOriginal is null)
|
||||||
_Logger.Error("Date is null!");
|
_Logger.Error("Date is null!");
|
||||||
else
|
else
|
||||||
|
@ -376,45 +376,7 @@ public partial class DlibDotNet
|
|||||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||||
List<KeyValuePair<string, string>> metadataCollection;
|
List<KeyValuePair<string, string>> metadataCollection;
|
||||||
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(item);
|
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(item);
|
||||||
if (item.Property is not null && item.Property.Id is not null && resizedFileHolder.Exists && item.Property.ThumbHashBytes is null)
|
if (item.Property is not null && item.Property.Id is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Height is not null)
|
||||||
{
|
|
||||||
(string aResultsFullGroupDirectory, _) = GetResultsFullGroupDirectories();
|
|
||||||
string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}");
|
|
||||||
string[] files = Directory.GetFiles(aPropertySingletonDirectory, $"{item.Property.Id.Value}*", SearchOption.AllDirectories);
|
|
||||||
if (files.Length == 1)
|
|
||||||
{
|
|
||||||
string matchFile = files.First();
|
|
||||||
string json = File.ReadAllText(matchFile);
|
|
||||||
string find = "\"CreationTime\":";
|
|
||||||
if (!json.Contains(find))
|
|
||||||
throw new NotImplementedException();
|
|
||||||
byte[]? thumbHashBytes = _IThumbHasher.Encode(resizedFileHolder.FullName);
|
|
||||||
string thumbHashJson = JsonSerializer.Serialize(thumbHashBytes);
|
|
||||||
json = json.Replace(find, $"\"{nameof(property.ThumbHashBytes)}\": {thumbHashJson}, {find}");
|
|
||||||
property = JsonSerializer.Deserialize<Shared.Models.Property>(json);
|
|
||||||
if (property is null || property.ThumbHashBytes is null)
|
|
||||||
throw new NullReferenceException(nameof(property));
|
|
||||||
json = JsonSerializer.Serialize(property, new JsonSerializerOptions { WriteIndented = true });
|
|
||||||
if (thumbHashBytes is null || thumbHashBytes.Length != property.ThumbHashBytes.Length)
|
|
||||||
throw new Exception(nameof(property.ThumbHashBytes));
|
|
||||||
for (int i = 0; i < thumbHashBytes.Length; i++)
|
|
||||||
{
|
|
||||||
if (thumbHashBytes[i] != property.ThumbHashBytes[i])
|
|
||||||
throw new Exception(nameof(property.ThumbHashBytes));
|
|
||||||
}
|
|
||||||
thumbHashBytes = JsonSerializer.Deserialize<byte[]>(thumbHashJson);
|
|
||||||
if (thumbHashBytes is null || thumbHashBytes.Length != property.ThumbHashBytes.Length)
|
|
||||||
throw new Exception(nameof(property.ThumbHashBytes));
|
|
||||||
for (int i = 0; i < thumbHashBytes.Length; i++)
|
|
||||||
{
|
|
||||||
if (thumbHashBytes[i] != property.ThumbHashBytes[i])
|
|
||||||
throw new Exception(nameof(property.ThumbHashBytes));
|
|
||||||
}
|
|
||||||
File.WriteAllText(matchFile, json);
|
|
||||||
File.SetLastWriteTime(matchFile, item.Property.LastWriteTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.Property is not null && item.Property.Id is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Height is not null && item.Property.ThumbHashBytes is not null)
|
|
||||||
{
|
{
|
||||||
string fileName;
|
string fileName;
|
||||||
string c2ThumbHasherContentDirectory = Path.Combine(c2ResultsFullGroupDirectory, "()");
|
string c2ThumbHasherContentDirectory = Path.Combine(c2ResultsFullGroupDirectory, "()");
|
||||||
@ -423,13 +385,13 @@ public partial class DlibDotNet
|
|||||||
_ = Directory.CreateDirectory(c2ThumbHasherContentDirectory);
|
_ = Directory.CreateDirectory(c2ThumbHasherContentDirectory);
|
||||||
if (!Directory.Exists(c2ThumbHasherSingletonDirectory))
|
if (!Directory.Exists(c2ThumbHasherSingletonDirectory))
|
||||||
_ = Directory.CreateDirectory(c2ThumbHasherSingletonDirectory);
|
_ = Directory.CreateDirectory(c2ThumbHasherSingletonDirectory);
|
||||||
MemoryStream memoryStream = _IThumbHasher.GetMemoryStream(item.Property.ThumbHashBytes, item.Property.Width.Value, item.Property.Height.Value);
|
MemoryStream memoryStream = _IThumbHasher.GetMemoryStream(Array.Empty<byte>(), item.Property.Width.Value, item.Property.Height.Value);
|
||||||
string thumbHashJson = JsonSerializer.Serialize(item.Property.ThumbHashBytes)[1..^1];
|
string thumbHashJson = JsonSerializer.Serialize(Array.Empty<byte>())[1..^1];
|
||||||
if (!Regex.Matches(thumbHashJson, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]").Any())
|
if (!Regex.Matches(thumbHashJson, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]").Any())
|
||||||
fileName = Path.Combine(c2ThumbHasherSingletonDirectory, $"{thumbHashJson}.png");
|
fileName = Path.Combine(c2ThumbHasherSingletonDirectory, $"{thumbHashJson}.png");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// string thumbHash = BitConverter.ToString(item.Property.ThumbHashBytes).Replace("-", string.Empty);
|
// string thumbHash = BitConverter.ToString(Array.Empty<byte>()).Replace("-", string.Empty);
|
||||||
// fileName = Path.Combine(c2ThumbHasherContentDirectory, $"{thumbHash}.png");
|
// fileName = Path.Combine(c2ThumbHasherContentDirectory, $"{thumbHash}.png");
|
||||||
fileName = Path.Combine(c2ThumbHasherContentDirectory, $"{resizedFileHolder.NameWithoutExtension}.png");
|
fileName = Path.Combine(c2ThumbHasherContentDirectory, $"{resizedFileHolder.NameWithoutExtension}.png");
|
||||||
}
|
}
|
||||||
@ -467,7 +429,7 @@ public partial class DlibDotNet
|
|||||||
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
|
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
|
||||||
else if (item.Moved.HasValue && item.Moved.Value)
|
else if (item.Moved.HasValue && item.Moved.Value)
|
||||||
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
|
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
|
||||||
property = propertyLogic.GetProperty(_IThumbHasher, item, subFileTuples, parseExceptions);
|
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
|
||||||
item.Update(property);
|
item.Update(property);
|
||||||
if (propertyHashCode is null)
|
if (propertyHashCode is null)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ public class A_Property
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Shared.Models.Property GetImageProperty(Shared.Models.Methods.IThumbHasher? thumbHasher, FileHolder fileHolder, Shared.Models.Property? property, bool populateId, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, int? id, ASCIIEncoding asciiEncoding, bool writeBitmapDataBytes, string? angleBracket)
|
private static Shared.Models.Property GetImageProperty(FileHolder fileHolder, Shared.Models.Property? property, bool populateId, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, int? id, ASCIIEncoding asciiEncoding, bool writeBitmapDataBytes, string? angleBracket)
|
||||||
{
|
{
|
||||||
Shared.Models.Property result;
|
Shared.Models.Property result;
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
@ -117,7 +117,6 @@ public class A_Property
|
|||||||
DateTime? dateTime = null;
|
DateTime? dateTime = null;
|
||||||
PropertyItem? propertyItem;
|
PropertyItem? propertyItem;
|
||||||
string? orientation = null;
|
string? orientation = null;
|
||||||
byte[]? thumbHashBytes = null;
|
|
||||||
DateTime? gpsDateStamp = null;
|
DateTime? gpsDateStamp = null;
|
||||||
DateTime? dateTimeOriginal = null;
|
DateTime? dateTimeOriginal = null;
|
||||||
DateTime? dateTimeDigitized = null;
|
DateTime? dateTimeDigitized = null;
|
||||||
@ -242,18 +241,16 @@ public class A_Property
|
|||||||
throw new NullReferenceException(nameof(fileHolder.CreationTime));
|
throw new NullReferenceException(nameof(fileHolder.CreationTime));
|
||||||
if (fileHolder.LastWriteTime is null && property?.LastWriteTime is null)
|
if (fileHolder.LastWriteTime is null && property?.LastWriteTime is null)
|
||||||
throw new NullReferenceException(nameof(fileHolder.LastWriteTime));
|
throw new NullReferenceException(nameof(fileHolder.LastWriteTime));
|
||||||
if (thumbHasher is not null && property?.ThumbHashBytes is null)
|
|
||||||
thumbHashBytes = thumbHasher.Encode(fileHolder.FullName);
|
|
||||||
if (fileHolder.CreationTime is not null && fileHolder.LastWriteTime is not null)
|
if (fileHolder.CreationTime is not null && fileHolder.LastWriteTime is not null)
|
||||||
result = new(fileHolder.CreationTime.Value, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginal, fileLength, gpsDateStamp, height, id, fileHolder.LastWriteTime.Value, make, model, orientation, thumbHashBytes, width);
|
result = new(fileHolder.CreationTime.Value, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginal, fileLength, gpsDateStamp, height, id, fileHolder.LastWriteTime.Value, make, model, orientation, width);
|
||||||
else if (property is not null)
|
else if (property is not null)
|
||||||
result = new(property.CreationTime, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginal, fileLength, gpsDateStamp, height, id, property.LastWriteTime, make, model, orientation, thumbHashBytes, width);
|
result = new(property.CreationTime, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginal, fileLength, gpsDateStamp, height, id, property.LastWriteTime, make, model, orientation, width);
|
||||||
else
|
else
|
||||||
throw new NullReferenceException(nameof(property));
|
throw new NullReferenceException(nameof(property));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Shared.Models.Property GetImageProperty(Shared.Models.Methods.IThumbHasher? thumbHasher, string fileName)
|
public static Shared.Models.Property GetImageProperty(string fileName)
|
||||||
{
|
{
|
||||||
int? id = null;
|
int? id = null;
|
||||||
bool populateId = true;
|
bool populateId = true;
|
||||||
@ -265,13 +262,13 @@ public class A_Property
|
|||||||
FileHolder fileHolder = new(fileName);
|
FileHolder fileHolder = new(fileName);
|
||||||
bool isValidImageFormatExtension = true;
|
bool isValidImageFormatExtension = true;
|
||||||
Shared.Models.Property? property = null;
|
Shared.Models.Property? property = null;
|
||||||
Shared.Models.Property result = GetImageProperty(thumbHasher, fileHolder, property, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, asciiEncoding, writeBitmapDataBytes, angleBracket);
|
Shared.Models.Property result = GetImageProperty(fileHolder, property, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, asciiEncoding, writeBitmapDataBytes, angleBracket);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning restore CA1416
|
#pragma warning restore CA1416
|
||||||
|
|
||||||
private Shared.Models.Property GetPropertyOfPrivate(Shared.Models.Methods.IThumbHasher? thumbHasher, Item item, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<string> parseExceptions, bool isIgnoreExtension, bool isValidMetadataExtensions)
|
private Shared.Models.Property GetPropertyOfPrivate(Item item, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<string> parseExceptions, bool isIgnoreExtension, bool isValidMetadataExtensions)
|
||||||
{
|
{
|
||||||
Shared.Models.Property? result;
|
Shared.Models.Property? result;
|
||||||
int? id = null;
|
int? id = null;
|
||||||
@ -359,25 +356,10 @@ public class A_Property
|
|||||||
parseExceptions.Add(nameof(A_Property));
|
parseExceptions.Add(nameof(A_Property));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(json) && result is not null && thumbHasher is not null && result.ThumbHashBytes is null)
|
|
||||||
{
|
|
||||||
string find = "\"CreationTime\":";
|
|
||||||
if (!json.Contains(find))
|
|
||||||
throw new NotImplementedException();
|
|
||||||
byte[] thumbHashBytes = thumbHasher.Encode(item.ImageFileHolder.FullName);
|
|
||||||
string thumbHashJson = JsonSerializer.Serialize(thumbHashBytes);
|
|
||||||
json = json.Replace(find, $"\"{nameof(result.ThumbHashBytes)}\": {thumbHashJson}, {find}");
|
|
||||||
result = JsonSerializer.Deserialize<Shared.Models.Property>(json);
|
|
||||||
if (result is null || result.ThumbHashBytes is null)
|
|
||||||
throw new NullReferenceException(nameof(result));
|
|
||||||
json = JsonSerializer.Serialize(result, _WriteIndentedJsonSerializerOptions);
|
|
||||||
File.WriteAllText(fileInfo.FullName, json);
|
|
||||||
File.SetLastWriteTime(fileInfo.FullName, fileInfo.LastWriteTime);
|
|
||||||
}
|
|
||||||
if (result is null)
|
if (result is null)
|
||||||
{
|
{
|
||||||
id ??= item.ImageFileHolder.Id;
|
id ??= item.ImageFileHolder.Id;
|
||||||
result = GetImageProperty(thumbHasher, item.ImageFileHolder, result, populateId, isIgnoreExtension, item.IsValidImageFormatExtension, isValidMetadataExtensions, id, _ASCIIEncoding, _Configuration.WriteBitmapDataBytes, angleBracket);
|
result = GetImageProperty(item.ImageFileHolder, result, populateId, isIgnoreExtension, item.IsValidImageFormatExtension, isValidMetadataExtensions, id, _ASCIIEncoding, _Configuration.WriteBitmapDataBytes, angleBracket);
|
||||||
json = JsonSerializer.Serialize(result, _WriteIndentedJsonSerializerOptions);
|
json = JsonSerializer.Serialize(result, _WriteIndentedJsonSerializerOptions);
|
||||||
if (populateId && Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches: true, compareBeforeWrite: true))
|
if (populateId && Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches: true, compareBeforeWrite: true))
|
||||||
{
|
{
|
||||||
@ -406,7 +388,7 @@ public class A_Property
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SavePropertyParallelForWork(Shared.Models.Methods.IThumbHasher? thumbHasher, string sourceDirectory, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<Tuple<string, DateTime>> sourceDirectoryChanges, Item item)
|
private void SavePropertyParallelForWork(string sourceDirectory, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<Tuple<string, DateTime>> sourceDirectoryChanges, Item item)
|
||||||
{
|
{
|
||||||
Shared.Models.Property property;
|
Shared.Models.Property property;
|
||||||
List<string> parseExceptions = new();
|
List<string> parseExceptions = new();
|
||||||
@ -417,7 +399,7 @@ public class A_Property
|
|||||||
File.Move(item.ImageFileHolder.FullName, filteredSourceDirectoryFileExtensionLowered);
|
File.Move(item.ImageFileHolder.FullName, filteredSourceDirectoryFileExtensionLowered);
|
||||||
if (item.FileSizeChanged is null || item.FileSizeChanged.Value || item.LastWriteTimeChanged is null || item.LastWriteTimeChanged.Value || item.Property is null)
|
if (item.FileSizeChanged is null || item.FileSizeChanged.Value || item.LastWriteTimeChanged is null || item.LastWriteTimeChanged.Value || item.Property is null)
|
||||||
{
|
{
|
||||||
property = GetPropertyOfPrivate(thumbHasher, item, sourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidMetadataExtensions);
|
property = GetPropertyOfPrivate(item, sourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidMetadataExtensions);
|
||||||
lock (sourceDirectoryChanges)
|
lock (sourceDirectoryChanges)
|
||||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
||||||
lock (item)
|
lock (item)
|
||||||
@ -425,7 +407,7 @@ public class A_Property
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SavePropertyParallelWork(int maxDegreeOfParallelism, Shared.Models.Methods.IThumbHasher? thumbHasher, List<Exception> exceptions, List<Tuple<string, DateTime>> sourceDirectoryChanges, Container container, List<Item> items, string message)
|
private void SavePropertyParallelWork(int maxDegreeOfParallelism, List<Exception> exceptions, List<Tuple<string, DateTime>> sourceDirectoryChanges, Container container, List<Item> items, string message)
|
||||||
{
|
{
|
||||||
List<Tuple<string, DateTime>> sourceDirectoryFileTuples = new();
|
List<Tuple<string, DateTime>> sourceDirectoryFileTuples = new();
|
||||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
|
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
|
||||||
@ -438,7 +420,7 @@ public class A_Property
|
|||||||
long ticks = DateTime.Now.Ticks;
|
long ticks = DateTime.Now.Ticks;
|
||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
List<Tuple<string, DateTime>> collection;
|
List<Tuple<string, DateTime>> collection;
|
||||||
SavePropertyParallelForWork(thumbHasher, container.SourceDirectory, sourceDirectoryChanges, sourceDirectoryFileTuples, items[i]);
|
SavePropertyParallelForWork(container.SourceDirectory, sourceDirectoryChanges, sourceDirectoryFileTuples, items[i]);
|
||||||
if (i == 0 || sourceDirectoryChanges.Any())
|
if (i == 0 || sourceDirectoryChanges.Any())
|
||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
lock (sourceDirectoryFileTuples)
|
lock (sourceDirectoryFileTuples)
|
||||||
@ -507,7 +489,7 @@ public class A_Property
|
|||||||
SetAngleBracketCollection(container.SourceDirectory, anyNullOrNoIsUniqueFileName);
|
SetAngleBracketCollection(container.SourceDirectory, anyNullOrNoIsUniqueFileName);
|
||||||
totalSeconds = (int)Math.Truncate(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
totalSeconds = (int)Math.Truncate(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||||
message = $"{i + 1:000} [{container.Items.Count:000}] / {containersLength:000} - {total} / {t} total - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
message = $"{i + 1:000} [{container.Items.Count:000}] / {containersLength:000} - {total} / {t} total - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
||||||
SavePropertyParallelWork(_MaxDegreeOfParallelism, thumbHasher, exceptions, sourceDirectoryChanges, container, container.Items, message);
|
SavePropertyParallelWork(_MaxDegreeOfParallelism, exceptions, sourceDirectoryChanges, container, container.Items, message);
|
||||||
foreach (Exception exception in exceptions)
|
foreach (Exception exception in exceptions)
|
||||||
_Log.Error(string.Concat(container.SourceDirectory, Environment.NewLine, exception.Message, Environment.NewLine, exception.StackTrace), exception);
|
_Log.Error(string.Concat(container.SourceDirectory, Environment.NewLine, exception.Message, Environment.NewLine, exception.StackTrace), exception);
|
||||||
if (exceptions.Count == container.Items.Count)
|
if (exceptions.Count == container.Items.Count)
|
||||||
@ -528,7 +510,7 @@ public class A_Property
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shared.Models.Property GetProperty(Shared.Models.Methods.IThumbHasher? thumbHasher, Item item, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<string> parseExceptions)
|
public Shared.Models.Property GetProperty(Item item, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<string> parseExceptions)
|
||||||
{
|
{
|
||||||
Shared.Models.Property result;
|
Shared.Models.Property result;
|
||||||
bool angleBracketCollectionAny = _AngleBracketCollection.Any();
|
bool angleBracketCollectionAny = _AngleBracketCollection.Any();
|
||||||
@ -540,7 +522,7 @@ public class A_Property
|
|||||||
}
|
}
|
||||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
bool isIgnoreExtension = item.IsValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||||
result = GetPropertyOfPrivate(thumbHasher, item, sourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidMetadataExtensions);
|
result = GetPropertyOfPrivate(item, sourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidMetadataExtensions);
|
||||||
if (!angleBracketCollectionAny)
|
if (!angleBracketCollectionAny)
|
||||||
_AngleBracketCollection.Clear();
|
_AngleBracketCollection.Clear();
|
||||||
return result;
|
return result;
|
||||||
|
@ -16,7 +16,6 @@ public interface IProperty
|
|||||||
public string? Make { init; get; }
|
public string? Make { init; get; }
|
||||||
public string? Model { init; get; }
|
public string? Model { init; get; }
|
||||||
public string? Orientation { init; get; }
|
public string? Orientation { init; get; }
|
||||||
public byte[]? ThumbHashBytes { init; get; }
|
|
||||||
public int? Width { init; get; }
|
public int? Width { init; get; }
|
||||||
|
|
||||||
}
|
}
|
@ -19,11 +19,10 @@ public class Property : Properties.IProperty
|
|||||||
public string? Make { init; get; }
|
public string? Make { init; get; }
|
||||||
public string? Model { init; get; }
|
public string? Model { init; get; }
|
||||||
public string? Orientation { init; get; }
|
public string? Orientation { init; get; }
|
||||||
public byte[]? ThumbHashBytes { init; get; }
|
|
||||||
public int? Width { init; get; }
|
public int? Width { init; get; }
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Property(DateTime creationTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeFromName, DateTime? dateTimeOriginal, long fileSize, DateTime? gpsDateStamp, int? height, int? id, DateTime lastWriteTime, string? make, string? model, string? orientation, byte[]? thumbHashBytes, int? width)
|
public Property(DateTime creationTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeFromName, DateTime? dateTimeOriginal, long fileSize, DateTime? gpsDateStamp, int? height, int? id, DateTime lastWriteTime, string? make, string? model, string? orientation, int? width)
|
||||||
{
|
{
|
||||||
DateTimeFromName = dateTimeFromName;
|
DateTimeFromName = dateTimeFromName;
|
||||||
CreationTime = creationTime;
|
CreationTime = creationTime;
|
||||||
@ -38,7 +37,6 @@ public class Property : Properties.IProperty
|
|||||||
Make = make;
|
Make = make;
|
||||||
Model = model;
|
Model = model;
|
||||||
Orientation = orientation;
|
Orientation = orientation;
|
||||||
ThumbHashBytes = thumbHashBytes;
|
|
||||||
Width = width;
|
Width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +168,7 @@ public class UnitTestResize
|
|||||||
Assert.IsNotNull(item.ImageFileHolder);
|
Assert.IsNotNull(item.ImageFileHolder);
|
||||||
if (item.Property is null)
|
if (item.Property is null)
|
||||||
{
|
{
|
||||||
Shared.Models.Methods.IThumbHasher? thumbHasher = new ThumbHash.Models.C2_ThumbHasher();
|
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
|
||||||
property = propertyLogic.GetProperty(thumbHasher, item, subFileTuples, parseExceptions);
|
|
||||||
item.Update(property);
|
item.Update(property);
|
||||||
}
|
}
|
||||||
if (property is null || item.Property is null)
|
if (property is null || item.Property is null)
|
||||||
|
@ -242,8 +242,7 @@ public class UnitTestFace
|
|||||||
Assert.IsNotNull(item.ImageFileHolder);
|
Assert.IsNotNull(item.ImageFileHolder);
|
||||||
if (item.Property is null)
|
if (item.Property is null)
|
||||||
{
|
{
|
||||||
Shared.Models.Methods.IThumbHasher? thumbHasher = new ThumbHash.Models.C2_ThumbHasher();
|
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
|
||||||
property = propertyLogic.GetProperty(thumbHasher, item, subFileTuples, parseExceptions);
|
|
||||||
item.Update(property);
|
item.Update(property);
|
||||||
}
|
}
|
||||||
if (property is null || item.Property is null)
|
if (property is null || item.Property is null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user