Bug fix from

Single Level AppSettings
This commit is contained in:
Mike Phares 2025-01-04 15:35:03 -07:00
parent 17532d2698
commit 0fa899f65d
8 changed files with 49 additions and 16 deletions

4
.gitignore vendored
View File

@ -470,5 +470,7 @@ globalStorage/
Shared/.kanbn Shared/.kanbn
.vscode/Har-Files .vscode/Har-Files
Rename/.vscode/.UserSecrets/secrets.json
Compare/.vscode/.UserSecrets/secrets.json Compare/.vscode/.UserSecrets/secrets.json
Rename/.vscode/.UserSecrets/secrets.json
Rename/.vscode/.UserSecretsOld/rename.json
Rename/.vscode/.UserSecretsOld/secrets.json

5
.vscode/mklink.md vendored
View File

@ -23,6 +23,11 @@ mklink /J "L:\Git\AA\Rename\.vscode\.UserSecrets" "C:\Users\mikep\AppData\Roamin
mklink /J "L:\Git\AA\Compare\.vscode\.UserSecrets" "C:\Users\mikep\AppData\Roaming\Microsoft\UserSecrets\770b6ae3-266e-4d5f-970a-173709b064de" mklink /J "L:\Git\AA\Compare\.vscode\.UserSecrets" "C:\Users\mikep\AppData\Roaming\Microsoft\UserSecrets\770b6ae3-266e-4d5f-970a-173709b064de"
``` ```
```bash 1736011475498 = 638716082754980000 = Sat Jan 04 2025 10:24:35 GMT-0700 (Mountain Standard Time)
mklink /J "L:\Git\AA\Rename\.vscode\.UserSecrets" "C:\Users\mikep\AppData\Roaming\Microsoft\UserSecrets\843db3e1-e18f-4cba-8b00-967529a32635"
mklink /J "L:\Git\AA\Compare\.vscode\.UserSecrets" "C:\Users\mikep\AppData\Roaming\Microsoft\UserSecrets\770b6ae3-266e-4d5f-970a-173709b064de"
```
```json 1735493575037 = 638710903750370000 = Sun Dec 29 2024 10:32:54 GMT-0700 (Mountain Standard Time) ```json 1735493575037 = 638710903750370000 = Sun Dec 29 2024 10:32:54 GMT-0700 (Mountain Standard Time)
{ "label": "Build-Compare", "command": "dotnet", "type": "process", "args": [ "build", "${workspaceFolder}/Compare/AA.Compare.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], "problemMatcher": "$msCompile" }, { "label": "Build-Compare", "command": "dotnet", "type": "process", "args": [ "build", "${workspaceFolder}/Compare/AA.Compare.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], "problemMatcher": "$msCompile" },
{ "label": "Build-Distance", "command": "dotnet", "type": "process", "args": [ "build", "${workspaceFolder}/Distance/AA.Distance.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], "problemMatcher": "$msCompile" }, { "label": "Build-Distance", "command": "dotnet", "type": "process", "args": [ "build", "${workspaceFolder}/Distance/AA.Distance.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], "problemMatcher": "$msCompile" },

View File

