IsOffsetDeterministicHashCode
This commit is contained in:
@ -3,6 +3,11 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
public interface IId
|
||||
{ // ...
|
||||
|
||||
const int DeterministicHashCode = 9876543;
|
||||
|
||||
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) =>
|
||||
|
@ -73,7 +73,7 @@ internal abstract class Id
|
||||
int check = GetId(propertyConfiguration, intelligentId);
|
||||
if (check != id)
|
||||
throw new NotSupportedException();
|
||||
result = index is null || propertyConfiguration.Offset == 9876543 ? intelligentId : $"{propertyConfiguration.Offset + index}{intelligentId}";
|
||||
result = index is null || propertyConfiguration.Offset == IId.DeterministicHashCode ? intelligentId : $"{propertyConfiguration.Offset + index}{intelligentId}";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -301,6 +301,7 @@ internal abstract partial class XDirectory
|
||||
Models.FileHolder fileHolder;
|
||||
List<string> distinctDirectories = [];
|
||||
FilePath[] sortedRecords = GetSortedRecords(propertyConfiguration, filesCollection);
|
||||
bool isOffsetDeterministicHashCode = IId.IsOffsetDeterministicHashCode(propertyConfiguration);
|
||||
for (int i = 0; i < sortedRecords.Length; i++)
|
||||
{
|
||||
tick?.Invoke();
|
||||
@ -342,7 +343,21 @@ 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);
|
||||
checkFile = Path.Combine(directory, $"{intelligentId}{filePath.ExtensionLowered}");
|
||||
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);
|
||||
paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}");
|
||||
if (File.Exists(paddedIdFile))
|
||||
continue;
|
||||
File.Move(filePath.FullName, paddedIdFile);
|
||||
if (!paddedCheck)
|
||||
paddedCheck = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((filePath.Id is not null && distinctIds.Contains(filePath.Id.Value)) || distinct.Contains(checkFile))
|
||||
{
|
||||
@ -380,6 +395,8 @@ internal abstract partial class XDirectory
|
||||
if (!distinctDirectories.Contains(directory))
|
||||
distinctDirectories.Add(directory);
|
||||
}
|
||||
if (isOffsetDeterministicHashCode)
|
||||
throw new Exception("Change Configuration Offset when ready to sort images!");
|
||||
if (paddedCheck)
|
||||
throw new Exception("Maybe need to restart application!");
|
||||
return (distinctDirectories.ToArray(), results);
|
||||
|
Reference in New Issue
Block a user