a
This commit is contained in:
@ -5,6 +5,7 @@ public interface IPropertyConfiguration
|
||||
|
||||
public string DateGroup { init; get; }
|
||||
public string[] IgnoreExtensions { init; get; }
|
||||
public string[] IgnoreRulesKeyWords { init; get; }
|
||||
public string PersonBirthdayFormat { init; get; }
|
||||
public bool PropertiesChangedForProperty { init; get; }
|
||||
public string[] PropertyContentCollectionFiles { init; get; }
|
||||
@ -17,6 +18,7 @@ public interface IPropertyConfiguration
|
||||
public string? ModelName { get; }
|
||||
public int? NumberOfJitters { get; }
|
||||
public int? NumberOfTimesToUpsample { get; }
|
||||
public int Offset { init; get; }
|
||||
public string? PredictorModelName { get; }
|
||||
public string RootDirectory { get; }
|
||||
|
||||
|
@ -11,4 +11,4 @@ public record Relation(int DistancePermyriad, string File)
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -12,4 +12,4 @@ public record RelationContainer(FileHolder FileHolder, ReadOnlyCollection<Relati
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -3,13 +3,10 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
public interface IDirectory
|
||||
{
|
||||
|
||||
static int GetOffset() =>
|
||||
1000000;
|
||||
|
||||
int TestStatic_GetSortOrderOnlyLengthIndex() =>
|
||||
GetSortOrderOnlyLengthIndex();
|
||||
static int GetSortOrderOnlyLengthIndex() =>
|
||||
GetOffset().ToString().Length + 3;
|
||||
short TestStatic_GetSortOrderOnlyLengthIndex(int offset) =>
|
||||
GetSortOrderOnlyLengthIndex(offset);
|
||||
static short GetSortOrderOnlyLengthIndex(int offset) =>
|
||||
(short)(offset.ToString().Length + 3);
|
||||
|
||||
char TestStatic_GetDirectory(string fileName) =>
|
||||
GetDirectory(fileName);
|
||||
@ -84,14 +81,14 @@ public interface IDirectory
|
||||
static List<string> CopyOrMove(List<(Models.FileHolder, string?, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
||||
XDirectory.CopyOrMove(toDoCollection, move, moveBack, tick);
|
||||
|
||||
(bool, int?) TestStatic_GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
||||
(bool, int?) TestStatic_GetId(short sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
||||
GetId(sortOrderOnlyLengthIndex, fileHolder);
|
||||
static (bool, int?) GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
||||
static (bool, int?) GetId(short sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
||||
XDirectory.GetId(sortOrderOnlyLengthIndex, fileHolder);
|
||||
|
||||
(bool, int?) TestStatic_GetId(Models.FileHolder fileHolder) =>
|
||||
GetId(fileHolder);
|
||||
static (bool, int?) GetId(Models.FileHolder fileHolder) =>
|
||||
XDirectory.GetId(GetSortOrderOnlyLengthIndex(), fileHolder);
|
||||
(bool, int?) TestStatic_GetId(int offset, Models.FileHolder fileHolder) =>
|
||||
GetId(offset, fileHolder);
|
||||
static (bool, int?) GetId(int offset, Models.FileHolder fileHolder) =>
|
||||
XDirectory.GetId(GetSortOrderOnlyLengthIndex(offset), fileHolder);
|
||||
|
||||
}
|
@ -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)
|
||||
|
@ -286,8 +286,9 @@ internal abstract class XPath
|
||||
internal static Dictionary<string, string[]> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories)
|
||||
{
|
||||
Dictionary<string, string[]> results = new();
|
||||
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||
string directory;
|
||||
string checkDirectory;
|
||||
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||
int plusOne = converted + 1;
|
||||
List<string> collection = new();
|
||||
if (directories is not null)
|
||||
@ -308,10 +309,11 @@ internal abstract class XPath
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne);
|
||||
if (i == converted)
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(directory, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||
else
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(directory, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||
}
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
|
Reference in New Issue
Block a user