logger for !9
xmp and json sidecar support Alignment with Phares 8.0.118.14905 for Shared and Metadata A_Metadata Parameter constructors Removed force-property-last-write-time-to-creation-time House Cleaning
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
@ -27,7 +28,26 @@ internal abstract class Id
|
||||
internal static byte GetHasIgnoreKeyword(FilePath filePath) =>
|
||||
(byte)(filePath.Id > -1 ? 8 : 2);
|
||||
|
||||
internal static int GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId)
|
||||
internal static byte GetHasDateTimeOriginal(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
(byte)(IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, filePath) ? filePath.Id > -1 ? 6 : 4 : filePath.Id > -1 ? 9 : 1);
|
||||
|
||||
private static string GetExtension(string nameWithoutExtension, string extensionLowered) =>
|
||||
extensionLowered is not ".xmp" and not ".json" ? extensionLowered : Path.GetExtension(nameWithoutExtension);
|
||||
|
||||
private static string GetExtension(FilePath filePath) =>
|
||||
GetExtension(filePath.NameWithoutExtension, filePath.ExtensionLowered);
|
||||
|
||||
private static bool IsIgnoreOrValidVideoFormatExtension(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, GetExtension(filePath));
|
||||
|
||||
private static bool IsIgnoreOrValidVideoFormatExtension(IPropertyConfiguration propertyConfiguration, string extensionLowered) =>
|
||||
propertyConfiguration.IgnoreExtensions.Contains(extensionLowered)
|
||||
|| propertyConfiguration.ValidVideoFormatExtensions.Contains(extensionLowered);
|
||||
|
||||
internal static byte GetMissingDateTimeOriginal(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
(byte)(IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, filePath) ? filePath.Id > -1 ? 5 : 0 : filePath.Id > -1 ? 7 : 3);
|
||||
|
||||
internal static int GetId(IPropertyConfiguration propertyConfiguration, string intelligentId)
|
||||
{
|
||||
int result;
|
||||
StringBuilder results = new();
|
||||
@ -44,13 +64,7 @@ internal abstract class Id
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static byte GetHasDateTimeOriginal(Properties.IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
(byte)(propertyConfiguration.IgnoreExtensions.Contains(filePath.ExtensionLowered) || propertyConfiguration.ValidVideoFormatExtensions.Contains(filePath.ExtensionLowered) ? filePath.Id > -1 ? 6 : 4 : filePath.Id > -1 ? 9 : 1);
|
||||
|
||||
internal static byte GetMissingDateTimeOriginal(Properties.IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
(byte)(propertyConfiguration.IgnoreExtensions.Contains(filePath.ExtensionLowered) || propertyConfiguration.ValidVideoFormatExtensions.Contains(filePath.ExtensionLowered) ? filePath.Id > -1 ? 5 : 0 : filePath.Id > -1 ? 7 : 3);
|
||||
|
||||
internal static bool NameWithoutExtensionIsIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameWithoutExtension)
|
||||
internal static bool NameWithoutExtensionIsIdFormat(IPropertyConfiguration propertyConfiguration, string fileNameWithoutExtension)
|
||||
{
|
||||
bool result;
|
||||
if (fileNameWithoutExtension.Length < 5 || fileNameWithoutExtension.Length > propertyConfiguration.IntMinValueLength)
|
||||
@ -63,7 +77,7 @@ internal abstract class Id
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal)
|
||||
internal static string GetIntelligentId(IPropertyConfiguration propertyConfiguration, long id, string nameWithoutExtension, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal)
|
||||
{
|
||||
string result;
|
||||
StringBuilder stringBuilder = new();
|
||||
@ -79,18 +93,20 @@ internal abstract class Id
|
||||
}
|
||||
else if (id > -1)
|
||||
{
|
||||
if (!propertyConfiguration.ValidVideoFormatExtensions.Contains(extensionLowered))
|
||||
key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 8 : hasDateTimeOriginal.Value ? 9 : 7;
|
||||
else
|
||||
string checkExtension = GetExtension(nameWithoutExtension, extensionLowered);
|
||||
if (IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, checkExtension))
|
||||
key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? throw new NotImplementedException() : hasDateTimeOriginal.Value ? 6 : 5;
|
||||
else
|
||||
key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 8 : hasDateTimeOriginal.Value ? 9 : 7;
|
||||
value = id.ToString().PadLeft(propertyConfiguration.IntMinValueLength, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!propertyConfiguration.ValidVideoFormatExtensions.Contains(extensionLowered))
|
||||
key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 2 : hasDateTimeOriginal.Value ? 1 : 3;
|
||||
else
|
||||
string checkExtension = GetExtension(nameWithoutExtension, extensionLowered);
|
||||
if (IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, checkExtension))
|
||||
key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? throw new NotImplementedException() : hasDateTimeOriginal.Value ? 4 : 0;
|
||||
else
|
||||
key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 2 : hasDateTimeOriginal.Value ? 1 : 3;
|
||||
value = id.ToString()[1..].PadLeft(propertyConfiguration.IntMinValueLength, '0');
|
||||
}
|
||||
for (int i = value.Length - propertyConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--)
|
||||
@ -101,14 +117,51 @@ internal abstract class Id
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index)
|
||||
internal static string GetIntelligentId(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
filePath.Id is null ? throw new Exception() : GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.NameWithoutExtension, filePath.ExtensionLowered, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal);
|
||||
|
||||
internal static string GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, int? index)
|
||||
{
|
||||
string result;
|
||||
if (propertyConfiguration.Offset < 0)
|
||||
result = Guid.NewGuid().ToString();
|
||||
else
|
||||
{
|
||||
string intelligentId = GetIntelligentId(propertyConfiguration, id, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal);
|
||||
string intelligentId = GetIntelligentId(propertyConfiguration, filePath);
|
||||
int check = GetId(propertyConfiguration, intelligentId);
|
||||
if (filePath.Id is not null && check != filePath.Id.Value)
|
||||
throw new NotSupportedException();
|
||||
result = index is null || propertyConfiguration.Offset == IId.DeterministicHashCode ? intelligentId : $"{propertyConfiguration.Offset + index}{intelligentId}";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string? GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index)
|
||||
{
|
||||
string? result;
|
||||
if (filePath.Id is null)
|
||||
result = null;
|
||||
else if (propertyConfiguration.Offset < 0)
|
||||
result = Guid.NewGuid().ToString();
|
||||
else
|
||||
{
|
||||
string intelligentId = GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.NameWithoutExtension, filePath.ExtensionLowered, hasIgnoreKeyword, hasDateTimeOriginal);
|
||||
int check = GetId(propertyConfiguration, intelligentId);
|
||||
if (filePath.Id is not null && check != filePath.Id.Value)
|
||||
throw new NotSupportedException();
|
||||
result = index is null || propertyConfiguration.Offset == IId.DeterministicHashCode ? intelligentId : $"{propertyConfiguration.Offset + index}{intelligentId}";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetPaddedId(IPropertyConfiguration propertyConfiguration, int id, string nameWithoutExtension, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index)
|
||||
{
|
||||
string result;
|
||||
if (propertyConfiguration.Offset < 0)
|
||||
result = Guid.NewGuid().ToString();
|
||||
else
|
||||
{
|
||||
string intelligentId = GetIntelligentId(propertyConfiguration, id, nameWithoutExtension, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal);
|
||||
int check = GetId(propertyConfiguration, intelligentId);
|
||||
if (check != id)
|
||||
throw new NotSupportedException();
|
||||
|
Reference in New Issue
Block a user