This commit is contained in:
2023-10-15 09:51:56 -07:00
parent 2cd2c2b434
commit cd5ab223c9
75 changed files with 895 additions and 722 deletions

View File

@ -281,7 +281,7 @@ internal abstract partial class XDirectory
}
}
internal static (bool, int?) GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder)
internal static (bool, int?) GetId(short sortOrderOnlyLengthIndex, Models.FileHolder fileHolder)
{
int? id;
short? multiplier;
@ -319,13 +319,13 @@ internal abstract partial class XDirectory
return (nameWithoutExtensionIsIdFormat, id);
}
private static SortedRecord[] GetSortedRecords(List<string[]> filesCollection)
private static SortedRecord[] GetSortedRecords(int offset, List<string[]> filesCollection)
{
List<SortedRecord> results = new();
int? id;
Models.FileHolder fileHolder;
bool nameWithoutExtensionIsIdFormat;
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
short sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex(offset);
foreach (string[] files in filesCollection)
{
foreach (string file in files)
@ -357,10 +357,9 @@ internal abstract partial class XDirectory
Models.FileHolder fileHolder;
List<int> distinctIds = new();
List<string> distinct = new();
int offset = IDirectory.GetOffset();
List<string> distinctDirectories = new();
int intMinValueLength = int.MinValue.ToString().Length;
SortedRecord[] sortedRecords = GetSortedRecords(filesCollection);
SortedRecord[] sortedRecords = GetSortedRecords(propertyConfiguration.Offset, filesCollection);
string? alternateResultAllInOne = !propertyConfiguration.ResultAllInOne.Contains(' ') ? null : propertyConfiguration.ResultAllInOne.Replace(' ', '-');
for (int i = 0; i < sortedRecords.Length; i++)
{
@ -390,7 +389,7 @@ internal abstract partial class XDirectory
}
if (ifCanUseId && sortedRecord.NameWithoutExtensionIsIdFormat && sortedRecord.Id is not null && fileHolder.DirectoryName is not null)
{
paddedId = IDirectory.GetPaddedId(intMinValueLength, offset + i, sortedRecord.Id.Value);
paddedId = IDirectory.GetPaddedId(intMinValueLength, propertyConfiguration.Offset + i, sortedRecord.Id.Value);
paddedIdFile = Path.Combine(fileHolder.DirectoryName, $"{paddedId}{fileHolder.ExtensionLowered}");
if (!File.Exists(paddedIdFile))
{
@ -462,9 +461,9 @@ internal abstract partial class XDirectory
foreach ((Models.FileHolder fileHolder, string? alternateFile, string to) in toDoCollection)
{
tick?.Invoke();
if (alternateFile is not null)
_ = XPath.WriteAllText(alternateFile, fileHolder.FullName, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
fileInfo = new(to);
if (!fileInfo.Exists && alternateFile is not null)
_ = XPath.WriteAllText(alternateFile, fileHolder.FullName, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
if (fileInfo.Exists)
{
if (fileHolder.Length != fileInfo.Length || fileHolder.LastWriteTime != fileInfo.LastWriteTime)