@ -56,8 +56,8 @@ internal static class MappedLogicA
PersonContainer? personContainer; PersonContainer? personContainer;
string? personDisplayDirectoryName; string? personDisplayDirectoryName;
results.AddRange(GetDisplayDirectoryAllFiles(peopleSettings, compareSettings, readOnlyCollections)); results.AddRange(GetDisplayDirectoryAllFiles(peopleSettings, compareSettings, readOnlyCollections));
ReadOnlyDictionary<long, PersonContainer> keyValuePairs = PersonContainer.Extract(readOnlyCollections.PersonContainers);
PersonKeyFormattedAndKeyTicksAndDisplayDirectoryName personKeyFormattedAndKeyTicksAndDisplayDirectoryName; PersonKeyFormattedAndKeyTicksAndDisplayDirectoryName personKeyFormattedAndKeyTicksAndDisplayDirectoryName;
ReadOnlyDictionary<long, PersonContainer> keyValuePairs = PersonContainer.Extract(readOnlyCollections.PersonContainers);
foreach (MappedLogicB.Record record in records) foreach (MappedLogicB.Record record in records)
{ {
personBirthday = IPersonBirthday.GetPersonBirthday(peopleSettings.PersonBirthdayFormat, record.PersonKeyFormatted); personBirthday = IPersonBirthday.GetPersonBirthday(peopleSettings.PersonBirthdayFormat, record.PersonKeyFormatted);
@ -65,8 +65,8 @@ internal static class MappedLogicA
continue; continue;
if (distinct.Contains(record.MappedFaceFilePath.Name)) if (distinct.Contains(record.MappedFaceFilePath.Name))
continue; continue;
distinct.Add(record.MappedFaceFilePath.Name);
personKey = personBirthday.Value.Ticks; personKey = personBirthday.Value.Ticks;
distinct.Add(record.MappedFaceFilePath.Name);
if (!keyValuePairs.TryGetValue(personKey, out personContainer)) if (!keyValuePairs.TryGetValue(personKey, out personContainer))
personDisplayDirectoryName = record.PersonDisplayDirectoryName; personDisplayDirectoryName = record.PersonDisplayDirectoryName;
else else

View File

@ -2,7 +2,6 @@ using MetadataExtractor;
using MetadataExtractor.Formats.Exif; using MetadataExtractor.Formats.Exif;
using MetadataExtractor.Formats.Exif.Makernotes; using MetadataExtractor.Formats.Exif.Makernotes;
using System.Globalization; using System.Globalization;
using View_by_Distance.Metadata.Models.Stateless;
namespace View_by_Distance.Metadata.Models.Stateless; namespace View_by_Distance.Metadata.Models.Stateless;

View File

@ -39,6 +39,7 @@ internal static class Get
FileInfo fileInfo; FileInfo fileInfo;
ExifDirectory exifDirectory; ExifDirectory exifDirectory;
MetadataGroup metadataGroup; MetadataGroup metadataGroup;
DeterministicHashCode deterministicHashCode;
FileHolder fileHolder = FileHolder.Get(file); FileHolder fileHolder = FileHolder.Get(file);
bool fastForwardMovingPictureExpertsGroupUsed; bool fastForwardMovingPictureExpertsGroupUsed;
FilePath? fastForwardMovingPictureExpertsGroupFilePath; FilePath? fastForwardMovingPictureExpertsGroupFilePath;
@ -50,12 +51,17 @@ internal static class Get
if (!renameSettings.SkipIdFiles || filePath.Id is null || (!filePath.IsIntelligentIdFormat && filePath.SortOrder is not null)) if (!renameSettings.SkipIdFiles || filePath.Id is null || (!filePath.IsIntelligentIdFormat && filePath.SortOrder is not null))
{ {
if (filePath.Id is not null) if (filePath.Id is not null)
{
fastForwardMovingPictureExpertsGroupFiles = null; fastForwardMovingPictureExpertsGroupFiles = null;
deterministicHashCode = new(null, filePath.Id, null);
}
else else
{ {
fastForwardMovingPictureExpertsGroupFiles = rename.ConvertAndGetFastForwardMovingPictureExpertsGroupFiles(renameSettings, filePath); fastForwardMovingPictureExpertsGroupFiles = rename.ConvertAndGetFastForwardMovingPictureExpertsGroupFiles(renameSettings, filePath);
fastForwardMovingPictureExpertsGroupFilePath = fastForwardMovingPictureExpertsGroupFiles.Count == 0 ? null : FilePath.Get(resultSettings, metadataSettings, FileHolder.Get(fastForwardMovingPictureExpertsGroupFiles[0]), index: null); fastForwardMovingPictureExpertsGroupFilePath = fastForwardMovingPictureExpertsGroupFiles.Count == 0 ? null : FilePath.Get(resultSettings, metadataSettings, FileHolder.Get(fastForwardMovingPictureExpertsGroupFiles[0]), index: null);
deterministicHashCode = fastForwardMovingPictureExpertsGroupFilePath is null ? rename.GetDeterministicHashCode(filePath) : rename.GetDeterministicHashCode(fastForwardMovingPictureExpertsGroupFilePath);
} }
filePath = FilePath.Get(filePath, deterministicHashCode);
fastForwardMovingPictureExpertsGroupUsed = fastForwardMovingPictureExpertsGroupFiles is not null && fastForwardMovingPictureExpertsGroupFiles.Count > 0; fastForwardMovingPictureExpertsGroupUsed = fastForwardMovingPictureExpertsGroupFiles is not null && fastForwardMovingPictureExpertsGroupFiles.Count > 0;
(fileInfo, exifDirectory) = metadata.GetMetadataCollection(resultSettings, metadataSettings, filePath); (fileInfo, exifDirectory) = metadata.GetMetadataCollection(resultSettings, metadataSettings, filePath);
metadataGroup = new(fastForwardMovingPictureExpertsGroupUsed, filePath, fileInfo, exifDirectory, new([])); metadataGroup = new(fastForwardMovingPictureExpertsGroupUsed, filePath, fileInfo, exifDirectory, new([]));

View File

@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<UserSecretsId>fa0fa59b-afe4-4960-9afc-18fcbc7fb41b</UserSecretsId> <UserSecretsIdOld>fa0fa59b-afe4-4960-9afc-18fcbc7fb41b</UserSecretsIdOld>
<UserSecretsId>843db3e1-e18f-4cba-8b00-967529a32635</UserSecretsId>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<PackageId>Phares.View.by.Distance.Rename</PackageId> <PackageId>Phares.View.by.Distance.Rename</PackageId>

View File

@ -175,6 +175,7 @@ public partial class Rename : IRename, IDisposable
string directoryName; string directoryName;
ExifDirectory exifDirectory; ExifDirectory exifDirectory;
List<FileHolder> sidecarFiles; List<FileHolder> sidecarFiles;
DeterministicHashCode deterministicHashCode;
bool fastForwardMovingPictureExpertsGroupUsed; bool fastForwardMovingPictureExpertsGroupUsed;
FilePath? fastForwardMovingPictureExpertsGroupFilePath; FilePath? fastForwardMovingPictureExpertsGroupFilePath;
ReadOnlyCollection<string>? fastForwardMovingPictureExpertsGroupFiles; ReadOnlyCollection<string>? fastForwardMovingPictureExpertsGroupFiles;
@ -203,6 +204,7 @@ public partial class Rename : IRename, IDisposable
if (!appSettings.RenameSettings.ForceNewId && filePath.Id is not null) if (!appSettings.RenameSettings.ForceNewId && filePath.Id is not null)
{ {
fastForwardMovingPictureExpertsGroupFiles = null; fastForwardMovingPictureExpertsGroupFiles = null;
deterministicHashCode = new(null, filePath.Id, null);
directoryName = Path.GetFileName(filePath.DirectoryFullPath); directoryName = Path.GetFileName(filePath.DirectoryFullPath);
if (appSettings.RenameSettings.InPlaceWithOriginalName || (appSettings.RenameSettings.InPlace && directoryName.EndsWith(filePath.Id.Value.ToString()))) if (appSettings.RenameSettings.InPlaceWithOriginalName || (appSettings.RenameSettings.InPlace && directoryName.EndsWith(filePath.Id.Value.ToString())))
continue; continue;
@ -211,8 +213,10 @@ public partial class Rename : IRename, IDisposable
{ {
fastForwardMovingPictureExpertsGroupFiles = rename.ConvertAndGetFastForwardMovingPictureExpertsGroupFiles(appSettings.RenameSettings, filePath); fastForwardMovingPictureExpertsGroupFiles = rename.ConvertAndGetFastForwardMovingPictureExpertsGroupFiles(appSettings.RenameSettings, filePath);
fastForwardMovingPictureExpertsGroupFilePath = fastForwardMovingPictureExpertsGroupFiles.Count == 0 ? null : FilePath.Get(appSettings.ResultSettings, appSettings.MetadataSettings, FileHolder.Get(fastForwardMovingPictureExpertsGroupFiles[0]), index); fastForwardMovingPictureExpertsGroupFilePath = fastForwardMovingPictureExpertsGroupFiles.Count == 0 ? null : FilePath.Get(appSettings.ResultSettings, appSettings.MetadataSettings, FileHolder.Get(fastForwardMovingPictureExpertsGroupFiles[0]), index);
deterministicHashCode = fastForwardMovingPictureExpertsGroupFilePath is null ? rename.GetDeterministicHashCode(filePath) : rename.GetDeterministicHashCode(fastForwardMovingPictureExpertsGroupFilePath);
} }
sidecarFiles = []; sidecarFiles = [];
filePath = FilePath.Get(filePath, deterministicHashCode);
for (int i = 0; i < keyValuePair.Value.Count; i++) for (int i = 0; i < keyValuePair.Value.Count; i++)
{ {
if (keyValuePair.Value[i].ExtensionLowered == fileHolder.ExtensionLowered) if (keyValuePair.Value[i].ExtensionLowered == fileHolder.ExtensionLowered)
@ -331,10 +335,10 @@ public partial class Rename : IRename, IDisposable
{ {
string tfw = GetTFW(record, isWrongYear); string tfw = GetTFW(record, isWrongYear);
string? maker = IMetadata.GetMaker(record.ExifDirectory); string? maker = IMetadata.GetMaker(record.ExifDirectory);
string[] segments = checkDirectoryName.Split(years, StringSplitOptions.None);
string? splat = checkDirectoryName[^3..][1] == '!' ? checkDirectoryName[^3..] : null;
(int seasonValue, string seasonName) = IDate.GetSeason(record.DateTime.DayOfYear);
string rootDirectory = appSettings.ResultSettings.RootDirectory; string rootDirectory = appSettings.ResultSettings.RootDirectory;
string[] segments = checkDirectoryName.Split(years, StringSplitOptions.None);
(int seasonValue, string seasonName) = IDate.GetSeason(record.DateTime.DayOfYear);
string? splat = checkDirectoryName.Length > 3 && checkDirectoryName[^3..][1] == '!' ? checkDirectoryName[^3..] : null;
string contains = record.ExifDirectory.FilePath.Id is null || ids.Contains(record.ExifDirectory.FilePath.Id.Value) ? "_ Exists _" : "_ New-Destination _"; string contains = record.ExifDirectory.FilePath.Id is null || ids.Contains(record.ExifDirectory.FilePath.Id.Value) ? "_ Exists _" : "_ New-Destination _";
string makerSplit = string.IsNullOrEmpty(maker) ? string.IsNullOrEmpty(appSettings.RenameSettings.DefaultMaker) ? string.Empty : appSettings.RenameSettings.DefaultMaker : $" {maker.Split(' ')[0]}"; string makerSplit = string.IsNullOrEmpty(maker) ? string.IsNullOrEmpty(appSettings.RenameSettings.DefaultMaker) ? string.Empty : appSettings.RenameSettings.DefaultMaker : $" {maker.Split(' ')[0]}";
string directoryName = GetDirectoryName(year, tfw, segments[0], splat, seasonValue, seasonName, makerSplit); string directoryName = GetDirectoryName(year, tfw, segments[0], splat, seasonValue, seasonName, makerSplit);

View File

@ -38,7 +38,7 @@ public record FilePath(long CreationTicks,
throw new NullReferenceException(nameof(fileHolder.Length)); throw new NullReferenceException(nameof(fileHolder.Length));
FilePath result; FilePath result;
int? id; int? id;
int? sortOder; int? sortOrder;
string fileNameFirstSegment = fileHolder.Name.Split('.')[0]; string fileNameFirstSegment = fileHolder.Name.Split('.')[0];
int sortOrderOnlyLengthIndex = metadataSettings.Offset.ToString().Length; int sortOrderOnlyLengthIndex = metadataSettings.Offset.ToString().Length;
string fileDirectoryFullPath = fileHolder.DirectoryFullPath ?? throw new NullReferenceException(); string fileDirectoryFullPath = fileHolder.DirectoryFullPath ?? throw new NullReferenceException();
@ -48,15 +48,15 @@ public record FilePath(long CreationTicks,
bool? hasIgnoreKeyword = !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'; bool? hasDateTimeOriginal = !isIntelligentIdFormat && !isPaddedIntelligentIdFormat ? null : fileNameFirstSegment[^1] is '1' or '9';
if (!fileNameFirstSegmentIsIdFormat && !isIntelligentIdFormat && !isPaddedIntelligentIdFormat) if (!fileNameFirstSegmentIsIdFormat && !isIntelligentIdFormat && !isPaddedIntelligentIdFormat)
(id, sortOder) = (null, null); (id, sortOrder) = (null, null);
else if (isIntelligentIdFormat) else if (isIntelligentIdFormat)
(id, sortOder) = (IId.GetId(resultSettings, metadataSettings, fileNameFirstSegment), null); (id, sortOrder) = (IId.GetId(resultSettings, metadataSettings, fileNameFirstSegment), null);
else if (isPaddedIntelligentIdFormat) else if (isPaddedIntelligentIdFormat)
{ {
if (!int.TryParse(fileNameFirstSegment[..sortOrderOnlyLengthIndex], out int absoluteValueOfSortOrder)) if (!int.TryParse(fileNameFirstSegment[..sortOrderOnlyLengthIndex], out int absoluteValueOfSortOrder))
(id, sortOder) = (null, null); (id, sortOrder) = (null, null);
else else
(id, sortOder) = (IId.GetId(resultSettings, metadataSettings, fileNameFirstSegment[sortOrderOnlyLengthIndex..]), absoluteValueOfSortOrder); (id, sortOrder) = (IId.GetId(resultSettings, metadataSettings, fileNameFirstSegment[sortOrderOnlyLengthIndex..]), absoluteValueOfSortOrder);
} }
else if (fileNameFirstSegmentIsIdFormat) else if (fileNameFirstSegmentIsIdFormat)
{ {
@ -64,7 +64,7 @@ public record FilePath(long CreationTicks,
throw new NullReferenceException(nameof(index)); throw new NullReferenceException(nameof(index));
if (!int.TryParse(fileNameFirstSegment, out int valueOfFileNameFirstSegment)) if (!int.TryParse(fileNameFirstSegment, out int valueOfFileNameFirstSegment))
throw new NotSupportedException(); throw new NotSupportedException();
(id, sortOder) = (valueOfFileNameFirstSegment, metadataSettings.Offset + index); (id, sortOrder) = (valueOfFileNameFirstSegment, metadataSettings.Offset + index);
} }
else else
throw new NotSupportedException(); throw new NotSupportedException();
@ -81,10 +81,26 @@ public record FilePath(long CreationTicks,
fileHolder.Length.Value, fileHolder.Length.Value,
fileHolder.Name, fileHolder.Name,
fileHolder.NameWithoutExtension, fileHolder.NameWithoutExtension,
sortOder); sortOrder);
return result; return result;
} }
public static FilePath Get(FilePath filePath, DeterministicHashCode deterministicHashCode) =>
new(filePath.CreationTicks,
filePath.DirectoryFullPath,
filePath.ExtensionLowered,
filePath.FileNameFirstSegment,
filePath.FullName,
deterministicHashCode.Id ?? filePath.Id,
filePath.HasIgnoreKeyword,
filePath.HasDateTimeOriginal,
filePath.IsIntelligentIdFormat,
filePath.LastWriteTicks,
filePath.Length,
filePath.Name,
filePath.NameWithoutExtension,
filePath.SortOrder);
} }
[JsonSourceGenerationOptions(WriteIndented = true)] [JsonSourceGenerationOptions(WriteIndented = true)]