Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
e728838d25 | |||
ac298166e9 | |||
0b793904b3 | |||
e053dd5746 |
5
.vscode/mklink.md
vendored
5
.vscode/mklink.md
vendored
@ -13,3 +13,8 @@ mklink /J "D:\1-Images-A\Images-4083e56a-Results\A2)People\4083e56a\{}\!" "D:\1-
|
||||
```bash
|
||||
mklink /J "L:\Git\View-by-Distance-MKLink-Console\.Immich" "D:\1-Images-A\Images-c9dbce3b-Results\F)Immich\c9dbce3b\{}"
|
||||
```
|
||||
|
||||
```bash 1740946894364 = 638765436943640000 = 2025-0.Winter = Sun Mar 02 2025 13:21:33 GMT-0700 (Mountain Standard Time)
|
||||
mklink /J "V:\Tmp\Phares\Pictures-Results" "V:\6-Other-Large-Z\Current-Results-Test"
|
||||
mklink /J "V:\1-Images-A\Images-0b793904-Results" "V:\6-Other-Large-Z\Current-Results"
|
||||
```
|
||||
|
18
.vscode/tasks.json
vendored
18
.vscode/tasks.json
vendored
@ -72,11 +72,7 @@
|
||||
"build",
|
||||
"${workspaceFolder}/Instance/Instance.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary",
|
||||
"/property:WarningLevel=0",
|
||||
"--verbosity",
|
||||
"quiet",
|
||||
"--no-restore"
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
@ -88,11 +84,7 @@
|
||||
"build",
|
||||
"${workspaceFolder}/Shared/View-by-Distance.Shared.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary",
|
||||
"/property:WarningLevel=0",
|
||||
"--verbosity",
|
||||
"quiet",
|
||||
"--no-restore"
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
@ -104,11 +96,7 @@
|
||||
"build",
|
||||
"${workspaceFolder}/Metadata/Metadata.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary",
|
||||
"/property:WarningLevel=0",
|
||||
"--verbosity",
|
||||
"quiet",
|
||||
"--no-restore"
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -11,20 +11,28 @@ public class C2_BlurHasher : IBlurHasher
|
||||
{
|
||||
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly Dictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultContentFileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultSingletonFileGroups;
|
||||
|
||||
public C2_BlurHasher(IPropertyConfiguration propertyConfiguration)
|
||||
{
|
||||
_FileGroups = [];
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_ResultContentFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
_ResultSingletonFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
}
|
||||
|
||||
public void Update(string resultsFullGroupDirectory)
|
||||
{
|
||||
_FileGroups.Clear();
|
||||
ReadOnlyDictionary<string, ReadOnlyCollection<string>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, resultsFullGroupDirectory, [_PropertyConfiguration.ResultContent, _PropertyConfiguration.ResultSingleton]);
|
||||
foreach (KeyValuePair<string, ReadOnlyCollection<string>> keyValuePair in keyValuePairs)
|
||||
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, resultsFullGroupDirectory, [_PropertyConfiguration.ResultContent, _PropertyConfiguration.ResultSingleton]);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (keyValuePair.Key == _PropertyConfiguration.ResultContent)
|
||||
_ResultContentFileGroups[0] = keyValuePair.Value;
|
||||
else if (keyValuePair.Key == _PropertyConfiguration.ResultSingleton)
|
||||
_ResultSingletonFileGroups[0] = keyValuePair.Value;
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
string IBlurHasher.Encode(FileHolder fileHolder)
|
||||
@ -40,20 +48,39 @@ public class C2_BlurHasher : IBlurHasher
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, string fullFileName)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (File.Exists(checkFile))
|
||||
File.Move(checkFile, fullFileName);
|
||||
}
|
||||
}
|
||||
|
||||
string IBlurHasher.GetFile(FilePath filePath)
|
||||
{
|
||||
string result;
|
||||
if (_FileGroups.Count == 0)
|
||||
if (_ResultSingletonFileGroups[0].Count == 0)
|
||||
throw new Exception("Call Update first!");
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
result = Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{filePath.Name}.csv");
|
||||
string fileName = $"{filePath.Name}.csv";
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
string directory = _ResultSingletonFileGroups[0][cei.Enum][cei.Index];
|
||||
result = Path.Combine(directory, fileName);
|
||||
MoveIf(fileName, cei, directory, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
string IBlurHasher.EncodeAndSave(FilePath filePath, FileHolder fileHolder)
|
||||
{
|
||||
string result;
|
||||
if (_FileGroups.Count == 0)
|
||||
if (_ResultSingletonFileGroups[0].Count == 0)
|
||||
throw new Exception("Call Update first!");
|
||||
int actualByte;
|
||||
string extension = ".png";
|
||||
@ -70,15 +97,18 @@ public class C2_BlurHasher : IBlurHasher
|
||||
byte[] blurHashBytes = Encoding.UTF8.GetBytes(result);
|
||||
string joined = string.Join(string.Empty, blurHashBytes.Select(l => l.ToString("000")));
|
||||
string fileNameWithoutExtension = $"{componentsX}x{componentsY}-{outputWidth}x{outputHeight}-{joined}";
|
||||
string fileName = $"{fileNameWithoutExtension}{extension}";
|
||||
string contents = string.Concat(result, Environment.NewLine, fileNameWithoutExtension, Environment.NewLine, extension);
|
||||
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(file, contents, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
file = Path.Combine(_FileGroups[_PropertyConfiguration.ResultContent][directoryIndex], $"{fileNameWithoutExtension}{extension}");
|
||||
if (!File.Exists(file))
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
string directory = _ResultContentFileGroups[0][cei.Enum][cei.Index];
|
||||
string fullFileName = Path.Combine(directory, fileName);
|
||||
MoveIf(fileName, cei, directory, fullFileName);
|
||||
if (!File.Exists(fullFileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
using FileStream fileStream = new(file, FileMode.CreateNew);
|
||||
using FileStream fileStream = new(fullFileName, FileMode.CreateNew);
|
||||
actualImage.Save(fileStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
_ = fileStream.Seek(0, SeekOrigin.Begin);
|
||||
actualByte = fileStream.ReadByte();
|
||||
|
@ -33,14 +33,14 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.2" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Map\Map.csproj" />
|
||||
|
@ -35,9 +35,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -19,7 +19,7 @@ public class CopyDistinct
|
||||
private readonly IsEnvironment _IsEnvironment;
|
||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||
private readonly ReadOnlyDictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> _FileGroups;
|
||||
|
||||
public CopyDistinct(List<string> args, ILogger<Program> logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
{
|
||||
|
@ -34,15 +34,15 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.2" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -251,11 +251,11 @@ public class DateGroup
|
||||
if (topDirectoryName.Length > 1)
|
||||
_ = destinationDirectoryName.Append(topDirectoryName);
|
||||
if (_Configuration.BySeason)
|
||||
directoryNames.AddRange(new string[] { $"{destinationDirectoryName} {year} {seasonName}" });
|
||||
directoryNames.AddRange([$"{destinationDirectoryName} {year} {seasonName}"]);
|
||||
else if (_Configuration.ByDay)
|
||||
directoryNames.AddRange(new string[] { $"{destinationDirectoryName} {year}", $"{weekOfYear}) {year}-{day}" });
|
||||
directoryNames.AddRange([$"{destinationDirectoryName} {year}", $"{weekOfYear}) {year}-{day}"]);
|
||||
else if (_Configuration.ByWeek)
|
||||
directoryNames.AddRange(new string[] { $"{destinationDirectoryName} {year}", $"{weekOfYear}) {year} {month}" });
|
||||
directoryNames.AddRange([$"{destinationDirectoryName} {year}", $"{weekOfYear}) {year} {month}"]);
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
|
@ -34,14 +34,14 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.2" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -34,14 +34,14 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.2" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -36,7 +36,7 @@
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FaceRecognitionDotNet\FaceRecognitionDotNet.csproj" />
|
||||
|
@ -358,7 +358,7 @@ public partial class E_Distance : IDistance
|
||||
}
|
||||
results.Add(keyValuePair.Key, new(keyValuePairs));
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
public static List<LocationContainer> GetPreFilterLocationContainer(int maxDegreeOfParallelism, Configuration configuration, string focusDirectory, string focusModel, int? skipPersonWithMoreThen, long ticks, MapLogic mapLogic, long[] jLinkResolvedPersonKeys, ReadOnlyDictionary<int, ReadOnlyDictionary<int, LocationContainer>> mapped, List<LocationContainer> available)
|
||||
@ -509,7 +509,7 @@ public partial class E_Distance : IDistance
|
||||
faceDistanceContainer = new(face, faceDistance);
|
||||
collection.Add(faceDistanceContainer);
|
||||
}
|
||||
results = new(collection.ToArray());
|
||||
results = collection.AsReadOnly();
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ public partial class E_Distance : IDistance
|
||||
foreach (KeyValuePair<int, LocationContainer> keyValue in keyValuePair.Value)
|
||||
results.Add(keyValue.Value);
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
public static ReadOnlyCollection<LocationContainer> GetMatrixLocationContainers(IDlibDotNet dlibDotNet, Configuration mapConfiguration, long ticks, MapLogic mapLogic, ReadOnlyDictionary<int, ReadOnlyDictionary<int, LocationContainer>> mappedWithEncoding, List<LocationContainer> preFiltered, DistanceLimits distanceLimits, List<LocationContainer> postFiltered)
|
||||
@ -624,7 +624,7 @@ public partial class E_Distance : IDistance
|
||||
results = ISortingContainer.Sort(results);
|
||||
else
|
||||
results = ISortingContainer.SortUsingDaysDelta(results);
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<RelationContainer> GetRelationCollections(IDistanceLimits distanceLimits, int faceDistancePermyriad, int locationContainerDistanceTake, float distanceTolerance, List<Record> records)
|
||||
@ -672,7 +672,7 @@ public partial class E_Distance : IDistance
|
||||
mappedRelations = (from l in mappedRelations orderby l.DistancePermyriad select l).Take(locationContainerDistanceTake).ToList();
|
||||
results.Add(new(fileHolder, new(mappedRelations)));
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
ReadOnlyCollection<RelationContainer> IDistance.GetRelationContainers(IDistanceLimits distanceLimits, int faceDistancePermyriad, int locationContainerDistanceTake, float locationContainerDistanceTolerance, ReadOnlyCollection<LocationContainer> locationContainers)
|
||||
|
@ -26,9 +26,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -6,10 +6,8 @@ public class Program
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
private static void Main() =>
|
||||
// ApplicationConfiguration.Initialize();
|
||||
Application.Run(new DragDropExplorer());
|
||||
}
|
||||
|
||||
}
|
@ -26,9 +26,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -6,10 +6,8 @@ public class Program
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
private static void Main() =>
|
||||
// ApplicationConfiguration.Initialize();
|
||||
Application.Run(new DragDropMove());
|
||||
}
|
||||
|
||||
}
|
@ -27,9 +27,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FaceRecognitionDotNet\FaceRecognitionDotNet.csproj" />
|
||||
|
@ -8,11 +8,9 @@ public class Program
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
private static void Main() =>
|
||||
// ApplicationConfiguration.Initialize();
|
||||
Application.Run(new DragDropSearch());
|
||||
}
|
||||
|
||||
private static Item[] GetFilterItems(Models.Configuration configuration, Container container)
|
||||
{
|
||||
|
@ -27,9 +27,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Metadata\Metadata.csproj" />
|
||||
|
@ -6,10 +6,8 @@ public class Program
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
private static void Main() =>
|
||||
// ApplicationConfiguration.Initialize();
|
||||
Application.Run(new DragDropSetPropertyItem());
|
||||
}
|
||||
|
||||
}
|
@ -33,14 +33,14 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.2" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -33,7 +33,7 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FaceRecognitionDotNet\FaceRecognitionDotNet.csproj" />
|
||||
|
@ -46,7 +46,8 @@ public class D_Face : IFaceD
|
||||
private readonly EncoderParameters _HiddenEncoderParameters;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly JsonSerializerOptions _WriteIndentedAndWhenWritingNull;
|
||||
private readonly Dictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultContentFileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultCollectionFileGroups;
|
||||
|
||||
public D_Face(
|
||||
string argZero,
|
||||
@ -69,7 +70,6 @@ public class D_Face : IFaceD
|
||||
float[] rectangleIntersectMinimums)
|
||||
{
|
||||
_ArgZero = argZero;
|
||||
_FileGroups = [];
|
||||
_ImageCodecInfo = imageCodecInfo;
|
||||
_EncoderParameters = encoderParameters;
|
||||
_FileNameExtension = filenameExtension;
|
||||
@ -84,6 +84,8 @@ public class D_Face : IFaceD
|
||||
_RectangleIntersectMinimum = rectangleIntersectMinimums.Min();
|
||||
_FaceDistanceHiddenImageFactor = faceDistanceHiddenImageFactor;
|
||||
_ForceFaceLastWriteTimeToCreationTime = forceFaceLastWriteTimeToCreationTime;
|
||||
_ResultContentFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
_ResultCollectionFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
(Model model, PredictorModel predictorModel, ModelParameter modelParameter) = GetModel(modelDirectory, modelName, predictorModelName);
|
||||
_Model = model;
|
||||
_PredictorModel = predictorModel;
|
||||
@ -101,10 +103,16 @@ public class D_Face : IFaceD
|
||||
|
||||
public void Update(string dResultsFullGroupDirectory)
|
||||
{
|
||||
_FileGroups.Clear();
|
||||
ReadOnlyDictionary<string, ReadOnlyCollection<string>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, dResultsFullGroupDirectory, [_PropertyConfiguration.ResultCollection, _PropertyConfiguration.ResultContent]);
|
||||
foreach (KeyValuePair<string, ReadOnlyCollection<string>> keyValuePair in keyValuePairs)
|
||||
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, dResultsFullGroupDirectory, [_PropertyConfiguration.ResultCollection, _PropertyConfiguration.ResultContent]);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (keyValuePair.Key == _PropertyConfiguration.ResultContent)
|
||||
_ResultContentFileGroups[0] = keyValuePair.Value;
|
||||
else if (keyValuePair.Key == _PropertyConfiguration.ResultCollection)
|
||||
_ResultCollectionFileGroups[0] = keyValuePair.Value;
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
private static (Model model, PredictorModel predictorModel, ModelParameter modelParameter) GetModel(string modelDirectory, string modelName, string predictorModelName)
|
||||
@ -295,6 +303,25 @@ public class D_Face : IFaceD
|
||||
|
||||
#pragma warning restore CA1416
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, FileInfo fileInfo)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (File.Exists(checkFile))
|
||||
{
|
||||
File.Move(checkFile, fileInfo.FullName);
|
||||
fileInfo.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Shared.Models.Face> GetFaces(string outputResolution, string cResultsFullGroupDirectory, FilePath filePath, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize, List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection)
|
||||
{
|
||||
List<Shared.Models.Face>? results;
|
||||
@ -302,8 +329,11 @@ public class D_Face : IFaceD
|
||||
List<Location> locations;
|
||||
string[] changesFrom = [nameof(A_Property), nameof(B_Metadata), nameof(C_Resize)];
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultCollection][directoryIndex], $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json"));
|
||||
string fileName = $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json";
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
string directory = _ResultCollectionFileGroups[0][cei.Enum][cei.Index];
|
||||
FileInfo fileInfo = new(Path.Combine(directory, fileName));
|
||||
MoveIf(fileName, cei, directory, fileInfo);
|
||||
if (_ForceFaceLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
@ -366,6 +396,25 @@ public class D_Face : IFaceD
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, DirectoryInfo directoryInfo)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (Directory.Exists(checkFile))
|
||||
{
|
||||
Directory.Move(checkFile, directoryInfo.FullName);
|
||||
directoryInfo.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<(Shared.Models.Face, FileHolder?, string, bool)> SaveFaces(FilePath filePath, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, MappingFromItem mappingFromItem, ExifDirectory exifDirectory, List<Shared.Models.Face> faces)
|
||||
{
|
||||
List<(Shared.Models.Face, FileHolder?, string, bool Save)> results = [];
|
||||
@ -373,11 +422,13 @@ public class D_Face : IFaceD
|
||||
FileInfo fileInfo;
|
||||
FileHolder fileHolder;
|
||||
string deterministicHashCodeKey;
|
||||
string fileName = mappingFromItem.FilePath.NameWithoutExtension;
|
||||
string[] changesFrom = [nameof(A_Property), nameof(B_Metadata), nameof(C_Resize)];
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
string directory = Path.Combine(_FileGroups[_PropertyConfiguration.ResultContent][directoryIndex], mappingFromItem.FilePath.NameWithoutExtension);
|
||||
bool directoryExists = Directory.Exists(directory);
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
string directory = _ResultContentFileGroups[0][cei.Enum][cei.Index];
|
||||
DirectoryInfo directoryInfo = new(Path.Combine(directory, fileName));
|
||||
MoveIf(fileName, cei, directory, directoryInfo);
|
||||
foreach (Shared.Models.Face face in faces)
|
||||
{
|
||||
save = false;
|
||||
@ -387,9 +438,9 @@ public class D_Face : IFaceD
|
||||
continue;
|
||||
}
|
||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(filePath, face.Location, Shared.Models.Stateless.ILocation.Digits, face.OutputResolution);
|
||||
fileInfo = new FileInfo(Path.Combine(directory, $"{deterministicHashCodeKey}{mappingFromItem.FilePath.ExtensionLowered}{_FileNameExtension}"));
|
||||
fileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, $"{deterministicHashCodeKey}{mappingFromItem.FilePath.ExtensionLowered}{_FileNameExtension}"));
|
||||
fileHolder = FileHolder.Get(fileInfo);
|
||||
if (!directoryExists)
|
||||
if (!directoryInfo.Exists)
|
||||
save = true;
|
||||
else if (_OverrideForFaceImages)
|
||||
save = true;
|
||||
@ -397,12 +448,12 @@ public class D_Face : IFaceD
|
||||
save = true;
|
||||
else if (_CheckDFaceAndUpWriteDates && dateTimes.Count > 0 && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
save = true;
|
||||
results.Add(new(face, fileHolder, Path.Combine(directory, $"{deterministicHashCodeKey}{mappingFromItem.FilePath.ExtensionLowered}{_HiddenFileNameExtension}"), save));
|
||||
results.Add(new(face, fileHolder, Path.Combine(directoryInfo.FullName, $"{deterministicHashCodeKey}{mappingFromItem.FilePath.ExtensionLowered}{_HiddenFileNameExtension}"), save));
|
||||
}
|
||||
if (results.Any(l => l.Save))
|
||||
{
|
||||
if (!directoryExists)
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
if (!directoryInfo.Exists)
|
||||
_ = Directory.CreateDirectory(directoryInfo.FullName);
|
||||
SaveFaces(mappingFromItem.ResizedFileHolder, exifDirectory, results);
|
||||
}
|
||||
return results;
|
||||
|
@ -33,7 +33,7 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FaceRecognitionDotNet\FaceRecognitionDotNet.csproj" />
|
||||
|
@ -32,17 +32,17 @@ public class D2_FaceParts
|
||||
private readonly bool _OverrideForFaceLandmarkImages;
|
||||
private readonly EncoderParameters _EncoderParameters;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly Dictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultContentFileGroups;
|
||||
|
||||
public D2_FaceParts(IPropertyConfiguration propertyConfiguration, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension, bool checkDFaceAndUpWriteDates, bool overrideForFaceLandmarkImages)
|
||||
{
|
||||
_FileGroups = [];
|
||||
_ImageCodecInfo = imageCodecInfo;
|
||||
_EncoderParameters = encoderParameters;
|
||||
_FileNameExtension = filenameExtension;
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_CheckDFaceAndUpWriteDates = checkDFaceAndUpWriteDates;
|
||||
_OverrideForFaceLandmarkImages = overrideForFaceLandmarkImages;
|
||||
_ResultContentFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
ConstructorInfo? constructorInfo = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, [], null) ?? throw new Exception();
|
||||
_ConstructorInfo = constructorInfo;
|
||||
}
|
||||
@ -55,10 +55,14 @@ public class D2_FaceParts
|
||||
|
||||
public void Update(string dResultsFullGroupDirectory)
|
||||
{
|
||||
_FileGroups.Clear();
|
||||
ReadOnlyDictionary<string, ReadOnlyCollection<string>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, dResultsFullGroupDirectory, [_PropertyConfiguration.ResultContent]);
|
||||
foreach (KeyValuePair<string, ReadOnlyCollection<string>> keyValuePair in keyValuePairs)
|
||||
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, dResultsFullGroupDirectory, [_PropertyConfiguration.ResultContent]);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (keyValuePair.Key == _PropertyConfiguration.ResultContent)
|
||||
_ResultContentFileGroups[0] = keyValuePair.Value;
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetPointBounds(PointF[] points, out float xMinimum, out float xMaximum, out float yMinimum, out float yMaximum)
|
||||
@ -380,6 +384,25 @@ public class D2_FaceParts
|
||||
|
||||
#pragma warning restore CA1416
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, DirectoryInfo directoryInfo)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (Directory.Exists(checkFile))
|
||||
{
|
||||
Directory.Move(checkFile, directoryInfo.FullName);
|
||||
directoryInfo.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveFaceLandmarkImages(Configuration configuration, string d2ResultsFullGroupDirectory, FilePath filePath, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, MappingFromItem mappingFromItem, ExifDirectory exifDirectory, List<Shared.Models.Face> faces, bool saveRotated)
|
||||
{
|
||||
FileInfo fileInfo;
|
||||
@ -390,11 +413,13 @@ public class D2_FaceParts
|
||||
string deterministicHashCodeKey;
|
||||
bool updateDateWhenMatches = false;
|
||||
List<(Shared.Models.Face, string, string)> collection = [];
|
||||
string fileName = mappingFromItem.FilePath.NameWithoutExtension;
|
||||
string[] changesFrom = [nameof(A_Property), nameof(B_Metadata), nameof(C_Resize), nameof(D_Face)];
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
string directory = Path.Combine(_FileGroups[_PropertyConfiguration.ResultContent][directoryIndex], mappingFromItem.FilePath.NameWithoutExtension);
|
||||
bool directoryExists = Directory.Exists(directory);
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
string directory = _ResultContentFileGroups[0][cei.Enum][cei.Index];
|
||||
DirectoryInfo directoryInfo = new(Path.Combine(directory, mappingFromItem.FilePath.NameWithoutExtension));
|
||||
MoveIf(fileName, cei, directory, directoryInfo);
|
||||
foreach (Shared.Models.Face face in faces)
|
||||
{
|
||||
if (face.FaceEncoding is null || face.Location is null || face.OutputResolution is null)
|
||||
@ -403,14 +428,14 @@ public class D2_FaceParts
|
||||
continue;
|
||||
}
|
||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(filePath, face.Location, Shared.Models.Stateless.ILocation.Digits, face.OutputResolution);
|
||||
fileInfo = new FileInfo(Path.Combine(directory, $"{deterministicHashCodeKey}{mappingFromItem.FilePath.ExtensionLowered}{_FileNameExtension}"));
|
||||
fileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, $"{deterministicHashCodeKey}{mappingFromItem.FilePath.ExtensionLowered}{_FileNameExtension}"));
|
||||
if (string.IsNullOrEmpty(fileInfo.DirectoryName))
|
||||
continue;
|
||||
rotatedFileInfo = new FileInfo(Path.Combine(fileInfo.DirectoryName, $"{deterministicHashCodeKey} - R{mappingFromItem.FilePath.ExtensionLowered}{_FileNameExtension}"));
|
||||
collection.Add(new(face, fileInfo.FullName, rotatedFileInfo.FullName));
|
||||
if (check)
|
||||
continue;
|
||||
else if (!directoryExists)
|
||||
else if (!directoryInfo.Exists)
|
||||
check = true;
|
||||
else if (_OverrideForFaceLandmarkImages)
|
||||
check = true;
|
||||
@ -428,8 +453,8 @@ public class D2_FaceParts
|
||||
}
|
||||
if (check)
|
||||
{
|
||||
if (!directoryExists)
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
if (!directoryInfo.Exists)
|
||||
_ = Directory.CreateDirectory(directoryInfo.FullName);
|
||||
SaveFaceParts(mappingFromItem, exifDirectory, collection);
|
||||
if (saveRotated)
|
||||
SaveRotated(mappingFromItem, collection);
|
||||
|
@ -117,7 +117,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
_MapConfiguration = Get(configuration, _DistanceLimits, _Faces.FileNameExtension, _Faces.HiddenFileNameExtension, _FaceParts.FileNameExtension);
|
||||
_Distance = new(configuration.DistanceMoveUnableToMatch, configuration.DistanceRenameToMatch, configuration.FaceConfidencePercent, configuration.RangeDistanceTolerance, configuration.RectangleIntersectMinimums);
|
||||
if (_PropertyRootExistedBefore || !_ArgZeroIsConfigurationRootDirectory)
|
||||
personContainers = new(new List<PersonContainer>());
|
||||
personContainers = new([]);
|
||||
else
|
||||
{
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
@ -636,37 +636,10 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<int, ReadOnlyCollection<FilePath>> GetKeyValuePairs(ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection)
|
||||
{
|
||||
Dictionary<int, ReadOnlyCollection<FilePath>> results = [];
|
||||
List<FilePath>? collection;
|
||||
Dictionary<int, List<FilePath>> keyValuePairs = [];
|
||||
foreach (ReadOnlyCollection<FilePath> filePaths in filePathsCollection)
|
||||
{
|
||||
if (filePaths.Count == 0)
|
||||
continue;
|
||||
foreach (FilePath filePath in filePaths)
|
||||
{
|
||||
if (filePath.Id is null)
|
||||
continue;
|
||||
if (!keyValuePairs.TryGetValue(filePath.Id.Value, out collection))
|
||||
{
|
||||
keyValuePairs.Add(filePath.Id.Value, []);
|
||||
if (!keyValuePairs.TryGetValue(filePath.Id.Value, out collection))
|
||||
throw new Exception();
|
||||
}
|
||||
collection.Add(filePath);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<int, List<FilePath>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value));
|
||||
return new(results);
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<int, Identifier> GetSplatNineIdentifiersAndHideSplatNine(Property.Models.Configuration propertyConfiguration, string bResultsFullGroupDirectory, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection)
|
||||
{
|
||||
Dictionary<int, Identifier> results = [];
|
||||
ReadOnlyDictionary<int, ReadOnlyCollection<FilePath>> keyValuePairs = GetKeyValuePairs(filePathsCollection);
|
||||
ReadOnlyDictionary<int, ReadOnlyCollection<FilePath>> keyValuePairs = FilePath.GetKeyValuePairs(filePathsCollection);
|
||||
if (keyValuePairs.Count > 0)
|
||||
{
|
||||
string json;
|
||||
@ -711,7 +684,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
json = JsonSerializer.Serialize((from l in identifiers orderby l.DirectoryNames.Length descending, l.Id select l).ToArray(), IdentifierCollectionSourceGenerationContext.Default.IdentifierArray);
|
||||
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(bMetadataCollectionDirectory, ".json"), json.Replace(rootDirectory, string.Empty), updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private ReadOnlyCollection<Mapping> GetMappings(Property.Models.Configuration propertyConfiguration, string eDistanceContentDirectory, ReadOnlyCollection<Container> readOnlyContainers, MapLogic mapLogic, bool distinctItems)
|
||||
@ -768,7 +741,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
}
|
||||
if (_Configuration.MoveToDecade && _Configuration.LocationContainerDistanceTolerance is null)
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static void SavePropertyShortcutsForOutputResolutions(string eDistanceContentDirectory, ReadOnlyCollection<Item> distinctValidImageItems)
|
||||
@ -877,7 +850,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
continue;
|
||||
results.Add(filePath);
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
public ReadOnlyDictionary<string, LocationContainer> GetOnlyOne(IDistanceLimits distanceLimits, ReadOnlyCollection<LocationContainer> matrix)
|
||||
@ -905,7 +878,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
added.Add(locationContainer.LengthSource.Name);
|
||||
results.Add(locationContainer.LengthSource.Name, locationContainer);
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private List<SaveContainer> GetSaveContainers(long ticks, ReadOnlyCollection<PersonContainer> personContainers, string a2PeopleSingletonDirectory, string eDistanceContentDirectory, ProgressBarOptions options, MapLogic mapLogic, string outputResolution)
|
||||
@ -1126,7 +1099,6 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges,
|
||||
Dictionary<int, List<MappingFromPhotoPrism>> fileNameToCollection,
|
||||
Container container,
|
||||
int index,
|
||||
Item item,
|
||||
DateTime[] containerDateTimes,
|
||||
bool? isFocusRelativePath)
|
||||
@ -1309,7 +1281,6 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
sourceDirectoryChanges,
|
||||
fileNameToCollection,
|
||||
container,
|
||||
index: i,
|
||||
filteredItems[i],
|
||||
containerDateTimes,
|
||||
isFocusRelativePath);
|
||||
@ -1491,7 +1462,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable
|
||||
ProgressBar progressBar;
|
||||
string filesCollectionRootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
||||
(string cResultsFullGroupDirectory, _, _, _) = GetResultsFullGroupDirectories(outputResolution);
|
||||
IReadOnlyDictionary<string, ReadOnlyCollection<string>> fileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, [_Configuration.PropertyConfiguration.ResultContent, _Configuration.PropertyConfiguration.ResultContentCollection]);
|
||||
IReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> fileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, [_Configuration.PropertyConfiguration.ResultContent, _Configuration.PropertyConfiguration.ResultContentCollection]);
|
||||
ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection = IDirectory.GetFilePathCollections(_Configuration.PropertyConfiguration, directorySearchFilter, fileSearchFilter, filesCollectionRootDirectory, useCeilingAverage: false);
|
||||
int count = filePathsCollection.Select(l => l.Count).Sum();
|
||||
bool filesCollectionCountIsOne = IsFilesCollectionCountIsOne(filePathsCollection);
|
||||
|
@ -34,12 +34,12 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.2" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
|
@ -54,7 +54,7 @@ public class Place
|
||||
results.Add(Get(place));
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ internal class F_Random
|
||||
relativePaths.Add(immichAsset.Path.Split(immichOwnerId)[1]);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static Dictionary<string, ImmichAsset> GetImmichAssets(string immichAssetsFile)
|
||||
|
@ -37,7 +37,7 @@
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -356,7 +356,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
else
|
||||
results = [];
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
public ReadOnlyDictionary<long, List<int>> GetPersonKeyToIds()
|
||||
@ -393,7 +393,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
}
|
||||
if (shouldMove.Count > 0)
|
||||
throw new Exception(string.Join(Environment.NewLine, shouldMove));
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
(bool, ReadOnlyDictionary<int, ReadOnlyCollection<PersonContainer>>?) Shared.Models.Methods.IMapLogic.GetWholePercentagesToPersonContainers(int id)
|
||||
@ -1089,7 +1089,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
results.Add(new(keyMapping, sortingContainer.Sorting, sortingContainer.Source));
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private (string, PersonBirthday?) GetPersonBirthday(string[] directoryNames)
|
||||
|
@ -87,7 +87,7 @@ internal abstract class FaceFileLogic
|
||||
Dictionary<int, ReadOnlyDictionary<int, LocationContainer>> results = [];
|
||||
foreach (KeyValuePair<int, Dictionary<int, LocationContainer>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value));
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<int, ReadOnlyDictionary<int, LocationContainer>> GetMapped(int maxDegreeOfParallelism, Property.Models.Configuration propertyConfiguration, Configuration configuration, long ticks, ReadOnlyCollection<PersonContainer> personContainers, string a2PeopleSingletonDirectory, string eDistanceContentDirectory)
|
||||
|
@ -174,7 +174,7 @@ internal abstract class MapLogic
|
||||
results.Add(face);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static string GetMappingSegmentB(long ticks, PersonBirthday personBirthday, int? approximateYears, MappingFromItem mappingFromItem)
|
||||
@ -234,11 +234,28 @@ internal abstract class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, string fullFileName)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (File.Exists(checkFile))
|
||||
File.Move(checkFile, fullFileName);
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetFacesDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string dFacesContentDirectory, FilePath filePath, MappingFromItem mappingFromItem)
|
||||
{
|
||||
string result;
|
||||
(string directoryName, _) = IPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(dFacesContentDirectory, directoryName, mappingFromItem.FilePath.NameWithoutExtension);
|
||||
CombinedEnumAndIndex cei = IPath.GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(dFacesContentDirectory, cei.Combined, mappingFromItem.FilePath.NameWithoutExtension);
|
||||
MoveIf(mappingFromItem.FilePath.NameWithoutExtension, cei, dFacesContentDirectory, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -369,7 +386,7 @@ internal abstract class MapLogic
|
||||
}
|
||||
results.Add(idTo.Key, new(keyValuePairs));
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<int, ReadOnlyDictionary<int, Mapping>> GetReadOnly(Dictionary<int, Dictionary<int, Mapping>> keyValuePairs)
|
||||
@ -377,7 +394,7 @@ internal abstract class MapLogic
|
||||
Dictionary<int, ReadOnlyDictionary<int, Mapping>> results = [];
|
||||
foreach (KeyValuePair<int, Dictionary<int, Mapping>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value));
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static List<PersonContainer> GetNonSpecificPeopleCollection(Configuration configuration, long ticks, List<long> personKeys, ReadOnlyDictionary<long, int> personKeyToCount)
|
||||
@ -793,7 +810,7 @@ internal abstract class MapLogic
|
||||
idToWholePercentagesCollection[record.MappedFaceFilePath.Id.Value].Add(wholePercentages.Value);
|
||||
results.Add(new(record.PersonKeyFormatted, record.PersonDisplayDirectoryName, record.IsDefault, record.LinksCount, record.MappedFaceFilePath, record.MappedFaceFilePath.Id.Value, wholePercentages.Value));
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static List<PersonContainer> GetNotMappedPersonContainers(Configuration configuration, long ticks, ReadOnlyCollection<PersonContainer> personContainers, ReadOnlyDictionary<long, int> personKeyToCount)
|
||||
@ -998,24 +1015,26 @@ internal abstract class MapLogic
|
||||
internal static string GetFacePartsDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string d2FacePartsContentDirectory, FilePath filePath, MappingFromItem mappingFromItem)
|
||||
{
|
||||
string result;
|
||||
(string directoryName, _) = IPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(d2FacePartsContentDirectory, directoryName, mappingFromItem.FilePath.NameWithoutExtension);
|
||||
CombinedEnumAndIndex cei = IPath.GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(d2FacePartsContentDirectory, cei.Combined, mappingFromItem.FilePath.NameWithoutExtension);
|
||||
MoveIf(mappingFromItem.FilePath.NameWithoutExtension, cei, d2FacePartsContentDirectory, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetFacePartsDirectoryX(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string d2FacePartsContentDirectory, FilePath filePath)
|
||||
{
|
||||
string result;
|
||||
(string directoryName, _) = IPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(d2FacePartsContentDirectory, directoryName, filePath.NameWithoutExtension);
|
||||
CombinedEnumAndIndex cei = IPath.GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(d2FacePartsContentDirectory, cei.Combined, filePath.NameWithoutExtension);
|
||||
MoveIf(filePath.NameWithoutExtension, cei, d2FacePartsContentDirectory, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetResizeContentDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string cContentDirectory, FilePath filePath)
|
||||
{
|
||||
string result;
|
||||
(string directoryName, _) = IPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(cContentDirectory, directoryName);
|
||||
CombinedEnumAndIndex cei = IPath.GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
result = Path.Combine(cContentDirectory, cei.Combined);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1124,7 +1143,7 @@ internal abstract class MapLogic
|
||||
collection.Add(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<int, ReadOnlyDictionary<int, Mapping>> GetIdToWholePercentagesToFace(ReadOnlyCollection<Mapping> distinctValidImageMappingCollection)
|
||||
@ -1274,7 +1293,7 @@ internal abstract class MapLogic
|
||||
foreach ((string _, int wholePercentage) in keyValuePair.Value)
|
||||
wholePercentagesCollection.Add(wholePercentage);
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<int, List<int>> ConvertSkipNotSkip(Dictionary<int, List<(string, int)>> skipNotSkipCollection)
|
||||
@ -1292,7 +1311,7 @@ internal abstract class MapLogic
|
||||
foreach ((string _, int wholePercentage) in keyValuePair.Value)
|
||||
wholePercentagesCollection.Add(wholePercentage);
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<int, List<LocationContainer>> ConvertLocationContainers(List<LocationContainer> locationContainers)
|
||||
@ -1304,7 +1323,7 @@ internal abstract class MapLogic
|
||||
results.Add(locationContainer.Id, []);
|
||||
results[locationContainer.Id].Add(locationContainer);
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static bool? CanReMap(long[] jLinkResolvedPersonKeys, ReadOnlyDictionary<int, ReadOnlyCollection<PersonContainer>>? wholePercentagesToPersonContainers, int wholePercentages)
|
||||
|
@ -82,12 +82,12 @@ internal abstract class RelationLogic
|
||||
locationContainer = collection[0];
|
||||
if (locationContainer.PersonKey is null)
|
||||
continue;
|
||||
results.Add(new(key, locationContainer.PersonKey.Value, new(collection)));
|
||||
results.Add(new(key, locationContainer.PersonKey.Value, collection.AsReadOnly()));
|
||||
collection = [];
|
||||
years.Clear();
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<string, string> MoveFiles(Configuration configuration, string key, bool isCounterPersonYear, string? displayDirectoryName, ReadOnlyCollection<RelationContainer> relationContainers, List<List<string>> linked)
|
||||
@ -202,7 +202,7 @@ internal abstract class RelationLogic
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static string? GetDisplayDirectoryName(ReadOnlyDictionary<long, List<PersonContainer>> readOnlyPersonKeyToPersonContainerCollection, ReadOnlyDictionary<string, PersonContainer> readOnlyPersonKeyFormattedToPersonContainer, long personKey, string personKeyFormatted)
|
||||
|
@ -35,10 +35,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -34,7 +34,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -17,15 +17,23 @@ public class B_Metadata : IMetadata<MetadataExtractor.Directory>
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly bool _ForceMetadataLastWriteTimeToCreationTime;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
private readonly ReadOnlyDictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultSingletonFileGroups;
|
||||
|
||||
public B_Metadata(IPropertyConfiguration propertyConfiguration)
|
||||
{
|
||||
_PropertiesChangedForMetadata = false;
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_ForceMetadataLastWriteTimeToCreationTime = false;
|
||||
_ResultSingletonFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, null, [propertyConfiguration.ResultSingleton]);
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, null, [propertyConfiguration.ResultSingleton]);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (keyValuePair.Key == _PropertyConfiguration.ResultSingleton)
|
||||
_ResultSingletonFileGroups[0] = keyValuePair.Value;
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public B_Metadata(IPropertyConfiguration propertyConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, string bResultsFullGroupDirectory)
|
||||
@ -33,8 +41,16 @@ public class B_Metadata : IMetadata<MetadataExtractor.Directory>
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
||||
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
||||
_ResultSingletonFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, bResultsFullGroupDirectory, [propertyConfiguration.ResultSingleton]);
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, bResultsFullGroupDirectory, [propertyConfiguration.ResultSingleton]);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (keyValuePair.Key == _PropertyConfiguration.ResultSingleton)
|
||||
_ResultSingletonFileGroups[0] = keyValuePair.Value;
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -43,12 +59,34 @@ public class B_Metadata : IMetadata<MetadataExtractor.Directory>
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, FileInfo fileInfo)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && System.IO.Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (File.Exists(checkFile))
|
||||
{
|
||||
File.Move(checkFile, fileInfo.FullName);
|
||||
fileInfo.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ExifDirectory GetMetadataCollection(FilePath filePath, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, string[] changesFrom, MappingFromItem mappingFromItem)
|
||||
{
|
||||
ExifDirectory? result = null;
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json"));
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
string fileName = $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json";
|
||||
string directory = _ResultSingletonFileGroups[0][cei.Enum][cei.Index];
|
||||
FileInfo fileInfo = new(Path.Combine(directory, fileName));
|
||||
MoveIf(fileName, cei, directory, fileInfo);
|
||||
if (_ForceMetadataLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
|
@ -484,7 +484,7 @@ internal abstract class Exif
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
private static Shared.Models.ExifDirectory Covert(Shared.Models.FilePath filePath, System.Drawing.Size? size, IReadOnlyList<MetadataExtractor.Directory> directories)
|
||||
private static Shared.Models.ExifDirectory Covert(Shared.Models.FilePath filePath, IReadOnlyList<MetadataExtractor.Directory> directories, System.Drawing.Size? size)
|
||||
{
|
||||
Shared.Models.ExifDirectory result;
|
||||
Shared.Models.AviDirectory[] aviDirectories = GetAviDirectories(directories);
|
||||
@ -520,13 +520,13 @@ internal abstract class Exif
|
||||
internal static Shared.Models.ExifDirectory GetExifDirectory(Shared.Models.FilePath filePath)
|
||||
{
|
||||
Shared.Models.ExifDirectory result;
|
||||
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(filePath.FullName);
|
||||
System.Drawing.Size? size;
|
||||
try
|
||||
{ size = Dimensions.GetDimensions(filePath.FullName); }
|
||||
catch (Exception)
|
||||
{ size = null; }
|
||||
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(filePath.FullName);
|
||||
result = Covert(filePath, size, directories);
|
||||
result = Covert(filePath, directories, size);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -193,6 +193,7 @@ public class MirrorLength
|
||||
{
|
||||
string message = nameof(MirrorLength);
|
||||
List<(string, string, int)> collectionForMarkDown;
|
||||
logger?.LogDebug("{method}", nameof(MirrorLengthFilesInDirectories));
|
||||
bool inPlaceSave = _PropertyConfiguration.RootDirectory.First() == _AppSettings.Destination;
|
||||
if (!inPlaceSave)
|
||||
collectionForMarkDown = [];
|
||||
|
@ -35,9 +35,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -35,10 +35,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
|
@ -37,7 +37,7 @@
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -33,14 +33,14 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -35,7 +35,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -22,19 +22,27 @@ public class A_Property
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly List<string> _AngleBracketCollection;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly ReadOnlyDictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultSingletonFileGroups;
|
||||
|
||||
public A_Property(int maxDegreeOfParallelism, Configuration propertyConfiguration, string outputExtension, bool reverse, string aResultsFullGroupDirectory)
|
||||
{
|
||||
Reverse = reverse;
|
||||
_ExceptionsDirectories = [];
|
||||
_AngleBracketCollection = [];
|
||||
_OutputExtension = outputExtension;
|
||||
_ASCIIEncoding = new ASCIIEncoding();
|
||||
_Configuration = propertyConfiguration;
|
||||
_AngleBracketCollection = [];
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, aResultsFullGroupDirectory, [propertyConfiguration.ResultSingleton]);
|
||||
_ResultSingletonFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, aResultsFullGroupDirectory, [propertyConfiguration.ResultSingleton]);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (keyValuePair.Key == _PropertyConfiguration.ResultSingleton)
|
||||
_ResultSingletonFileGroups[0] = keyValuePair.Value;
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -43,6 +51,25 @@ public class A_Property
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, FileInfo fileInfo)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (File.Exists(checkFile))
|
||||
{
|
||||
File.Move(checkFile, fileInfo.FullName);
|
||||
fileInfo.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Shared.Models.Property GetImageProperty(Shared.Models.Methods.IMetadata<MetadataExtractor.Directory> metadata, Item item, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<string> parseExceptions, bool isIgnoreExtension)
|
||||
{
|
||||
Shared.Models.Property? result;
|
||||
@ -57,8 +84,11 @@ public class A_Property
|
||||
fileInfo = new(Path.Combine(angleBracket.Replace("<>", _PropertyConfiguration.ResultSingleton), $"{item.FilePath.NameWithoutExtension}{item.FilePath.ExtensionLowered}.json"));
|
||||
else
|
||||
{
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, item.FilePath);
|
||||
fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{item.FilePath.NameWithoutExtension}{item.FilePath.ExtensionLowered}.json"));
|
||||
string fileName = $"{item.FilePath.NameWithoutExtension}{item.FilePath.ExtensionLowered}.json";
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, item.FilePath);
|
||||
string directory = _ResultSingletonFileGroups[0][cei.Enum][cei.Index];
|
||||
fileInfo = new(Path.Combine(directory, fileName));
|
||||
MoveIf(fileName, cei, directory, fileInfo);
|
||||
}
|
||||
List<DateTime> dateTimes = (from l in sourceDirectoryFileTuples where l is not null && changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
@ -168,7 +198,7 @@ public class A_Property
|
||||
{
|
||||
_AngleBracketCollection.Clear();
|
||||
if (!anyNullOrNoIsUniqueFileName)
|
||||
_AngleBracketCollection.AddRange(new[] { Path.Combine(aResultsFullGroupDirectory, "<>") });
|
||||
_AngleBracketCollection.AddRange([Path.Combine(aResultsFullGroupDirectory, "<>")]);
|
||||
else
|
||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
|
@ -40,10 +40,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -251,7 +251,7 @@ public class Rename
|
||||
catch (Exception) { continue; }
|
||||
CommandTask<CommandResult> result = Cli.Wrap("ffmpeg.exe")
|
||||
// .WithArguments(new[] { "-ss", "00:00:00", "-t", "00:00:00", "-i", files[i], "-qscale:v", "2", "-r", "0.01", $"{fileHolder.Name}-%4d.jpg" })
|
||||
.WithArguments(new[] { "-i", files[i], "-vframes", "1", $"{fileHolder.Name}-%4d.jpg" })
|
||||
.WithArguments(["-i", files[i], "-vframes", "1", $"{fileHolder.Name}-%4d.jpg"])
|
||||
.WithWorkingDirectory(fileHolder.DirectoryFullPath)
|
||||
.ExecuteAsync();
|
||||
result.Task.Wait();
|
||||
|
@ -34,11 +34,11 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CliWrap" Version="3.7.0" />
|
||||
<PackageReference Include="CliWrap" Version="3.8.1" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Metadata\Metadata.csproj" />
|
||||
|
@ -40,11 +40,10 @@ public class C_Resize
|
||||
private readonly bool _ForceResizeLastWriteTimeToCreationTime;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
private readonly Dictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<byte, ReadOnlyCollection<string>>[] _ResultSingletonFileGroups;
|
||||
|
||||
public C_Resize(IPropertyConfiguration propertyConfiguration, bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension)
|
||||
{
|
||||
_FileGroups = [];
|
||||
_Original = "Original";
|
||||
_TempResolutionWidth = 3;
|
||||
_TempResolutionHeight = 4;
|
||||
@ -61,6 +60,7 @@ public class C_Resize
|
||||
_OverrideForResizeImages = overrideForResizeImages;
|
||||
_PropertiesChangedForResize = propertiesChangedForResize;
|
||||
_ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
|
||||
_ResultSingletonFileGroups = [new(new Dictionary<byte, ReadOnlyCollection<string>>())];
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
ConstructorInfo? constructorInfo = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, [], null) ?? throw new Exception();
|
||||
_ConstructorInfo = constructorInfo;
|
||||
@ -74,10 +74,14 @@ public class C_Resize
|
||||
|
||||
public void Update(string cResultsFullGroupDirectory)
|
||||
{
|
||||
_FileGroups.Clear();
|
||||
ReadOnlyDictionary<string, ReadOnlyCollection<string>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, [_PropertyConfiguration.ResultSingleton]);
|
||||
foreach (KeyValuePair<string, ReadOnlyCollection<string>> keyValuePair in keyValuePairs)
|
||||
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, [_PropertyConfiguration.ResultSingleton]);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (keyValuePair.Key == _PropertyConfiguration.ResultSingleton)
|
||||
_ResultSingletonFileGroups[0] = keyValuePair.Value;
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAngleBracketCollection(string cResultsFullGroupDirectory, string sourceDirectory)
|
||||
@ -427,8 +431,8 @@ public class C_Resize
|
||||
result = Shared.Models.Stateless.Methods.IFileHolder.Get(Path.Combine(AngleBracketCollection[0].Replace("<>", _PropertyConfiguration.ResultContent), fileName));
|
||||
else
|
||||
{
|
||||
(string directoryName, _) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
result = Shared.Models.Stateless.Methods.IFileHolder.Get(Path.Combine(cResultsFullGroupDirectory, _PropertyConfiguration.ResultContent, directoryName, fileName));
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
result = Shared.Models.Stateless.Methods.IFileHolder.Get(Path.Combine(cResultsFullGroupDirectory, _PropertyConfiguration.ResultContent, cei.Combined, fileName));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -439,14 +443,36 @@ public class C_Resize
|
||||
public FileHolder GetResizedFileHolder(string cResultsFullGroupDirectory, Item item, bool outputResolutionHasNumber, int id) =>
|
||||
GetResizedFileHolder(cResultsFullGroupDirectory, item.FilePath, outputResolutionHasNumber, $"{id}{item.FilePath.ExtensionLowered}");
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, FileInfo fileInfo)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (File.Exists(checkFile))
|
||||
{
|
||||
File.Move(checkFile, fileInfo.FullName);
|
||||
fileInfo.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, int[]> GetResizeKeyValuePairs(Configuration configuration, string cResultsFullGroupDirectory, FilePath filePath, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Shared.Models.Property property, MappingFromItem mappingFromItem)
|
||||
{
|
||||
Dictionary<string, int[]>? results;
|
||||
string json;
|
||||
string[] changesFrom = [nameof(A_Property), nameof(B_Metadata)];
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, filePath);
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json"));
|
||||
CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath);
|
||||
string fileName = $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json";
|
||||
string directory = _ResultSingletonFileGroups[0][cei.Enum][cei.Index];
|
||||
FileInfo fileInfo = new(Path.Combine(directory, fileName));
|
||||
MoveIf(fileName, cei, directory, fileInfo);
|
||||
if (_ForceResizeLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
|
@ -35,7 +35,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -35,9 +35,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Metadata\Metadata.csproj" />
|
||||
|
@ -22,7 +22,7 @@ public class SetCreatedDate
|
||||
private readonly IsEnvironment _IsEnvironment;
|
||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||
private readonly ReadOnlyDictionary<string, ReadOnlyCollection<string>> _FileGroups;
|
||||
private readonly ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> _FileGroups;
|
||||
|
||||
public SetCreatedDate(List<string> args, ILogger<Program> logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
{
|
||||
|
23
Shared/Models/CombinedEnumAndIndex.cs
Normal file
23
Shared/Models/CombinedEnumAndIndex.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record CombinedEnumAndIndex(string Combined,
|
||||
byte Enum,
|
||||
int Index)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, CombinedEnumAndIndexSourceGenerationContext.Default.CombinedEnumAndIndex);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(CombinedEnumAndIndex))]
|
||||
internal partial class CombinedEnumAndIndexSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
@ -4,7 +4,7 @@ namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record Datum(
|
||||
[property: JsonPropertyName("accessRuleIds")] IReadOnlyList<object> AccessRuleIds,
|
||||
[property: JsonPropertyName("childAssetTypeInfo")] IReadOnlyList<object> ChildAssetTypeInfo,
|
||||
[property: JsonPropertyName("childAssetTyceinfo")] IReadOnlyList<object> ChildAssetTyceinfo,
|
||||
[property: JsonPropertyName("contentProperties")] ContentProperties ContentProperties,
|
||||
[property: JsonPropertyName("createdBy")] string CreatedBy,
|
||||
[property: JsonPropertyName("createdDate")] DateTime CreatedDate,
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
@ -83,6 +84,33 @@ public record FilePath(long CreationTicks,
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ReadOnlyDictionary<int, ReadOnlyCollection<FilePath>> GetKeyValuePairs(ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection)
|
||||
{
|
||||
Dictionary<int, ReadOnlyCollection<FilePath>> results = [];
|
||||
List<FilePath>? collection;
|
||||
Dictionary<int, List<FilePath>> keyValuePairs = [];
|
||||
foreach (ReadOnlyCollection<FilePath> filePaths in filePathsCollection)
|
||||
{
|
||||
if (filePaths.Count == 0)
|
||||
continue;
|
||||
foreach (FilePath filePath in filePaths)
|
||||
{
|
||||
if (filePath.Id is null)
|
||||
continue;
|
||||
if (!keyValuePairs.TryGetValue(filePath.Id.Value, out collection))
|
||||
{
|
||||
keyValuePairs.Add(filePath.Id.Value, []);
|
||||
if (!keyValuePairs.TryGetValue(filePath.Id.Value, out collection))
|
||||
throw new Exception();
|
||||
}
|
||||
collection.Add(filePath);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<int, List<FilePath>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value));
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
|
@ -26,7 +26,7 @@ internal abstract class Container
|
||||
continue;
|
||||
results.Add(item);
|
||||
}
|
||||
return container.Items.Count == results.Count ? container.Items : new(results);
|
||||
return container.Items.Count == results.Count ? container.Items : results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static List<Models.FilePair> GetFilePairs(Properties.IPropertyConfiguration propertyConfiguration, string directorySearchFilter, string extension, string aPropertySingletonDirectory, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection)
|
||||
@ -71,6 +71,22 @@ internal abstract class Container
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void MoveIf(string fileName, CombinedEnumAndIndex cei, string directory, string fullFileName)
|
||||
{
|
||||
string[] segments = directory.Split(cei.Combined);
|
||||
string? checkDirectory = segments.Length == 1 ?
|
||||
Path.Combine(segments[0], $"{cei.Combined[2..]}") :
|
||||
segments.Length == 2 ?
|
||||
$"{segments[0]}{cei.Combined[2..]}{segments[1]}" :
|
||||
null;
|
||||
if (checkDirectory is not null && Directory.Exists(checkDirectory))
|
||||
{
|
||||
string checkFile = Path.Combine(checkDirectory, fileName);
|
||||
if (File.Exists(checkFile))
|
||||
File.Move(checkFile, fullFileName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParallelFor(IDlibDotNet? dlibDotNet, Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string extension, int rootDirectoryLength, ReadOnlyDictionary<int, Identifier>? splatNineIdentifiers, Models.FilePair filePair, List<FilePair> results)
|
||||
{
|
||||
dlibDotNet?.Tick();
|
||||
@ -108,8 +124,12 @@ internal abstract class Container
|
||||
else
|
||||
{
|
||||
string fileName = Path.GetFileName(filePair.Path);
|
||||
(string directoryName, _) = IPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
sourceDirectoryFileHolder = IFileHolder.Get(Path.Combine(aPropertySingletonDirectory, directoryName, $"{fileName}{extension}"));
|
||||
CombinedEnumAndIndex cei = IPath.GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
string directory = Path.Combine(aPropertySingletonDirectory, cei.Combined);
|
||||
string jsonFileName = $"{fileName}{extension}";
|
||||
string fullFileName = Path.Combine(directory, jsonFileName);
|
||||
MoveIf(jsonFileName, cei, directory, fullFileName);
|
||||
sourceDirectoryFileHolder = IFileHolder.Get(fullFileName);
|
||||
}
|
||||
if (sourceDirectoryFileHolder.CreationTime is not null && sourceDirectoryFileHolder.LastWriteTime is not null && filePath.LastWriteTicks != sourceDirectoryFileHolder.CreationTime.Value.Ticks)
|
||||
{
|
||||
@ -183,7 +203,7 @@ internal abstract class Container
|
||||
Models.Container[] results;
|
||||
const string directorySearchFilter = "*";
|
||||
(_, results) = GetContainers(dlibDotNet, propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, splatNineIdentifiers, filePathsCollection, directorySearchFilter);
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, ReadOnlyDictionary<int, Identifier>? splatNineIdentifiers, string aPropertySingletonDirectory)
|
||||
@ -276,7 +296,7 @@ internal abstract class Container
|
||||
results.Add(item);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
}
|
@ -30,14 +30,14 @@ public interface IDirectory
|
||||
static void MoveFiles(List<string> files, string find, string replace) =>
|
||||
XDirectory.MoveFiles(files, find, replace);
|
||||
|
||||
(string[], List<(FilePath, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyCollection<string>> fileGroups, Action? tick) =>
|
||||
(string[], List<(FilePath, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> fileGroups, Action? tick) =>
|
||||
GetToDoCollection(propertyConfiguration, filePathsCollection, fileGroups, tick);
|
||||
static (string[], List<(FilePath, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyCollection<string>> fileGroups, Action? tick) =>
|
||||
static (string[], List<(FilePath, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> fileGroups, Action? tick) =>
|
||||
XDirectory.GetToDoCollection(propertyConfiguration, copyDuplicates: false, ifCanUseId: true, filePathsCollection, fileGroups, tick);
|
||||
|
||||
(string[], List<(FilePath, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyCollection<string>> fileGroups, Action? tick) =>
|
||||
(string[], List<(FilePath, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> fileGroups, Action? tick) =>
|
||||
GetToDoCollection(propertyConfiguration, copyDuplicates, ifCanUseId, filePathsCollection, fileGroups, tick);
|
||||
static (string[], List<(FilePath, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyCollection<string>> fileGroups, Action? tick) =>
|
||||
static (string[], List<(FilePath, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> fileGroups, Action? tick) =>
|
||||
XDirectory.GetToDoCollection(propertyConfiguration, copyDuplicates, ifCanUseId, filePathsCollection, fileGroups, tick);
|
||||
|
||||
List<string> TestStatic_CopyOrMove(List<(FilePath, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
||||
|
@ -62,14 +62,14 @@ public interface IPath
|
||||
static string GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
||||
XPath.GetDirectory(sourceDirectory, level, directoryName);
|
||||
|
||||
(string, int) TestStatic_GetDirectoryNameAndIndex(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
static (string, int) GetDirectoryNameAndIndex(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
XPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
CombinedEnumAndIndex TestStatic_GetCombinedEnumAndIndex(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
static CombinedEnumAndIndex GetCombinedEnumAndIndex(IPropertyConfiguration propertyConfiguration, FilePath filePath) =>
|
||||
XPath.GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
|
||||
ReadOnlyDictionary<string, ReadOnlyCollection<string>> TestStatic_GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? jsonGroups) =>
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> TestStatic_GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? jsonGroups) =>
|
||||
GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, jsonGroups);
|
||||
static ReadOnlyDictionary<string, ReadOnlyCollection<string>> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? jsonGroups) =>
|
||||
static ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? jsonGroups) =>
|
||||
XPath.GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, jsonGroups);
|
||||
|
||||
}
|
@ -3,7 +3,7 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
internal abstract class MetadataFileCollection
|
||||
{
|
||||
|
||||
internal static Dictionary<string, List<KeyValuePair<string, string>>> GetDefaultValue() => new(); // {{1}}SingletonValue
|
||||
internal static Dictionary<string, List<KeyValuePair<string, string>>> GetDefaultValue() => []; // {{1}}SingletonValue
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -75,13 +75,15 @@ internal abstract class Property
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
check = Path.GetDirectoryName(check);
|
||||
if (string.IsNullOrEmpty(check) || check == pathRoot)
|
||||
if (string.IsNullOrEmpty(check))
|
||||
break;
|
||||
directoryName = Path.GetFileName(check);
|
||||
directorySegments = directoryName.Split(' ');
|
||||
(result, results) = IsWrongYear(directorySegments, year);
|
||||
if (result is not null)
|
||||
break;
|
||||
if (check == pathRoot)
|
||||
break;
|
||||
}
|
||||
if (result is not null && !result.Value)
|
||||
break;
|
||||
|
@ -51,7 +51,7 @@ internal abstract partial class XDirectory
|
||||
int ceilingAverage = directory[^1] == '_' || results.Count == 0 ? 0 : GetCeilingAverage(results);
|
||||
if (useCeilingAverage)
|
||||
results = GetFilesCollection(results, ceilingAverage);
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static ReadOnlyCollection<ReadOnlyCollection<FilePath>> GetFilePathCollections(Properties.IPropertyConfiguration propertyConfiguration, string directorySearchFilter, string fileSearchFilter, string directory, bool useCeilingAverage)
|
||||
@ -326,10 +326,10 @@ internal abstract partial class XDirectory
|
||||
}
|
||||
results.Add(new(filePaths));
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static (string[], List<(FilePath, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyCollection<string>> fileGroups, Action? tick)
|
||||
internal static (string[], List<(FilePath, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, ReadOnlyCollection<ReadOnlyCollection<FilePath>> filePathsCollection, IReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> fileGroups, Action? tick)
|
||||
{
|
||||
List<(FilePath, string)> results = [];
|
||||
string key;
|
||||
@ -338,18 +338,18 @@ internal abstract partial class XDirectory
|
||||
string directory;
|
||||
FileInfo fileInfo;
|
||||
FilePath filePath;
|
||||
int directoryIndex;
|
||||
string paddedIdFile;
|
||||
bool wrapped = false;
|
||||
string intelligentId;
|
||||
CombinedEnumAndIndex cei;
|
||||
bool paddedCheck = false;
|
||||
string fileDirectoryName;
|
||||
List<int> distinctIds = [];
|
||||
List<string> distinct = [];
|
||||
Models.FileHolder fileHolder;
|
||||
List<string> distinctDirectories = [];
|
||||
ReadOnlyCollection<string>? directories;
|
||||
FilePath[] sortedRecords = GetSortedRecords(filePathsCollection);
|
||||
ReadOnlyDictionary<byte, ReadOnlyCollection<string>>? keyValuePairs;
|
||||
bool isOffsetDeterministicHashCode = IId.IsOffsetDeterministicHashCode(propertyConfiguration);
|
||||
for (int i = 0; i < sortedRecords.Length; i++)
|
||||
{
|
||||
@ -358,21 +358,21 @@ internal abstract partial class XDirectory
|
||||
if (filePath.Name.EndsWith("len") || filePath.ExtensionLowered == ".id" || filePath.ExtensionLowered == ".lsv" || filePath.DirectoryFullPath is null)
|
||||
continue;
|
||||
key = propertyConfiguration.ValidVideoFormatExtensions.Contains(filePath.ExtensionLowered) ? propertyConfiguration.ResultContentCollection : propertyConfiguration.ResultContent;
|
||||
if (!fileGroups.TryGetValue(key, out directories))
|
||||
if (!fileGroups.TryGetValue(key, out keyValuePairs))
|
||||
continue;
|
||||
(_, directoryIndex) = IPath.GetDirectoryNameAndIndex(propertyConfiguration, filePath);
|
||||
cei = IPath.GetCombinedEnumAndIndex(propertyConfiguration, filePath);
|
||||
fileDirectoryName = Path.GetFileName(filePath.DirectoryFullPath);
|
||||
if (fileDirectoryName.Length < propertyConfiguration.ResultAllInOneSubdirectoryLength + 3 || !filePath.Name.StartsWith(fileDirectoryName))
|
||||
{
|
||||
if (wrapped)
|
||||
continue;
|
||||
directory = directories[directoryIndex];
|
||||
directory = keyValuePairs[cei.Enum][cei.Index];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!wrapped)
|
||||
wrapped = true;
|
||||
directory = Path.Combine(directories[directoryIndex], fileDirectoryName);
|
||||
directory = Path.Combine(keyValuePairs[cei.Enum][cei.Index], fileDirectoryName);
|
||||
}
|
||||
if (ifCanUseId && filePath.IsIntelligentIdFormat && filePath.Id is not null && filePath.DirectoryFullPath is not null)
|
||||
{
|
||||
|
@ -266,78 +266,155 @@ internal abstract class XPath
|
||||
}
|
||||
}
|
||||
|
||||
internal static (string, int) GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName)
|
||||
private static byte GetEnum(bool? ik, bool? dto)
|
||||
{
|
||||
byte result;
|
||||
if (ik is not null && ik.Value && dto is not null && dto.Value)
|
||||
result = 11;
|
||||
else if (ik is not null && ik.Value && dto is not null && !dto.Value)
|
||||
result = 15;
|
||||
else if (ik is not null && ik.Value && dto is null)
|
||||
result = 19;
|
||||
else if (ik is not null && !ik.Value && dto is not null && dto.Value)
|
||||
result = 51;
|
||||
else if (ik is not null && !ik.Value && dto is not null && !dto.Value)
|
||||
result = 55;
|
||||
else if (ik is not null && !ik.Value && dto is null)
|
||||
result = 59;
|
||||
else if (ik is null && dto is not null && dto.Value)
|
||||
result = 91;
|
||||
else if (ik is null && dto is not null && !dto.Value)
|
||||
result = 95;
|
||||
else if (ik is null && dto is null)
|
||||
result = 99;
|
||||
else
|
||||
throw new Exception();
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static CombinedEnumAndIndex GetCombinedEnumAndIndex(int resultAllInOneSubdirectoryLength, FilePath filePath, string fileName)
|
||||
{
|
||||
CombinedEnumAndIndex result;
|
||||
int converted;
|
||||
string result;
|
||||
string check = fileName.Length < resultAllInOneSubdirectoryLength ? new('-', resultAllInOneSubdirectoryLength) : fileName.Split('.')[0][^resultAllInOneSubdirectoryLength..];
|
||||
string combined;
|
||||
byte @enum = GetEnum(filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal);
|
||||
string check = fileName.Length < resultAllInOneSubdirectoryLength ?
|
||||
new('-', resultAllInOneSubdirectoryLength) :
|
||||
fileName.Split('.')[0][^resultAllInOneSubdirectoryLength..];
|
||||
if (check.Any(l => !char.IsNumber(l)))
|
||||
{
|
||||
result = new('-', resultAllInOneSubdirectoryLength);
|
||||
combined = $"{@enum}{new('-', resultAllInOneSubdirectoryLength)}";
|
||||
converted = int.Parse($"1{new string('0', resultAllInOneSubdirectoryLength)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = check;
|
||||
combined = $"{@enum}{check}";
|
||||
converted = int.Parse(check);
|
||||
}
|
||||
return (result, converted);
|
||||
result = new(combined, @enum, converted);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static (string, int) GetDirectoryNameAndIndex(IPropertyConfiguration propertyConfiguration, FilePath filePath)
|
||||
internal static CombinedEnumAndIndex GetCombinedEnumAndIndex(IPropertyConfiguration propertyConfiguration, FilePath filePath)
|
||||
{
|
||||
int converted;
|
||||
string result;
|
||||
CombinedEnumAndIndex result;
|
||||
if (filePath.Id is not null)
|
||||
(result, converted) = GetDirectoryNameAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, filePath.Id.Value.ToString());
|
||||
result = GetCombinedEnumAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, filePath, filePath.Id.Value.ToString());
|
||||
else
|
||||
(result, converted) = GetDirectoryNameAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, filePath.FileNameFirstSegment);
|
||||
return (result, converted);
|
||||
result = GetCombinedEnumAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, filePath, filePath.FileNameFirstSegment);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<string, ReadOnlyCollection<string>> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? jsonGroups)
|
||||
private static byte[] GetBytes() =>
|
||||
[
|
||||
11,
|
||||
15,
|
||||
19,
|
||||
51,
|
||||
55,
|
||||
59,
|
||||
91,
|
||||
95,
|
||||
99
|
||||
];
|
||||
|
||||
private static ReadOnlyDictionary<byte, ReadOnlyCollection<string>> Convert(Dictionary<byte, List<string>> keyValuePairs)
|
||||
{
|
||||
Dictionary<string, ReadOnlyCollection<string>> results = [];
|
||||
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||
Dictionary<byte, ReadOnlyCollection<string>> results = [];
|
||||
foreach (KeyValuePair<byte, List<string>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value));
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<byte, ReadOnlyCollection<string>> Convert(List<CombinedEnumAndIndex> collection)
|
||||
{
|
||||
Dictionary<byte, List<string>> results = [];
|
||||
List<string>? c;
|
||||
foreach (CombinedEnumAndIndex cei in collection)
|
||||
{
|
||||
if (!results.TryGetValue(cei.Enum, out c))
|
||||
{
|
||||
results.Add(cei.Enum, []);
|
||||
if (!results.TryGetValue(cei.Enum, out c))
|
||||
throw new Exception();
|
||||
}
|
||||
c.Add(cei.Combined);
|
||||
}
|
||||
return Convert(results);
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? jsonGroups)
|
||||
{
|
||||
Dictionary<string, ReadOnlyDictionary<byte, ReadOnlyCollection<string>>> results = [];
|
||||
int plusOne;
|
||||
string directory;
|
||||
string checkDirectory;
|
||||
List<string> collection;
|
||||
int plusOne = converted + 1;
|
||||
CombinedEnumAndIndex cei;
|
||||
byte[] bytes = GetBytes();
|
||||
List<CombinedEnumAndIndex> collection;
|
||||
ReadOnlyDictionary<byte, ReadOnlyCollection<string>> keyValuePairs;
|
||||
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||
if (jsonGroups is not null)
|
||||
{
|
||||
plusOne = converted + 1;
|
||||
foreach (string jsonGroup in jsonGroups)
|
||||
{
|
||||
collection = [];
|
||||
if (resultsFullGroupDirectory is null)
|
||||
continue;
|
||||
collection = [];
|
||||
for (int i = 0; i < plusOne; i++)
|
||||
foreach (byte @enum in bytes)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonGroup))
|
||||
for (int i = 0; i < plusOne; i++)
|
||||
{
|
||||
if (i == converted)
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||
if (string.IsNullOrEmpty(jsonGroup))
|
||||
{
|
||||
if (i == converted)
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, $"{@enum}{new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)}"));
|
||||
else
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, $"{@enum}{i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')}"));
|
||||
}
|
||||
else
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||
{
|
||||
directory = Path.Combine(resultsFullGroupDirectory, jsonGroup);
|
||||
if (i == converted)
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(directory, $"{@enum}{new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)}"));
|
||||
else
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(directory, $"{@enum}{i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')}"));
|
||||
}
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
cei = new(Combined: checkDirectory, Enum: @enum, Index: -1);
|
||||
collection.Add(cei);
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = Path.Combine(resultsFullGroupDirectory, jsonGroup);
|
||||
if (i == converted)
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(directory, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||
else
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(directory, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||
}
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
collection.Add(checkDirectory);
|
||||
}
|
||||
keyValuePairs = Convert(collection);
|
||||
if (!string.IsNullOrEmpty(jsonGroup))
|
||||
results.Add(jsonGroup, new(collection));
|
||||
results.Add(jsonGroup, keyValuePairs);
|
||||
else
|
||||
results.Add(propertyConfiguration.ResultAllInOne, new(collection));
|
||||
results.Add(propertyConfiguration.ResultAllInOne, keyValuePairs);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
}
|
@ -33,6 +33,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -27,14 +27,14 @@
|
||||
<DefineConstants>Linux</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.7.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.7.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.8.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.8.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlurHash\BlurHash.csproj" />
|
||||
|
@ -45,7 +45,7 @@ public partial class UnitTestHardCoded
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
_Git = "d8013da9";
|
||||
_Git = "0b793904";
|
||||
_AppSettings = appSettings;
|
||||
_Configuration = configuration;
|
||||
_IsEnvironment = isEnvironment;
|
||||
|
@ -27,13 +27,13 @@
|
||||
<DefineConstants>Linux</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.7.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.7.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.8.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.8.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlurHash\BlurHash.csproj" />
|
||||
|
@ -35,7 +35,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SkiaSharp" Version="3.116.1" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
6
global.json
Normal file
6
global.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"rollForward": "latestMinor",
|
||||
"version": "9.0.103"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user