diff --git a/Instance/DlibDotNet.cs b/Instance/DlibDotNet.cs index 6965d8a..f27e7b8 100644 --- a/Instance/DlibDotNet.cs +++ b/Instance/DlibDotNet.cs @@ -681,7 +681,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable if (distinct.Contains(item.Property.Id.Value)) continue; distinct.Add(item.Property.Id.Value); - paddedId = IId.GetPaddedId(propertyConfiguration, item.Property.Id.Value, item.FilePath.IsIgnore, index: null); + paddedId = IId.GetPaddedId(propertyConfiguration, item.Property.Id.Value, item.FilePath.HasIgnoreKeyword, item.FilePath.HasDateTimeOriginal, index: null); identifiers.Add(new(item.Property.Id.Value, paddedId)); } } diff --git a/Rename/Rename.cs b/Rename/Rename.cs index 6f7be64..6c3181e 100644 --- a/Rename/Rename.cs +++ b/Rename/Rename.cs @@ -402,7 +402,7 @@ public class Rename { if (record.Id is null) continue; - paddedId = IId.GetPaddedId(_PropertyConfiguration, record.Id.Value, ignore: null, record.Index); + paddedId = IId.GetPaddedId(_PropertyConfiguration, record.Id.Value, hasIgnoreKeyword: null, hasDateTimeOriginal: null, record.Index); checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered; checkFile = Path.Combine(seasonDirectory, $"{paddedId}{checkFileExtension}"); if (checkFile == fileHolder.FullName) diff --git a/Shared/Models/FilePath.cs b/Shared/Models/FilePath.cs index c562c6d..20c5b14 100644 --- a/Shared/Models/FilePath.cs +++ b/Shared/Models/FilePath.cs @@ -10,7 +10,8 @@ public record FilePath(long CreationTicks, string FileNameFirstSegment, string FullName, int? Id, - bool? IsIgnore, + bool? HasIgnoreKeyword, + bool? HasDateTimeOriginal, bool IsIntelligentIdFormat, long LastWriteTicks, long Length, @@ -42,7 +43,8 @@ public record FilePath(long CreationTicks, bool isIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment); bool isPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(propertyConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment); bool fileNameFirstSegmentIsIdFormat = !isPaddedIntelligentIdFormat && !isIntelligentIdFormat && IId.NameWithoutExtensionIsIdFormat(propertyConfiguration, fileHolder); - bool? isIgnore = !isIntelligentIdFormat && !isPaddedIntelligentIdFormat ? null : fileNameFirstSegment[^1] is '2' or '8'; + bool? hasIgnoreKeyword = !isIntelligentIdFormat && !isPaddedIntelligentIdFormat ? null : fileNameFirstSegment[^1] is '2' or '8'; + bool? hasDateTimeOriginal = !isIntelligentIdFormat && !isPaddedIntelligentIdFormat ? null : fileNameFirstSegment[^1] is '1' or '9'; if (!fileNameFirstSegmentIsIdFormat && !isIntelligentIdFormat && !isPaddedIntelligentIdFormat) (id, sortOder) = (null, null); else if (isIntelligentIdFormat) @@ -70,7 +72,8 @@ public record FilePath(long CreationTicks, fileNameFirstSegment, fileHolder.FullName, id, - isIgnore, + hasIgnoreKeyword, + hasDateTimeOriginal, isIntelligentIdFormat, fileHolder.LastWriteTime.Value.Ticks, fileHolder.Length.Value, diff --git a/Shared/Models/Stateless/Methods/Container.cs b/Shared/Models/Stateless/Methods/Container.cs index 83f44f5..a3508b5 100644 --- a/Shared/Models/Stateless/Methods/Container.cs +++ b/Shared/Models/Stateless/Methods/Container.cs @@ -83,8 +83,6 @@ internal abstract class Container bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(filePath.ExtensionLowered); if (property is not null && property.Keywords is not null) { - if (filePath.IsIgnore is null) - throw new NullReferenceException(); bool shouldIgnore = propertyConfiguration.IgnoreRulesKeyWords.Any(l => property.Keywords.Contains(l)); if (shouldIgnore) { @@ -92,7 +90,7 @@ internal abstract class Container if (!fileInfo.Attributes.HasFlag(FileAttributes.Hidden)) File.SetAttributes(imageFileHolder.FullName, FileAttributes.Hidden); } - if (filePath.IsIgnore.Value != shouldIgnore) + if (filePath.HasIgnoreKeyword is not null && filePath.HasIgnoreKeyword.Value != shouldIgnore) { if (filePath.DirectoryName.Contains("Results") && filePath.DirectoryName.Contains("Resize")) File.Delete(filePath.FullName); diff --git a/Shared/Models/Stateless/Methods/IId.cs b/Shared/Models/Stateless/Methods/IId.cs index f8c0318..64668fd 100644 --- a/Shared/Models/Stateless/Methods/IId.cs +++ b/Shared/Models/Stateless/Methods/IId.cs @@ -8,20 +8,20 @@ public interface IId static bool IsOffsetDeterministicHashCode(Properties.IPropertyConfiguration propertyConfiguration) => propertyConfiguration.Offset == DeterministicHashCode; - string TestStatic_GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore) => - GetIntelligentId(propertyConfiguration, id, ignore); - static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore) => - Id.GetIntelligentId(propertyConfiguration, id, ignore); + string TestStatic_GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) => + GetIntelligentId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal); + static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) => + Id.GetIntelligentId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal); int TestStatic_GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) => GetId(propertyConfiguration, intelligentId); static int GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) => Id.GetId(propertyConfiguration, intelligentId); - string TestStatic_GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index) => - GetPaddedId(propertyConfiguration, id, ignore, index); - static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index) => - Id.GetPaddedId(propertyConfiguration, id, ignore, index); + string TestStatic_GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => + GetPaddedId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal, index); + static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => + Id.GetPaddedId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal, index); string TestStatic_GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) => GetIgnoreFullPath(filePath, fileHolder); diff --git a/Shared/Models/Stateless/Methods/Id.cs b/Shared/Models/Stateless/Methods/Id.cs index e6893a7..a0edf5b 100644 --- a/Shared/Models/Stateless/Methods/Id.cs +++ b/Shared/Models/Stateless/Methods/Id.cs @@ -35,7 +35,7 @@ internal abstract class Id return result; } - internal static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore) + internal static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) { string result; StringBuilder stringBuilder = new(); @@ -46,12 +46,12 @@ internal abstract class Id List resultAllInOneSubdirectoryChars = []; if (id > -1) { - key = ignore is not null && ignore.Value ? 8 : 9; + key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 8 : 9; value = id.ToString().PadLeft(propertyConfiguration.IntMinValueLength, '0'); } else { - key = ignore is not null && ignore.Value ? 2 : 1; + key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 2 : 1; value = id.ToString()[1..].PadLeft(propertyConfiguration.IntMinValueLength, '0'); } for (int i = value.Length - propertyConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--) @@ -62,14 +62,14 @@ internal abstract class Id return result; } - internal static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index) + internal static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) { string result; if (propertyConfiguration.Offset < 0) result = Guid.NewGuid().ToString(); else { - string intelligentId = GetIntelligentId(propertyConfiguration, id, ignore); + string intelligentId = GetIntelligentId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal); int check = GetId(propertyConfiguration, intelligentId); if (check != id) throw new NotSupportedException(); diff --git a/Shared/Models/Stateless/Methods/XDirectory.cs b/Shared/Models/Stateless/Methods/XDirectory.cs index 5159a02..0b3f49a 100644 --- a/Shared/Models/Stateless/Methods/XDirectory.cs +++ b/Shared/Models/Stateless/Methods/XDirectory.cs @@ -331,7 +331,7 @@ internal abstract partial class XDirectory } if (ifCanUseId && filePath.IsIntelligentIdFormat && filePath.Id is not null && filePath.DirectoryName is not null) { - paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.IsIgnore, i); + paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal, i); paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}"); if (!File.Exists(paddedIdFile)) { @@ -349,14 +349,14 @@ internal abstract partial class XDirectory { if (filePath.Id is null) throw new NullReferenceException(nameof(filePath.Id)); - intelligentId = IId.GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.IsIgnore); + intelligentId = IId.GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal); if (!isOffsetDeterministicHashCode) checkFile = Path.Combine(directory, $"{intelligentId}{filePath.ExtensionLowered}"); else { if (filePath.DirectoryName is null) continue; - paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.IsIgnore, i); + paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal, i); paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}"); if (File.Exists(paddedIdFile)) continue;