Season breakout

DirectoryName to DirectoryFullPath
This commit is contained in:
2024-11-02 14:24:28 -07:00
parent 444e7ed71a
commit 4da353d150
23 changed files with 91 additions and 109 deletions

View File

@ -92,7 +92,7 @@ internal abstract class Container
}
if (filePath.HasIgnoreKeyword is not null && filePath.HasIgnoreKeyword.Value != shouldIgnore.Value)
{
if (filePath.DirectoryName.Contains("Results") && filePath.DirectoryName.Contains("Resize"))
if (filePath.DirectoryFullPath.Contains("Results") && filePath.DirectoryFullPath.Contains("Resize"))
File.Delete(filePath.FullName);
else
throw new NotSupportedException($"Rename File! <{filePath.FileNameFirstSegment}>");
@ -144,7 +144,7 @@ internal abstract class Container
{
if (filePaths.Count == 0)
continue;
directory = filePaths[0].DirectoryName;
directory = filePaths[0].DirectoryFullPath;
if (directory is null)
continue;
if (!directories.Contains(directory))
@ -159,10 +159,10 @@ internal abstract class Container
List<FilePair> filePairs = GetFilePairs(dlibDotNet, propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, filePathsCollection, directorySearchFilter);
foreach (FilePair filePair in filePairs)
{
if (!directoryToItems.TryGetValue(filePair.FilePath.DirectoryName, out items))
if (!directoryToItems.TryGetValue(filePair.FilePath.DirectoryFullPath, out items))
{
directoryToItems.Add(filePair.FilePath.DirectoryName, []);
if (!directoryToItems.TryGetValue(filePair.FilePath.DirectoryName, out items))
directoryToItems.Add(filePair.FilePath.DirectoryFullPath, []);
if (!directoryToItems.TryGetValue(filePair.FilePath.DirectoryFullPath, out items))
throw new Exception();
}
items.Add(filePair.Item);

View File

@ -37,7 +37,7 @@ public interface IFileHolder
Get(filePath);
static Models.FileHolder Get(FilePath filePath) =>
new(new(filePath.CreationTicks),
filePath.DirectoryName,
filePath.DirectoryFullPath,
true,
filePath.ExtensionLowered,
filePath.FullName,

View File

@ -26,14 +26,14 @@ public interface IId
string TestStatic_GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
GetIgnoreFullPath(filePath, fileHolder);
static string GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
fileHolder.DirectoryName is null ?
fileHolder.DirectoryFullPath is null ?
throw new NotSupportedException() :
filePath.Id > -1 ?
fileHolder.NameWithoutExtension[^1] == '9' ?
Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}8{fileHolder.ExtensionLowered}") :
Path.Combine(fileHolder.DirectoryFullPath, $"{fileHolder.NameWithoutExtension[..^1]}8{fileHolder.ExtensionLowered}") :
throw new NotSupportedException("High") :
fileHolder.NameWithoutExtension[^1] == '1' ?
Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}2{fileHolder.ExtensionLowered}") :
Path.Combine(fileHolder.DirectoryFullPath, $"{fileHolder.NameWithoutExtension[..^1]}2{fileHolder.ExtensionLowered}") :
throw new NotSupportedException("Low");
bool TestStatic_NameWithoutExtensionIsIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) =>

View File

@ -18,11 +18,6 @@ public interface IProperty
static (int Season, string seasonName) GetSeason(int dayOfYear) =>
Property.GetSeason(dayOfYear);
(int Season, string seasonName) TestStatic_GetSeasonAB(int dayOfYear) =>
GetSeasonAB(dayOfYear);
static (int Season, string seasonName) GetSeasonAB(int dayOfYear) =>
Property.GetSeasonAB(dayOfYear);
string TestStatic_GetDiffRootDirectory(string diffPropertyDirectory) =>
GetDiffRootDirectory(diffPropertyDirectory);
static string GetDiffRootDirectory(string diffPropertyDirectory) =>

View File

@ -8,26 +8,13 @@ internal abstract class Property
(int Season, string seasonName) result = dayOfYear switch
{
< 78 => new(0, "Winter"),
< 171 => new(1, "Spring"),
< 264 => new(2, "Summer"),
< 354 => new(3, "Fall"),
_ => new(4, "Winter")
};
return result;
}
internal static (int Season, string seasonName) GetSeasonAB(int dayOfYear)
{
(int Season, string seasonName) result = dayOfYear switch
{
< 78 => new(0, "WinterA"),
< 124 => new(1, "SpringA"),
< 171 => new(1, "SpringB"),
< 217 => new(2, "SummerA"),
< 264 => new(2, "SummerB"),
< 309 => new(3, "FallA"),
< 354 => new(3, "FallB"),
_ => new(4, "WinterB")
< 124 => new(1, "Spring"),
< 171 => new(2, "Spring"),
< 217 => new(3, "Summer"),
< 264 => new(4, "Summer"),
< 309 => new(5, "Fall"),
< 354 => new(6, "Fall"),
_ => new(7, "Winter")
};
return result;
}

View File

@ -351,10 +351,10 @@ internal abstract partial class XDirectory
{
tick?.Invoke();
filePath = sortedRecords[i];
if (filePath.Name.EndsWith("len") || filePath.ExtensionLowered == ".id" || filePath.ExtensionLowered == ".lsv" || filePath.DirectoryName is null)
if (filePath.Name.EndsWith("len") || filePath.ExtensionLowered == ".id" || filePath.ExtensionLowered == ".lsv" || filePath.DirectoryFullPath is null)
continue;
(_, directoryIndex) = IPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
fileDirectoryName = Path.GetFileName(filePath.DirectoryName);
fileDirectoryName = Path.GetFileName(filePath.DirectoryFullPath);
if (fileDirectoryName.Length < propertyConfiguration.ResultAllInOneSubdirectoryLength + 3 || !filePath.Name.StartsWith(fileDirectoryName))
{
if (wrapped)
@ -367,10 +367,10 @@ internal abstract partial class XDirectory
wrapped = true;
directory = Path.Combine(directories[directoryIndex], fileDirectoryName);
}
if (ifCanUseId && filePath.IsIntelligentIdFormat && filePath.Id is not null && filePath.DirectoryName is not null)
if (ifCanUseId && filePath.IsIntelligentIdFormat && filePath.Id is not null && filePath.DirectoryFullPath is not null)
{
paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal, i);
paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}");
paddedIdFile = Path.Combine(filePath.DirectoryFullPath, $"{paddedId}{filePath.ExtensionLowered}");
if (!File.Exists(paddedIdFile))
{
File.Move(filePath.FullName, paddedIdFile);
@ -392,10 +392,10 @@ internal abstract partial class XDirectory
checkFile = Path.Combine(directory, $"{intelligentId}{filePath.ExtensionLowered}");
else
{
if (filePath.DirectoryName is null)
if (filePath.DirectoryFullPath is null)
continue;
paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal, i);
paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}");
paddedIdFile = Path.Combine(filePath.DirectoryFullPath, $"{paddedId}{filePath.ExtensionLowered}");
if (File.Exists(paddedIdFile))
continue;
File.Move(filePath.FullName, paddedIdFile);
@ -406,7 +406,7 @@ internal abstract partial class XDirectory
}
if ((filePath.Id is not null && distinctIds.Contains(filePath.Id.Value)) || distinct.Contains(checkFile))
{
if (string.IsNullOrEmpty(filePath.DirectoryName))
if (string.IsNullOrEmpty(filePath.DirectoryFullPath))
continue;
if (!copyDuplicates)
continue;