Instance UserSecretsId and BlurHash for 1376 x 768
This commit is contained in:
@ -349,6 +349,28 @@ public partial class DlibDotNet
|
||||
return result;
|
||||
}
|
||||
|
||||
private void LogItemPropertyIsNull(Item item)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
if (!item.SourceDirectoryFileHolder.Exists)
|
||||
_Log.Information(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
|
||||
else if (item.FileSizeChanged.HasValue && item.FileSizeChanged.Value)
|
||||
_Log.Information(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
|
||||
else if (item.LastWriteTimeChanged.HasValue && item.LastWriteTimeChanged.Value)
|
||||
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
|
||||
else if (item.Moved.HasValue && item.Moved.Value)
|
||||
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
|
||||
}
|
||||
|
||||
private void LogNameWithoutExtensionIsIdFormatBut(Item item)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
_Log.Information($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
|
||||
File.Move(item.ImageFileHolder.FullName, $"{item.ImageFileHolder.FullName}.rename");
|
||||
}
|
||||
|
||||
private void FullParallelForWork(A_Property propertyLogic,
|
||||
B_Metadata metadata,
|
||||
ReadOnlyDictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers,
|
||||
@ -366,8 +388,6 @@ public partial class DlibDotNet
|
||||
bool? isIgnoreRelativePath,
|
||||
string facePartsCollectionDirectory)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
List<Shared.Models.Face> faces;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
@ -376,56 +396,10 @@ public partial class DlibDotNet
|
||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||
List<KeyValuePair<string, string>> metadataCollection;
|
||||
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(item);
|
||||
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)
|
||||
{
|
||||
_ = _BlurHasher?.EncodeAndSave(resizedFileHolder);
|
||||
// if (item.Property.Width.Value < -255 && item.Property.Height.Value < -255)
|
||||
// {
|
||||
// MemoryStream memoryStream = _ThumbHasher.GetMemoryStream(Array.Empty<byte>(), item.Property.Width.Value, item.Property.Height.Value);
|
||||
// string thumbHashJson = JsonSerializer.Serialize(Array.Empty<byte>())[1..^1];
|
||||
// if (!Regex.Matches(thumbHashJson, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]").Any())
|
||||
// fileName = Path.Combine(c2HasherSingletonDirectory, $"{thumbHashJson}.png");
|
||||
// else
|
||||
// {
|
||||
// // string thumbHash = BitConverter.ToString(Array.Empty<byte>()).Replace("-", string.Empty);
|
||||
// // fileName = Path.Combine(c2HasherContentDirectory, $"{thumbHash}.png");
|
||||
// fileName = Path.Combine(c2HasherContentDirectory, $"{resizedFileHolder.NameWithoutExtension}.png");
|
||||
// }
|
||||
// if (!File.Exists(fileName))
|
||||
// {
|
||||
// using FileStream fileStream = new(fileName, FileMode.CreateNew);
|
||||
// memoryStream.WriteTo(fileStream);
|
||||
// memoryStream.Dispose();
|
||||
// if (resizedFileHolder.LastWriteTime is not null)
|
||||
// File.SetLastWriteTime(fileName, resizedFileHolder.LastWriteTime.Value);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (item.Property is not null && item.Property.Id is not null && !item.Any())
|
||||
{
|
||||
property = item.Property;
|
||||
if (item.SourceDirectoryFileHolder.LastWriteTime is not null)
|
||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
|
||||
else
|
||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
|
||||
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
|
||||
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
|
||||
{
|
||||
_Log.Information($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
|
||||
File.Move(item.ImageFileHolder.FullName, $"{item.ImageFileHolder.FullName}.rename");
|
||||
}
|
||||
}
|
||||
else
|
||||
if (item.Property is null || item.Property.Id is null || item.Any())
|
||||
{
|
||||
LogItemPropertyIsNull(item);
|
||||
int? propertyHashCode = item.Property?.GetHashCode();
|
||||
if (!item.SourceDirectoryFileHolder.Exists)
|
||||
_Log.Information(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
|
||||
else if (item.FileSizeChanged.HasValue && item.FileSizeChanged.Value)
|
||||
_Log.Information(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
|
||||
else if (item.LastWriteTimeChanged.HasValue && item.LastWriteTimeChanged.Value)
|
||||
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
|
||||
else if (item.Moved.HasValue && item.Moved.Value)
|
||||
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
|
||||
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
|
||||
item.Update(property);
|
||||
if (propertyHashCode is null)
|
||||
@ -439,6 +413,23 @@ public partial class DlibDotNet
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property = item.Property;
|
||||
if (item.SourceDirectoryFileHolder.LastWriteTime is not null)
|
||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
|
||||
else
|
||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
|
||||
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
|
||||
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
|
||||
LogNameWithoutExtensionIsIdFormatBut(item);
|
||||
if (_BlurHasher is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Width.Value > 4 && _Configuration.SaveBlurHashForOutputResolutions.Contains(outputResolution))
|
||||
{
|
||||
string? file = _BlurHasher.GetFile(resizedFileHolder);
|
||||
if (file is not null && !File.Exists(file))
|
||||
_ = _BlurHasher.EncodeAndSave(resizedFileHolder);
|
||||
}
|
||||
}
|
||||
if (property is null || item.Property is null)
|
||||
throw new NullReferenceException(nameof(property));
|
||||
item.SetResizedFileHolder(_Resize.FileNameExtension, resizedFileHolder);
|
||||
|
Reference in New Issue
Block a user