Prep for item.FilePath.HasIgnoreKeyword, item.FilePath.HasDateTimeOriginal
This commit is contained in:
parent
86b13dc00f
commit
9c253786a9
@ -681,7 +681,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
|||||||
if (distinct.Contains(item.Property.Id.Value))
|
if (distinct.Contains(item.Property.Id.Value))
|
||||||
continue;
|
continue;
|
||||||
distinct.Add(item.Property.Id.Value);
|
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));
|
identifiers.Add(new(item.Property.Id.Value, paddedId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ public class Rename
|
|||||||
{
|
{
|
||||||
if (record.Id is null)
|
if (record.Id is null)
|
||||||
continue;
|
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;
|
checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered;
|
||||||
checkFile = Path.Combine(seasonDirectory, $"{paddedId}{checkFileExtension}");
|
checkFile = Path.Combine(seasonDirectory, $"{paddedId}{checkFileExtension}");
|
||||||
if (checkFile == fileHolder.FullName)
|
if (checkFile == fileHolder.FullName)
|
||||||
|
@ -10,7 +10,8 @@ public record FilePath(long CreationTicks,
|
|||||||
string FileNameFirstSegment,
|
string FileNameFirstSegment,
|
||||||
string FullName,
|
string FullName,
|
||||||
int? Id,
|
int? Id,
|
||||||
bool? IsIgnore,
|
bool? HasIgnoreKeyword,
|
||||||
|
bool? HasDateTimeOriginal,
|
||||||
bool IsIntelligentIdFormat,
|
bool IsIntelligentIdFormat,
|
||||||
long LastWriteTicks,
|
long LastWriteTicks,
|
||||||
long Length,
|
long Length,
|
||||||
@ -42,7 +43,8 @@ public record FilePath(long CreationTicks,
|
|||||||
bool isIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment);
|
bool isIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment);
|
||||||
bool isPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(propertyConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
bool isPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(propertyConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
||||||
bool fileNameFirstSegmentIsIdFormat = !isPaddedIntelligentIdFormat && !isIntelligentIdFormat && IId.NameWithoutExtensionIsIdFormat(propertyConfiguration, fileHolder);
|
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)
|
if (!fileNameFirstSegmentIsIdFormat && !isIntelligentIdFormat && !isPaddedIntelligentIdFormat)
|
||||||
(id, sortOder) = (null, null);
|
(id, sortOder) = (null, null);
|
||||||
else if (isIntelligentIdFormat)
|
else if (isIntelligentIdFormat)
|
||||||
@ -70,7 +72,8 @@ public record FilePath(long CreationTicks,
|
|||||||
fileNameFirstSegment,
|
fileNameFirstSegment,
|
||||||
fileHolder.FullName,
|
fileHolder.FullName,
|
||||||
id,
|
id,
|
||||||
isIgnore,
|
hasIgnoreKeyword,
|
||||||
|
hasDateTimeOriginal,
|
||||||
isIntelligentIdFormat,
|
isIntelligentIdFormat,
|
||||||
fileHolder.LastWriteTime.Value.Ticks,
|
fileHolder.LastWriteTime.Value.Ticks,
|
||||||
fileHolder.Length.Value,
|
fileHolder.Length.Value,
|
||||||
|
@ -83,8 +83,6 @@ internal abstract class Container
|
|||||||
bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(filePath.ExtensionLowered);
|
bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(filePath.ExtensionLowered);
|
||||||
if (property is not null && property.Keywords is not null)
|
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));
|
bool shouldIgnore = propertyConfiguration.IgnoreRulesKeyWords.Any(l => property.Keywords.Contains(l));
|
||||||
if (shouldIgnore)
|
if (shouldIgnore)
|
||||||
{
|
{
|
||||||
@ -92,7 +90,7 @@ internal abstract class Container
|
|||||||
if (!fileInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
if (!fileInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
||||||
File.SetAttributes(imageFileHolder.FullName, 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"))
|
if (filePath.DirectoryName.Contains("Results") && filePath.DirectoryName.Contains("Resize"))
|
||||||
File.Delete(filePath.FullName);
|
File.Delete(filePath.FullName);
|
||||||
|
@ -8,20 +8,20 @@ public interface IId
|
|||||||
static bool IsOffsetDeterministicHashCode(Properties.IPropertyConfiguration propertyConfiguration) =>
|
static bool IsOffsetDeterministicHashCode(Properties.IPropertyConfiguration propertyConfiguration) =>
|
||||||
propertyConfiguration.Offset == DeterministicHashCode;
|
propertyConfiguration.Offset == DeterministicHashCode;
|
||||||
|
|
||||||
string TestStatic_GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore) =>
|
string TestStatic_GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) =>
|
||||||
GetIntelligentId(propertyConfiguration, id, ignore);
|
GetIntelligentId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal);
|
||||||
static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore) =>
|
static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) =>
|
||||||
Id.GetIntelligentId(propertyConfiguration, id, ignore);
|
Id.GetIntelligentId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal);
|
||||||
|
|
||||||
int TestStatic_GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
|
int TestStatic_GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
|
||||||
GetId(propertyConfiguration, intelligentId);
|
GetId(propertyConfiguration, intelligentId);
|
||||||
static int GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
|
static int GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
|
||||||
Id.GetId(propertyConfiguration, intelligentId);
|
Id.GetId(propertyConfiguration, intelligentId);
|
||||||
|
|
||||||
string TestStatic_GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index) =>
|
string TestStatic_GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) =>
|
||||||
GetPaddedId(propertyConfiguration, id, ignore, index);
|
GetPaddedId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal, index);
|
||||||
static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index) =>
|
static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) =>
|
||||||
Id.GetPaddedId(propertyConfiguration, id, ignore, index);
|
Id.GetPaddedId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal, index);
|
||||||
|
|
||||||
string TestStatic_GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
|
string TestStatic_GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
|
||||||
GetIgnoreFullPath(filePath, fileHolder);
|
GetIgnoreFullPath(filePath, fileHolder);
|
||||||
|
@ -35,7 +35,7 @@ internal abstract class Id
|
|||||||
return result;
|
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;
|
string result;
|
||||||
StringBuilder stringBuilder = new();
|
StringBuilder stringBuilder = new();
|
||||||
@ -46,12 +46,12 @@ internal abstract class Id
|
|||||||
List<char> resultAllInOneSubdirectoryChars = [];
|
List<char> resultAllInOneSubdirectoryChars = [];
|
||||||
if (id > -1)
|
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');
|
value = id.ToString().PadLeft(propertyConfiguration.IntMinValueLength, '0');
|
||||||
}
|
}
|
||||||
else
|
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');
|
value = id.ToString()[1..].PadLeft(propertyConfiguration.IntMinValueLength, '0');
|
||||||
}
|
}
|
||||||
for (int i = value.Length - propertyConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--)
|
for (int i = value.Length - propertyConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--)
|
||||||
@ -62,14 +62,14 @@ internal abstract class Id
|
|||||||
return result;
|
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;
|
string result;
|
||||||
if (propertyConfiguration.Offset < 0)
|
if (propertyConfiguration.Offset < 0)
|
||||||
result = Guid.NewGuid().ToString();
|
result = Guid.NewGuid().ToString();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string intelligentId = GetIntelligentId(propertyConfiguration, id, ignore);
|
string intelligentId = GetIntelligentId(propertyConfiguration, id, hasIgnoreKeyword, hasDateTimeOriginal);
|
||||||
int check = GetId(propertyConfiguration, intelligentId);
|
int check = GetId(propertyConfiguration, intelligentId);
|
||||||
if (check != id)
|
if (check != id)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
|
@ -331,7 +331,7 @@ internal abstract partial class XDirectory
|
|||||||
}
|
}
|
||||||
if (ifCanUseId && filePath.IsIntelligentIdFormat && filePath.Id is not null && filePath.DirectoryName is not null)
|
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}");
|
paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}");
|
||||||
if (!File.Exists(paddedIdFile))
|
if (!File.Exists(paddedIdFile))
|
||||||
{
|
{
|
||||||
@ -349,14 +349,14 @@ internal abstract partial class XDirectory
|
|||||||
{
|
{
|
||||||
if (filePath.Id is null)
|
if (filePath.Id is null)
|
||||||
throw new NullReferenceException(nameof(filePath.Id));
|
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)
|
if (!isOffsetDeterministicHashCode)
|
||||||
checkFile = Path.Combine(directory, $"{intelligentId}{filePath.ExtensionLowered}");
|
checkFile = Path.Combine(directory, $"{intelligentId}{filePath.ExtensionLowered}");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (filePath.DirectoryName is null)
|
if (filePath.DirectoryName is null)
|
||||||
continue;
|
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}");
|
paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}");
|
||||||
if (File.Exists(paddedIdFile))
|
if (File.Exists(paddedIdFile))
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user