ResultAllInOneSubdirectoryLength
This commit is contained in:
parent
8dfcc33e74
commit
3092cd5b9e
@ -10,23 +10,27 @@ completedColumns:
|
||||
## Backlog
|
||||
|
||||
- [asdf](tasks/asdf.md)
|
||||
- [merge-scan-photos](tasks/merge-scan-photos.md)
|
||||
|
||||
## Todo
|
||||
|
||||
- [nef-support](tasks/nef-support.md)
|
||||
- [determine-if-location-container-collection-is-needed-in-get-faces](tasks/determine-if-location-container-collection-is-needed-in-get-faces.md)
|
||||
- [use-photo-prism-to-map](tasks/use-photo-prism-to-map.md)
|
||||
- [import-face-region-metadata](tasks/import-face-region-metadata.md)
|
||||
- [use-photo-prism-to-map](tasks/use-photo-prism-to-map.md)
|
||||
- [determine-if-location-container-collection-is-needed-in-get-faces](tasks/determine-if-location-container-collection-is-needed-in-get-faces.md)
|
||||
- [google-timeline-for-geo](tasks/google-timeline-for-geo.md)
|
||||
- [merge-kristy-files](tasks/merge-kristy-files.md)
|
||||
- [setup-syncthing-server](tasks/setup-syncthing-server.md)
|
||||
|
||||
## In Progress
|
||||
|
||||
- [import-know-faces-into-db](tasks/import-know-faces-into-db.md)
|
||||
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
||||
- [run-scan-originals](tasks/run-scan-originals.md)
|
||||
- [find-incorrectly-mapped-faces](tasks/find-incorrectly-mapped-faces.md)
|
||||
- [shrink-percent](tasks/shrink-percent.md)
|
||||
- [nef-support](tasks/nef-support.md)
|
||||
- [use-eyes-to-find-orientation](tasks/use-eyes-to-find-orientation.md)
|
||||
- [import-know-faces-into-db](tasks/import-know-faces-into-db.md)
|
||||
|
||||
## Done
|
||||
|
||||
- [eof-error](tasks/eof-error.md)
|
||||
- [eof-error](tasks/eof-error.md)
|
||||
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
||||
- [run-scan-originals](tasks/run-scan-originals.md)
|
||||
- [shrink-percent](tasks/shrink-percent.md)
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-12T21:54:44.803Z
|
||||
updated: 2023-06-12T21:54:44.803Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "1-Backlog"
|
||||
---
|
||||
|
||||
# asdf
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-24T02:12:00.629Z
|
||||
updated: 2023-06-24T02:12:47.758Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "2-Todo"
|
||||
---
|
||||
|
||||
# determine-if-location-container-collection-is-needed-in-get-faces
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-12T21:55:20.591Z
|
||||
updated: 2023-06-18T15:18:01.941Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "4-Done"
|
||||
---
|
||||
|
||||
# eof-error
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-18T20:29:10.288Z
|
||||
updated: 2023-06-19T01:50:22.660Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "3-In Progress"
|
||||
---
|
||||
|
||||
# find-incorrectly-mapped-faces
|
||||
|
15
.kanbn/tasks/google-timeline-for-geo.md
Normal file
15
.kanbn/tasks/google-timeline-for-geo.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
created: 2023-06-25T15:26:35.170Z
|
||||
updated: 2023-06-25T15:29:50.594Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "2-Todo"
|
||||
---
|
||||
|
||||
# google-timeline-for-geo
|
||||
|
||||
## Sub-tasks
|
||||
|
||||
- [ ] Download google-timeline then update images within time frame
|
||||
- [ ] Determine if NIKON CORPORATION NIKON D3400 changes timezones
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-19T21:38:12.818Z
|
||||
updated: 2023-06-19T21:38:12.818Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "2-Todo"
|
||||
---
|
||||
|
||||
# import-face-region-metadata
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-12T21:54:44.803Z
|
||||
updated: 2023-06-25T01:24:50.138Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "3-In Progress"
|
||||
---
|
||||
|
||||
# import-know-faces-into-db
|
||||
|
14
.kanbn/tasks/merge-kristy-files.md
Normal file
14
.kanbn/tasks/merge-kristy-files.md
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
created: 2023-06-25T16:35:28.627Z
|
||||
updated: 2023-06-25T16:35:35.404Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "2-Todo"
|
||||
---
|
||||
|
||||
# merge-kristy-files
|
||||
|
||||
## Sub-tasks
|
||||
|
||||
- [ ] asdf
|
20
.kanbn/tasks/merge-scan-photos.md
Normal file
20
.kanbn/tasks/merge-scan-photos.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
created: 2023-06-12T21:54:44.803Z
|
||||
updated: 2023-06-12T21:54:44.803Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "1-Backlog"
|
||||
---
|
||||
|
||||
# merge-scan-photos
|
||||
|
||||
- Inform about the few file name duplicates
|
||||
|
||||
```bash
|
||||
cd "D:/7) Question/- Scans 12.22 (2043)"
|
||||
```
|
||||
|
||||
## Sub-tasks
|
||||
|
||||
- [ ] asdf
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-24T02:13:16.426Z
|
||||
updated: 2023-06-24T02:13:20.545Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "3-In Progress"
|
||||
---
|
||||
|
||||
# nef-support
|
||||
|
@ -1,13 +1,14 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-12T21:54:44.810Z
|
||||
updated: 2023-06-25T16:30:22.805Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "4-Done"
|
||||
---
|
||||
|
||||
# run-scan-originals
|
||||
|
||||
## Sub-tasks
|
||||
|
||||
- [ ] run-scan-originals
|
||||
- [x] run-scan-originals
|
||||
|
@ -1,14 +1,15 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-12T17:28:20.080Z
|
||||
updated: 2023-06-25T16:29:52.487Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "4-Done"
|
||||
---
|
||||
|
||||
# Setup PhotoPrism again in WSL / Docker
|
||||
|
||||
## Sub-tasks
|
||||
|
||||
- [ ] Install Docker
|
||||
- [ ] Install WSL
|
||||
- [x] Install Docker
|
||||
- [x] Install WSL
|
||||
|
19
.kanbn/tasks/setup-syncthing-server.md
Normal file
19
.kanbn/tasks/setup-syncthing-server.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
created: 2023-06-12T21:54:44.803Z
|
||||
updated: 2023-06-12T21:54:44.803Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "1-Backlog"
|
||||
---
|
||||
|
||||
# setup-syncthing-server
|
||||
|
||||
- Share one folder at a time
|
||||
- Use push only feature
|
||||
|
||||
## Sub-tasks
|
||||
|
||||
- [ ] Use Windows box to create Syncthing server
|
||||
- [ ] Find 256 GB SSD to put pictures on
|
||||
- [ ] asdf
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-19T21:39:09.103Z
|
||||
updated: 2023-06-25T16:24:52.333Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "4-Done"
|
||||
---
|
||||
|
||||
# shrink-percent
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-23T13:56:11.956Z
|
||||
updated: 2023-06-24T15:11:14.038Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "3-In Progress"
|
||||
---
|
||||
|
||||
# use-eyes-to-find-orientation
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
created: 2023-06-12T15:44:11.932Z
|
||||
updated: 2023-06-12T15:45:59.891Z
|
||||
created: 2023-06-19T21:38:12.818Z
|
||||
updated: 2023-06-19T21:38:12.818Z
|
||||
assigned: ""
|
||||
progress: 0
|
||||
tags: []
|
||||
status: "2-Todo"
|
||||
---
|
||||
|
||||
# use-photo-prism-to-map
|
||||
@ -11,4 +12,4 @@ tags: []
|
||||
## Sub-tasks
|
||||
|
||||
- [ ] Do I need to join makers with subjects
|
||||
- [ ] Build logic to use photo prism to suggest missing mapping
|
||||
- [ ] Build logic to use photo prism to suggest missing mapping
|
||||
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -34,6 +34,7 @@
|
||||
"Serilog",
|
||||
"Subfile",
|
||||
"Subfiles",
|
||||
"Syncthing",
|
||||
"Unmanaged",
|
||||
"Upsample",
|
||||
"Vericruz"
|
||||
|
@ -2,16 +2,21 @@ using System.Drawing;
|
||||
using System.Text;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
namespace View_by_Distance.BlurHash.Models;
|
||||
|
||||
public class C2_BlurHasher : IBlurHasher
|
||||
{
|
||||
|
||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||
|
||||
public C2_BlurHasher(string resultAllInOne, string? resultsFullGroupDirectory) =>
|
||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, new string[] { "{}", "()" }, maxValue: 102);
|
||||
public C2_BlurHasher(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory)
|
||||
{
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, new string[] { propertyConfiguration.ResultContent, propertyConfiguration.ResultSingleton });
|
||||
}
|
||||
|
||||
string IBlurHasher.Encode(FileHolder fileHolder)
|
||||
{
|
||||
@ -26,24 +31,21 @@ public class C2_BlurHasher : IBlurHasher
|
||||
return result;
|
||||
}
|
||||
|
||||
string? IBlurHasher.GetFile(FileHolder fileHolder)
|
||||
string IBlurHasher.GetFile(FileHolder fileHolder)
|
||||
{
|
||||
string? result;
|
||||
string directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.Name, length: 2);
|
||||
result = !int.TryParse(directory, out int directoryIndex) ? null : Path.Combine(_JsonGroups["{}"][directoryIndex], $"{fileHolder.Name}.csv");
|
||||
string result;
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, fileHolder.Name);
|
||||
result = Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{fileHolder.Name}.csv");
|
||||
return result;
|
||||
}
|
||||
|
||||
string IBlurHasher.EncodeAndSave(FileHolder fileHolder)
|
||||
{
|
||||
string? file;
|
||||
string result;
|
||||
int actualByte;
|
||||
string extension = ".png";
|
||||
IBlurHasher blurHasher = this;
|
||||
file = blurHasher.GetFile(fileHolder);
|
||||
if (file is null)
|
||||
throw new NullReferenceException(nameof(file));
|
||||
string file = blurHasher.GetFile(fileHolder);
|
||||
#pragma warning disable CA1416
|
||||
Image image = Image.FromFile(fileHolder.FullName);
|
||||
int outputWidth = (int)(image.Width * .25);
|
||||
@ -57,23 +59,20 @@ public class C2_BlurHasher : IBlurHasher
|
||||
string fileNameWithoutExtension = $"{componentsX}x{componentsY}-{outputWidth}x{outputHeight}-{joined}";
|
||||
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);
|
||||
string directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(joined, length: 2);
|
||||
if (int.TryParse(directory, out int directoryIndex))
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, joined);
|
||||
file = Path.Combine(_FileGroups[_PropertyConfiguration.ResultContent][directoryIndex], $"{fileNameWithoutExtension}{extension}");
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
file = Path.Combine(_JsonGroups["()"][directoryIndex], $"{fileNameWithoutExtension}{extension}");
|
||||
if (!File.Exists(file))
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
using FileStream fileStream = new(file, FileMode.CreateNew);
|
||||
actualImage.Save(fileStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
_ = fileStream.Seek(0, SeekOrigin.Begin);
|
||||
using FileStream fileStream = new(file, FileMode.CreateNew);
|
||||
actualImage.Save(fileStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
_ = fileStream.Seek(0, SeekOrigin.Begin);
|
||||
actualByte = fileStream.ReadByte();
|
||||
while (actualByte > -1)
|
||||
actualByte = fileStream.ReadByte();
|
||||
while (actualByte > -1)
|
||||
actualByte = fileStream.ReadByte();
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
image.Dispose();
|
||||
#pragma warning restore CA1416
|
||||
|
@ -16,7 +16,7 @@ public class CopyDistinct
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly IsEnvironment _IsEnvironment;
|
||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||
|
||||
public CopyDistinct(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
@ -29,10 +29,10 @@ public class CopyDistinct
|
||||
_IsEnvironment = isEnvironment;
|
||||
_WorkingDirectory = workingDirectory;
|
||||
_ConfigurationRoot = configurationRoot;
|
||||
string[] directories = new string[] { "()" };
|
||||
ILogger? log = Log.ForContext<CopyDistinct>();
|
||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration.ResultAllInOne, appSettings.CopyTo, directories, appSettings.MaxValue);
|
||||
string[] directories = new string[] { propertyConfiguration.ResultContent };
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, appSettings.CopyTo, directories);
|
||||
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_Configuration = configuration;
|
||||
@ -41,7 +41,7 @@ public class CopyDistinct
|
||||
Verify();
|
||||
List<string> lines = CopyDistinctFilesInDirectories(log);
|
||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||
if (lines.Any())
|
||||
if (!lines.Any())
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
|
||||
}
|
||||
|
||||
@ -83,13 +83,10 @@ public class CopyDistinct
|
||||
private List<(FileHolder, string)> GetToDoCollection(ProgressBar progressBar, List<string> files)
|
||||
{
|
||||
List<(FileHolder, string)> results = new();
|
||||
string directory;
|
||||
string checkFile;
|
||||
int directoryIndex;
|
||||
FileHolder fileHolder;
|
||||
bool isIgnoreExtension;
|
||||
List<string> distinct = new();
|
||||
bool isValidImageFormatExtension;
|
||||
bool nameWithoutExtensionIsIdFormat;
|
||||
foreach (string file in files)
|
||||
{
|
||||
@ -99,17 +96,15 @@ public class CopyDistinct
|
||||
continue;
|
||||
if (files.Contains($"{fileHolder.FullName}.id"))
|
||||
continue;
|
||||
isValidImageFormatExtension = _PropertyConfiguration.ValidImageFormatExtensions.Contains(fileHolder.ExtensionLowered);
|
||||
isIgnoreExtension = isValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(fileHolder.ExtensionLowered);
|
||||
if (isIgnoreExtension || !isValidImageFormatExtension)
|
||||
continue;
|
||||
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
|
||||
if (!nameWithoutExtensionIsIdFormat)
|
||||
continue;
|
||||
directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.NameWithoutExtension, 2);
|
||||
if (!int.TryParse(directory, out directoryIndex))
|
||||
continue;
|
||||
checkFile = Path.Combine(_JsonGroups["()"][directoryIndex], fileHolder.Name);
|
||||
{
|
||||
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(_PropertyConfiguration.ValidImageFormatExtensions, fileHolder);
|
||||
if (!nameWithoutExtensionIsIdFormat)
|
||||
continue;
|
||||
}
|
||||
(_, directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, fileHolder.NameWithoutExtension);
|
||||
checkFile = Path.Combine(_FileGroups[_PropertyConfiguration.ResultContent][directoryIndex], fileHolder.Name);
|
||||
if (distinct.Contains(checkFile))
|
||||
continue;
|
||||
distinct.Add(checkFile);
|
||||
@ -160,8 +155,8 @@ public class CopyDistinct
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
ProgressBar progressBar = new(allFiles.Count, message, options);
|
||||
List<(FileHolder, string)> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
||||
results.AddRange(Copy(log, toDoCollection));
|
||||
progressBar.Dispose();
|
||||
results.AddRange(Copy(log, toDoCollection));
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -9,20 +9,17 @@ public class AppSettings
|
||||
public string Company { init; get; }
|
||||
public string CopyTo { init; get; }
|
||||
public int MaxDegreeOfParallelism { init; get; }
|
||||
public int MaxValue { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company,
|
||||
string copyTo,
|
||||
int maxDegreeOfParallelism,
|
||||
int maxValue,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
Company = company;
|
||||
CopyTo = copyTo;
|
||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
MaxValue = maxValue;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ public class AppSettings
|
||||
|
||||
public string Company { get; set; }
|
||||
public int? MaxDegreeOfParallelism { get; set; }
|
||||
public int? MaxValue { get; set; }
|
||||
public string CopyTo { get; set; }
|
||||
public string WorkingDirectoryName { get; set; }
|
||||
|
||||
@ -27,13 +26,10 @@ public class AppSettings
|
||||
Models.AppSettings result;
|
||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||
if (appSettings?.MaxValue is null)
|
||||
throw new NullReferenceException(nameof(appSettings.MaxValue));
|
||||
result = new(
|
||||
appSettings.Company,
|
||||
appSettings.CopyTo,
|
||||
appSettings.MaxDegreeOfParallelism.Value,
|
||||
appSettings.MaxValue.Value,
|
||||
appSettings.WorkingDirectoryName
|
||||
);
|
||||
return result;
|
||||
|
@ -12,7 +12,6 @@
|
||||
}
|
||||
},
|
||||
"MaxDegreeOfParallelism": 6,
|
||||
"MaxValue": 12,
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
@ -64,6 +63,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -64,6 +64,7 @@
|
||||
"PopulatePropertyId": false,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -66,6 +66,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -61,6 +61,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -63,6 +63,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -11,6 +11,7 @@ using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Property.Models.Stateless;
|
||||
using View_by_Distance.Resize.Models;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Face.Models;
|
||||
@ -33,7 +34,6 @@ public class D_Face
|
||||
private readonly string _ArgZero;
|
||||
private readonly Serilog.ILogger? _Log;
|
||||
private readonly bool _OverrideForFaceImages;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly bool _LoadPhotoPrismLocations;
|
||||
private readonly ImageCodecInfo _ImageCodecInfo;
|
||||
private readonly ModelParameter _ModelParameter;
|
||||
@ -45,14 +45,16 @@ public class D_Face
|
||||
private readonly int _FaceDistanceHiddenImageFactor;
|
||||
private readonly EncoderParameters _EncoderParameters;
|
||||
private readonly ImageCodecInfo _HiddenImageCodecInfo;
|
||||
private readonly Dictionary<string, string[]> _FileGroups;
|
||||
private readonly bool _ForceFaceLastWriteTimeToCreationTime;
|
||||
private readonly EncoderParameters _HiddenEncoderParameters;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly JsonSerializerOptions _WriteIndentedAndWhenWritingNull;
|
||||
|
||||
public D_Face(
|
||||
string argZero,
|
||||
IPropertyConfiguration propertyConfiguration,
|
||||
bool checkDFaceAndUpWriteDates,
|
||||
Configuration configuration,
|
||||
EncoderParameters encoderParameters,
|
||||
int faceDistanceHiddenImageFactor,
|
||||
string filenameExtension,
|
||||
@ -70,7 +72,7 @@ public class D_Face
|
||||
float[] rectangleIntersectMinimums)
|
||||
{
|
||||
_ArgZero = argZero;
|
||||
_Configuration = configuration;
|
||||
_FileGroups = new();
|
||||
_ImageCodecInfo = imageCodecInfo;
|
||||
_EncoderParameters = encoderParameters;
|
||||
_FileNameExtension = filenameExtension;
|
||||
@ -78,6 +80,7 @@ public class D_Face
|
||||
AngleBracketCollection = new List<string>();
|
||||
_HiddenImageCodecInfo = hiddenImageCodecInfo;
|
||||
_OverrideForFaceImages = overrideForFaceImages;
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_HiddenEncoderParameters = hiddenEncoderParameters;
|
||||
_HiddenFileNameExtension = hiddenFileNameExtension;
|
||||
_LoadPhotoPrismLocations = loadPhotoPrismLocations;
|
||||
@ -101,6 +104,14 @@ public class D_Face
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Update(string dResultsFullGroupDirectory)
|
||||
{
|
||||
_FileGroups.Clear();
|
||||
Dictionary<string, string[]> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, dResultsFullGroupDirectory, new string[] { _PropertyConfiguration.ResultCollection });
|
||||
foreach (KeyValuePair<string, string[]> keyValuePair in keyValuePairs)
|
||||
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
}
|
||||
|
||||
private static (Model model, PredictorModel predictorModel, ModelParameter modelParameter) GetModel(string modelDirectory, string modelName, string predictorModelName)
|
||||
{
|
||||
(Model, PredictorModel, ModelParameter) result;
|
||||
@ -179,7 +190,7 @@ public class D_Face
|
||||
continue;
|
||||
if (face.FaceEncoding is null || face?.Location is null || face?.OutputResolution is null)
|
||||
continue;
|
||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, ILocation.Digits, ILocation.Factor, source.Height, source.Width, collection.Count);
|
||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, source.Height, source.Width, collection.Count);
|
||||
if (location is null)
|
||||
continue;
|
||||
width = location.Right - location.Left;
|
||||
@ -202,7 +213,7 @@ public class D_Face
|
||||
}
|
||||
if (File.Exists(fileName))
|
||||
File.Delete(fileName);
|
||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(_FaceDistanceHiddenImageFactor, face.Location, ILocation.Digits, ILocation.Factor, source.Height, source.Width, collection.Count);
|
||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(_FaceDistanceHiddenImageFactor, face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, source.Height, source.Width, collection.Count);
|
||||
if (location is null)
|
||||
continue;
|
||||
width = location.Right - location.Left;
|
||||
@ -222,10 +233,10 @@ public class D_Face
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
if (_Configuration.NumberOfJitters is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.NumberOfJitters));
|
||||
if (_Configuration.NumberOfTimesToUpsample is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.NumberOfTimesToUpsample));
|
||||
if (_PropertyConfiguration.NumberOfJitters is null)
|
||||
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfJitters));
|
||||
if (_PropertyConfiguration.NumberOfTimesToUpsample is null)
|
||||
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfTimesToUpsample));
|
||||
List<Shared.Models.Face> results = new();
|
||||
FaceRecognitionDotNet.Image? unknownImage;
|
||||
try
|
||||
@ -239,7 +250,7 @@ public class D_Face
|
||||
{
|
||||
(int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation) = Resize.Models.Stateless.Methods.IResize.Get(outputResolution, outputResolutionToResize);
|
||||
List<(Location Location, FaceRecognitionDotNet.FaceEncoding? FaceEncoding, Dictionary<FacePart, FacePoint[]>? FaceParts)> collection;
|
||||
FaceRecognition faceRecognition = new(_Configuration.NumberOfJitters.Value, _Configuration.NumberOfTimesToUpsample.Value, _Model, _ModelParameter, _PredictorModel);
|
||||
FaceRecognition faceRecognition = new(_PropertyConfiguration.NumberOfJitters.Value, _PropertyConfiguration.NumberOfTimesToUpsample.Value, _Model, _ModelParameter, _PredictorModel);
|
||||
collection = faceRecognition.GetCollection(unknownImage, locations, includeFaceEncoding: true, includeFaceParts: true);
|
||||
if (!collection.Any())
|
||||
results.Add(new(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, location: null));
|
||||
@ -271,7 +282,7 @@ public class D_Face
|
||||
public void SetAngleBracketCollection(string dResultsFullGroupDirectory, string sourceDirectory)
|
||||
{
|
||||
AngleBracketCollection.Clear();
|
||||
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_Configuration,
|
||||
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
dResultsFullGroupDirectory,
|
||||
contentDescription: "n png file(s) for each face found",
|
||||
@ -290,7 +301,7 @@ public class D_Face
|
||||
throw new NullReferenceException(nameof(item.ImageFileHolder.DirectoryName));
|
||||
SetAngleBracketCollection(dResultsFullGroupDirectory, item.ImageFileHolder.DirectoryName);
|
||||
}
|
||||
result = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
||||
result = Path.Combine(AngleBracketCollection[0].Replace("<>", _PropertyConfiguration.ResultContent), item.ImageFileHolder.NameWithoutExtension);
|
||||
if (!angleBracketCollectionAny)
|
||||
AngleBracketCollection.Clear();
|
||||
return result;
|
||||
@ -311,7 +322,7 @@ public class D_Face
|
||||
{
|
||||
if (face.Location is null || face.OutputResolution is null)
|
||||
continue;
|
||||
skip.Add(Shared.Models.Stateless.Methods.ILocation.GetWholePercentages(face.Location, ILocation.Digits, face.OutputResolution));
|
||||
skip.Add(Shared.Models.Stateless.Methods.ILocation.GetWholePercentages(face.Location, Shared.Models.Stateless.ILocation.Digits, face.OutputResolution));
|
||||
}
|
||||
foreach (LocationContainer<MetadataExtractor.Directory> locationContainer in locationContainers)
|
||||
{
|
||||
@ -329,7 +340,7 @@ public class D_Face
|
||||
outputResolutionCheck = JsonSerializer.Deserialize<OutputResolution>(json);
|
||||
if (outputResolutionCheck is null || outputResolutionCheck.Width != outputResolutionWidth || outputResolutionCheck.Height != outputResolutionHeight)
|
||||
continue;
|
||||
rectangle = Shared.Models.Stateless.Methods.ILocation.GetRectangle(ILocation.Digits, outputResolutionCheck, locationContainer.WholePercentages);
|
||||
rectangle = Shared.Models.Stateless.Methods.ILocation.GetRectangle(Shared.Models.Stateless.ILocation.Digits, outputResolutionCheck, locationContainer.WholePercentages);
|
||||
if (rectangle is null)
|
||||
continue;
|
||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(outputResolutionHeight, rectangle.Value, outputResolutionWidth);
|
||||
@ -353,8 +364,8 @@ public class D_Face
|
||||
List<Location>? locations;
|
||||
string[] changesFrom = new string[] { 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();
|
||||
string dCollectionFile = Path.Combine(dResultsFullGroupDirectory, "[]", _Configuration.ResultAllInOne, $"{mappingFromItem.Id}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json");
|
||||
FileInfo fileInfo = new(dCollectionFile);
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, mappingFromItem.ImageFileHolder.Name);
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultCollection][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||
if (_ForceFaceLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
@ -440,7 +451,7 @@ public class D_Face
|
||||
results.Add(new(face, null, string.Empty, save));
|
||||
continue;
|
||||
}
|
||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(mappingFromItem.Id, face.Location, ILocation.Digits, face.OutputResolution);
|
||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(mappingFromItem.Id, face.Location, Shared.Models.Stateless.ILocation.Digits, face.OutputResolution);
|
||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{deterministicHashCodeKey}{mappingFromItem.ImageFileHolder.ExtensionLowered}{_FileNameExtension}"));
|
||||
if (_OverrideForFaceImages)
|
||||
save = true;
|
||||
|
@ -85,8 +85,8 @@ public partial class DlibDotNet
|
||||
(ImageCodecInfo hiddenImageCodecInfo, EncoderParameters hiddenEncoderParameters, string hiddenFileNameExtension) = C_Resize.GetGifLowQuality();
|
||||
_Faces = new D_Face(
|
||||
argZero,
|
||||
configuration.CheckDFaceAndUpWriteDates,
|
||||
configuration.PropertyConfiguration,
|
||||
configuration.CheckDFaceAndUpWriteDates,
|
||||
encoderParameters,
|
||||
configuration.FaceDistanceHiddenImageFactor,
|
||||
filenameExtension,
|
||||
@ -136,6 +136,7 @@ public partial class DlibDotNet
|
||||
configuration.OutputExtension,
|
||||
configuration.OutputQuality);
|
||||
_Resize = new C_Resize(
|
||||
configuration.PropertyConfiguration,
|
||||
configuration.ForceResizeLastWriteTimeToCreationTime,
|
||||
configuration.OverrideForResizeImages,
|
||||
configuration.PropertiesChangedForResize,
|
||||
@ -682,7 +683,9 @@ public partial class DlibDotNet
|
||||
{
|
||||
total = 0;
|
||||
(cResultsFullGroupDirectory, c2ResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory) = GetResultsFullGroupDirectories(outputResolution);
|
||||
_BlurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration.ResultAllInOne, c2ResultsFullGroupDirectory);
|
||||
_Faces.Update(dResultsFullGroupDirectory);
|
||||
_Resize.Update(cResultsFullGroupDirectory);
|
||||
_BlurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration, c2ResultsFullGroupDirectory);
|
||||
for (int i = 0; i < containers.Length; i++)
|
||||
{
|
||||
container = containers[i];
|
||||
@ -702,7 +705,7 @@ public partial class DlibDotNet
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
_FaceParts.SetAngleBracketCollection(_Configuration.PropertyConfiguration, d2ResultsFullGroupDirectory, container.SourceDirectory);
|
||||
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, container.SourceDirectory, anyNullOrNoIsUniqueFileName);
|
||||
_Resize.SetAngleBracketCollection(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, container.SourceDirectory);
|
||||
_Resize.SetAngleBracketCollection(cResultsFullGroupDirectory, container.SourceDirectory);
|
||||
exceptionCount = FullParallelWork(maxDegreeOfParallelism,
|
||||
propertyLogic,
|
||||
metadata,
|
||||
|
@ -104,6 +104,7 @@
|
||||
"PropertiesChangedForProperty": false,
|
||||
"PropertiesChangedForResize": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -3,6 +3,7 @@ using System.Text.Json;
|
||||
using View_by_Distance.Metadata.Models.Stateless;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Property.Models.Stateless;
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Metadata.Models;
|
||||
@ -15,17 +16,19 @@ public class B_Metadata
|
||||
|
||||
private readonly Serilog.ILogger? _Log;
|
||||
private readonly bool _PropertiesChangedForMetadata;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly bool _ForceMetadataLastWriteTimeToCreationTime;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
|
||||
public B_Metadata(Configuration configuration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, string bResultsFullGroupDirectory)
|
||||
public B_Metadata(IPropertyConfiguration propertyConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, string bResultsFullGroupDirectory)
|
||||
{
|
||||
_Log = Serilog.Log.ForContext<B_Metadata>();
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
||||
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, bResultsFullGroupDirectory, new string[] { "{}" });
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, bResultsFullGroupDirectory, new string[] { propertyConfiguration.ResultSingleton });
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -83,10 +86,9 @@ public class B_Metadata
|
||||
string json = string.Empty;
|
||||
string[] changesFrom = new string[] { nameof(A_Property) };
|
||||
Dictionary<string, List<KeyValuePair<string, string>>>? dictionary;
|
||||
char directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(mappingFromItem.ImageFileHolder.Name);
|
||||
int directoryIndex = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(directory);
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
FileInfo fileInfo = new(Path.Combine(_JsonGroups["{}"][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, mappingFromItem.ImageFileHolder.Name);
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||
if (_ForceMetadataLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
|
@ -160,6 +160,7 @@ public class MoveById
|
||||
List<string> allFiles = GetAllFiles(matchNginxCollection);
|
||||
ProgressBar progressBar = new(allFiles.Count, message, options);
|
||||
List<string> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
||||
progressBar.Dispose();
|
||||
List<(string, string)> moveCollection = new();
|
||||
foreach (string file in toDoCollection)
|
||||
{
|
||||
@ -179,7 +180,6 @@ public class MoveById
|
||||
continue;
|
||||
File.Move(from, to);
|
||||
}
|
||||
progressBar.Dispose();
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -13,6 +13,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
@ -134,6 +135,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -7,6 +7,7 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Property.Models.Stateless;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Property.Models;
|
||||
@ -25,21 +26,23 @@ public class A_Property
|
||||
private readonly ASCIIEncoding _ASCIIEncoding;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly List<string> _AngleBracketCollection;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
|
||||
public A_Property(int maxDegreeOfParallelism, Configuration configuration, string outputExtension, bool reverse, string aResultsFullGroupDirectory)
|
||||
public A_Property(int maxDegreeOfParallelism, Configuration propertyConfiguration, string outputExtension, bool reverse, string aResultsFullGroupDirectory)
|
||||
{
|
||||
Reverse = reverse;
|
||||
_Configuration = configuration;
|
||||
_ExceptionsDirectories = new();
|
||||
_OutputExtension = outputExtension;
|
||||
_ASCIIEncoding = new ASCIIEncoding();
|
||||
_Configuration = propertyConfiguration;
|
||||
_Log = Serilog.Log.ForContext<A_Property>();
|
||||
_AngleBracketCollection = new List<string>();
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, aResultsFullGroupDirectory, new string[] { "{}" });
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, aResultsFullGroupDirectory, new string[] { propertyConfiguration.ResultSingleton });
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -263,12 +266,13 @@ public class A_Property
|
||||
string[] changesFrom = Array.Empty<string>();
|
||||
string angleBracket = _AngleBracketCollection[0];
|
||||
bool populateId = _Configuration.PopulatePropertyId;
|
||||
char directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(item.ImageFileHolder.Name);
|
||||
int directoryIndex = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(directory);
|
||||
if (!item.IsUniqueFileName)
|
||||
fileInfo = new(Path.Combine(angleBracket.Replace("<>", "{}"), $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
fileInfo = new(Path.Combine(angleBracket.Replace("<>", _PropertyConfiguration.ResultSingleton), $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
else
|
||||
fileInfo = new(Path.Combine(_JsonGroups["{}"][directoryIndex], $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
{
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, item.ImageFileHolder.Name);
|
||||
fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
}
|
||||
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")))
|
||||
{
|
||||
@ -378,7 +382,7 @@ public class A_Property
|
||||
Shared.Models.Property property;
|
||||
List<string> parseExceptions = new();
|
||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
string filteredSourceDirectoryFileExtensionLowered = Path.Combine(sourceDirectory, $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}");
|
||||
if (item.IsValidImageFormatExtension && item.ImageFileHolder.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && item.ImageFileHolder.FullName != filteredSourceDirectoryFileExtensionLowered)
|
||||
File.Move(item.ImageFileHolder.FullName, filteredSourceDirectoryFileExtensionLowered);
|
||||
@ -427,7 +431,7 @@ public class A_Property
|
||||
if (!anyNullOrNoIsUniqueFileName)
|
||||
_AngleBracketCollection.AddRange(new[] { Path.Combine(aResultsFullGroupDirectory, "<>") });
|
||||
else
|
||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_Configuration,
|
||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
aResultsFullGroupDirectory,
|
||||
contentDescription: string.Empty,
|
||||
@ -439,7 +443,7 @@ public class A_Property
|
||||
private void SetAngleBracketCollection(string sourceDirectory, bool anyNullOrNoIsUniqueFileName)
|
||||
{
|
||||
_AngleBracketCollection.Clear();
|
||||
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_Configuration,
|
||||
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_PropertyConfiguration,
|
||||
nameof(A_Property),
|
||||
string.Empty,
|
||||
includeResizeGroup: false,
|
||||
@ -461,7 +465,7 @@ public class A_Property
|
||||
int containersLength = containers.Length;
|
||||
const string outputResolution = "Original";
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
|
||||
string propertyRoot = IResult.GetResultsGroupDirectory(_Configuration, nameof(A_Property));
|
||||
string propertyRoot = IResult.GetResultsGroupDirectory(_PropertyConfiguration, nameof(A_Property));
|
||||
for (int i = 0; i < containers.Length; i++)
|
||||
{
|
||||
container = containers[i];
|
||||
@ -506,7 +510,7 @@ public class A_Property
|
||||
SetAngleBracketCollection(item.ImageFileHolder.DirectoryName, !item.IsUniqueFileName);
|
||||
}
|
||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
result = GetPropertyOfPrivate(item, sourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidMetadataExtensions);
|
||||
if (!angleBracketCollectionAny)
|
||||
_AngleBracketCollection.Clear();
|
||||
|
@ -21,6 +21,7 @@ public class Configuration
|
||||
[Display(Name = "Properties Changed For Property"), Required] public bool? PropertiesChangedForProperty { get; set; }
|
||||
[Display(Name = "Property Content Collection Files"), Required] public string[] PropertyContentCollectionFiles { get; set; }
|
||||
[Display(Name = "Result All In One"), Required] public string ResultAllInOne { get; set; }
|
||||
[Display(Name = "Result All In One Max Value"), Required] public int? ResultAllInOneSubdirectoryLength { get; set; }
|
||||
[Display(Name = "Result Collection"), Required] public string ResultCollection { get; set; }
|
||||
[Display(Name = "Result Content"), Required] public string ResultContent { get; set; }
|
||||
[Display(Name = "Result Singleton"), Required] public string ResultSingleton { get; set; }
|
||||
@ -53,6 +54,8 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForProperty));
|
||||
if (configuration.ResultAllInOne is null)
|
||||
throw new NullReferenceException(nameof(configuration.ResultAllInOne));
|
||||
if (configuration.ResultAllInOneSubdirectoryLength is null)
|
||||
throw new NullReferenceException(nameof(configuration.ResultAllInOneSubdirectoryLength));
|
||||
if (configuration.ResultCollection is null)
|
||||
throw new NullReferenceException(nameof(configuration.ResultCollection));
|
||||
if (configuration.ResultContent is null)
|
||||
@ -77,6 +80,7 @@ public class Configuration
|
||||
configuration.PropertiesChangedForProperty.Value,
|
||||
configuration.PropertyContentCollectionFiles,
|
||||
configuration.ResultAllInOne,
|
||||
configuration.ResultAllInOneSubdirectoryLength.Value,
|
||||
configuration.ResultCollection,
|
||||
configuration.ResultContent,
|
||||
configuration.ResultSingleton,
|
||||
|
@ -29,6 +29,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
||||
public bool PropertiesChangedForProperty { init; get; }
|
||||
public string[] PropertyContentCollectionFiles { init; get; }
|
||||
public string ResultAllInOne { init; get; }
|
||||
public int ResultAllInOneSubdirectoryLength { init; get; }
|
||||
public string ResultCollection { init; get; }
|
||||
public string ResultContent { init; get; }
|
||||
public string ResultSingleton { init; get; }
|
||||
@ -48,6 +49,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
||||
bool propertiesChangedForProperty,
|
||||
string[] propertyContentCollectionFiles,
|
||||
string resultAllInOne,
|
||||
int resultAllInOneSubdirectoryLength,
|
||||
string resultCollection,
|
||||
string resultContent,
|
||||
string resultSingleton,
|
||||
@ -68,6 +70,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
||||
PropertiesChangedForProperty = propertiesChangedForProperty;
|
||||
PropertyContentCollectionFiles = propertyContentCollectionFiles;
|
||||
ResultAllInOne = resultAllInOne;
|
||||
ResultAllInOneSubdirectoryLength = resultAllInOneSubdirectoryLength;
|
||||
ResultCollection = resultCollection;
|
||||
ResultContent = resultContent;
|
||||
ResultSingleton = resultSingleton;
|
||||
|
@ -8,7 +8,6 @@ using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Rename.Models;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
namespace View_by_Distance.Rename;
|
||||
|
||||
@ -541,17 +540,17 @@ public class Rename
|
||||
private void RenameByDateTakenB(MatchNginx[] matchNginxCollection, string aPropertySingletonDirectory, string[] jsonFiles)
|
||||
{
|
||||
string json;
|
||||
char directory;
|
||||
string[] files;
|
||||
string fileName;
|
||||
string checkFile;
|
||||
string extension;
|
||||
string[] matches;
|
||||
string checkFile;
|
||||
DateTime dateTime;
|
||||
string[] segments;
|
||||
string? checkFileName;
|
||||
string checkDirectory;
|
||||
string directoryName;
|
||||
string? subdirectory;
|
||||
string checkDirectory;
|
||||
string? checkFileName;
|
||||
Shared.Models.Property? property;
|
||||
foreach (MatchNginx matchNginx in matchNginxCollection)
|
||||
{
|
||||
@ -574,9 +573,9 @@ public class Rename
|
||||
fileName = Path.GetFileName(file);
|
||||
segments = fileName.Split('.');
|
||||
extension = Path.GetExtension(file);
|
||||
directory = IDirectory.GetDirectory(fileName);
|
||||
(directoryName, _) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_Configuration.PropertyConfiguration.ResultAllInOneSubdirectoryLength, fileName);
|
||||
checkFileName = $"{segments.First()}{Path.GetExtension(Path.GetFileNameWithoutExtension(file))}.json";
|
||||
checkDirectory = Path.Combine(aPropertySingletonDirectory, _PropertyConfiguration.ResultAllInOne, directory.ToString());
|
||||
checkDirectory = Path.Combine(aPropertySingletonDirectory, _PropertyConfiguration.ResultAllInOne, directoryName);
|
||||
checkFile = Path.Combine(checkDirectory, checkFileName);
|
||||
matches = jsonFiles.Where(l => l == checkFile).ToArray();
|
||||
if (!matches.Any())
|
||||
@ -617,7 +616,7 @@ public class Rename
|
||||
string aPropertySingletonDirectory = Path.GetFullPath(Path.Combine(aResultsFullGroupDirectory, "{}"));
|
||||
string[] jsonFiles = !Directory.Exists(aPropertySingletonDirectory) ? Array.Empty<string>() : Directory.GetFiles(aPropertySingletonDirectory, "*.json", SearchOption.AllDirectories);
|
||||
if (!jsonFiles.Any())
|
||||
log.Information($"No json file(s) found! Check directory <{aPropertySingletonDirectory}>");
|
||||
log.Information($"No json file(s) found! Check directoryName <{aPropertySingletonDirectory}>");
|
||||
else
|
||||
RenameByDateTakenB(matchNginxCollection, aPropertySingletonDirectory, jsonFiles);
|
||||
}
|
||||
|
@ -64,6 +64,7 @@
|
||||
"PopulatePropertyId": true,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultAllInOneSubdirectoryLength": 2,
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
|
@ -5,8 +5,10 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Property.Models.Stateless;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Resize.Models;
|
||||
@ -35,11 +37,14 @@ public class C_Resize
|
||||
private readonly int _OutputResolutionHeightIndex;
|
||||
private readonly EncoderParameters _EncoderParameters;
|
||||
private readonly int _OutputResolutionOrientationIndex;
|
||||
private readonly Dictionary<string, string[]> _FileGroups;
|
||||
private readonly bool _ForceResizeLastWriteTimeToCreationTime;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
|
||||
public C_Resize(bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension)
|
||||
public C_Resize(IPropertyConfiguration propertyConfiguration, bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension)
|
||||
{
|
||||
_FileGroups = new();
|
||||
_Original = "Original";
|
||||
_TempResolutionWidth = 3;
|
||||
_TempResolutionHeight = 4;
|
||||
@ -52,6 +57,7 @@ public class C_Resize
|
||||
_EncoderParameters = encoderParameters;
|
||||
_FileNameExtension = filenameExtension;
|
||||
AngleBracketCollection = new List<string>();
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_OverrideForResizeImages = overrideForResizeImages;
|
||||
_PropertiesChangedForResize = propertiesChangedForResize;
|
||||
_ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
|
||||
@ -66,10 +72,18 @@ public class C_Resize
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SetAngleBracketCollection(Property.Models.Configuration configuration, string cResultsFullGroupDirectory, string sourceDirectory)
|
||||
public void Update(string cResultsFullGroupDirectory)
|
||||
{
|
||||
_FileGroups.Clear();
|
||||
Dictionary<string, string[]> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, new string[] { _PropertyConfiguration.ResultSingleton });
|
||||
foreach (KeyValuePair<string, string[]> keyValuePair in keyValuePairs)
|
||||
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
}
|
||||
|
||||
public void SetAngleBracketCollection(string cResultsFullGroupDirectory, string sourceDirectory)
|
||||
{
|
||||
AngleBracketCollection.Clear();
|
||||
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(configuration,
|
||||
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
cResultsFullGroupDirectory,
|
||||
contentDescription: "Resized image",
|
||||
@ -280,7 +294,6 @@ public class C_Resize
|
||||
|
||||
private void SaveResizedSubfile(Shared.Models.Property property, MappingFromItem mappingFromItem, int[] resize)
|
||||
{
|
||||
// string subFile, Shared.Models.Property property, Shared.Models.FileHolder? fileHolder
|
||||
string dateTimeFormat = Shared.Models.Stateless.Methods.IProperty.DateTimeFormat();
|
||||
DateTime dateTime = property.DateTimeOriginal is not null ? property.DateTimeOriginal.Value : Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(property);
|
||||
string dateTimeValue = dateTime.ToString(dateTimeFormat);
|
||||
@ -295,7 +308,7 @@ public class C_Resize
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public void SaveResizedSubfile(Property.Models.Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize)
|
||||
public void SaveResizedSubfile(Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize)
|
||||
{
|
||||
if (mappingFromItem.ResizedFileHolder is null)
|
||||
throw new NullReferenceException(nameof(mappingFromItem.ResizedFileHolder));
|
||||
@ -310,7 +323,7 @@ public class C_Resize
|
||||
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
|
||||
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
|
||||
int[] originalCollection = outputResolutionToResize[_Original];
|
||||
string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
||||
string[] changesFrom = new string[] { 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();
|
||||
if (_OverrideForResizeImages)
|
||||
check = true;
|
||||
@ -408,18 +421,18 @@ public class C_Resize
|
||||
|
||||
public FileHolder GetResizedFileHolder(Item item)
|
||||
{
|
||||
FileHolder result = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(item.ImageFileHolder.FullName)));
|
||||
FileHolder result = new(Path.Combine(AngleBracketCollection[0].Replace("<>", _PropertyConfiguration.ResultContent), Path.GetFileName(item.ImageFileHolder.FullName)));
|
||||
return result;
|
||||
}
|
||||
|
||||
public Dictionary<string, int[]> GetResizeKeyValuePairs(Property.Models.Configuration configuration, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, List<KeyValuePair<string, string>> metadataCollection, Shared.Models.Property property, MappingFromItem mappingFromItem)
|
||||
public Dictionary<string, int[]> GetResizeKeyValuePairs(Configuration configuration, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, List<KeyValuePair<string, string>> metadataCollection, Shared.Models.Property property, MappingFromItem mappingFromItem)
|
||||
{
|
||||
Dictionary<string, int[]>? results;
|
||||
string json;
|
||||
string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata) };
|
||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata) };
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
string cResizeSingletonFile = Path.Combine(cResultsFullGroupDirectory, "{}", configuration.ResultAllInOne, $"{mappingFromItem.Id}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json");
|
||||
FileInfo fileInfo = new(cResizeSingletonFile);
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, mappingFromItem.ImageFileHolder.Name);
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||
if (_ForceResizeLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
|
@ -4,7 +4,7 @@ public interface IBlurHasher
|
||||
{
|
||||
|
||||
string Encode(FileHolder fileHolder);
|
||||
string? GetFile(FileHolder fileHolder);
|
||||
string GetFile(FileHolder fileHolder);
|
||||
string EncodeAndSave(FileHolder fileHolder);
|
||||
|
||||
}
|
@ -9,6 +9,7 @@ public interface IPropertyConfiguration
|
||||
public bool PropertiesChangedForProperty { init; get; }
|
||||
public string[] PropertyContentCollectionFiles { init; get; }
|
||||
public string ResultAllInOne { init; get; }
|
||||
public int ResultAllInOneSubdirectoryLength { init; get; }
|
||||
public string ResultCollection { init; get; }
|
||||
public string ResultContent { init; get; }
|
||||
public string ResultSingleton { init; get; }
|
||||
|
@ -92,7 +92,7 @@ internal abstract class Container
|
||||
compareFileNamesToFiles = IDirectory.GetFilesKeyValuePairs(jsonFilesCollection);
|
||||
renamed += IDirectory.LookForAbandoned(jsonFilesCollection, fileNamesToFiles, extension);
|
||||
filePairs = IDirectory.GetFiles(filesCollection, fileNamesToFiles, extension, compareFileNamesToFiles);
|
||||
renamed += IDirectory.MaybeMove(propertyConfiguration.RootDirectory, propertyConfiguration.ResultAllInOne, filePairs, aPropertySingletonDirectory, extension);
|
||||
renamed += IDirectory.MaybeMove(propertyConfiguration.RootDirectory, propertyConfiguration.ResultAllInOne, propertyConfiguration.ResultAllInOneSubdirectoryLength, filePairs, aPropertySingletonDirectory, extension);
|
||||
if (renamed == 0)
|
||||
break;
|
||||
}
|
||||
@ -119,7 +119,6 @@ internal abstract class Container
|
||||
|
||||
private static void ParallelFor(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string extension, int length, Models.FilePair filePair, List<FilePair> results)
|
||||
{
|
||||
char directory;
|
||||
string fileName;
|
||||
bool abandoned = false;
|
||||
Models.FileHolder sourceDirectoryFileHolder;
|
||||
@ -136,8 +135,8 @@ internal abstract class Container
|
||||
else
|
||||
{
|
||||
fileName = Path.GetFileName(filePair.Path);
|
||||
directory = IDirectory.GetDirectory(fileName);
|
||||
sourceDirectoryFileHolder = new(Path.Combine(aPropertySingletonDirectory, propertyConfiguration.ResultAllInOne, directory.ToString(), $"{fileName}{extension}"));
|
||||
(string directoryName, _) = IPath.GetDirectoryNameAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, fileName);
|
||||
sourceDirectoryFileHolder = new(Path.Combine(aPropertySingletonDirectory, propertyConfiguration.ResultAllInOne, directoryName, $"{fileName}{extension}"));
|
||||
}
|
||||
if (imageFileInfo.LastWriteTime is not null && sourceDirectoryFileHolder.CreationTime is not null && sourceDirectoryFileHolder.LastWriteTime is not null && imageFileInfo.LastWriteTime.Value != sourceDirectoryFileHolder.CreationTime.Value)
|
||||
{
|
||||
|
@ -8,11 +8,6 @@ public interface IDirectory
|
||||
static char GetDirectory(string fileName) =>
|
||||
fileName.Split('-').Length > 2 ? '-' : fileName.Split('.')[0][^1];
|
||||
|
||||
string TestStatic_GetDirectory(string fileName, int length) =>
|
||||
GetDirectory(fileName, length);
|
||||
static string GetDirectory(string fileName, int length) =>
|
||||
fileName.Length < length ? new('-', length) : fileName.Split('.')[0][^length..];
|
||||
|
||||
int TestStatic_GetDirectory(char directory) =>
|
||||
GetDirectory(directory);
|
||||
static int GetDirectory(char directory) =>
|
||||
@ -33,10 +28,10 @@ public interface IDirectory
|
||||
static int LookForAbandoned(List<string[]> jsonFilesCollection, IReadOnlyDictionary<string, List<string>> fileNamesToFiles, string extension) =>
|
||||
XDirectory.LookForAbandoned(jsonFilesCollection, fileNamesToFiles, extension);
|
||||
|
||||
int TestStatic_MaybeMove(string directory, string resultAllInOne, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
||||
MaybeMove(directory, resultAllInOne, filePairs, jsonGroupDirectory, extension);
|
||||
static int MaybeMove(string directory, string resultAllInOne, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
||||
XDirectory.MaybeMove(directory, resultAllInOne, filePairs, jsonGroupDirectory, extension);
|
||||
int TestStatic_MaybeMove(string directory, string resultAllInOne, int resultAllInOneSubdirectoryLength, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
||||
MaybeMove(directory, resultAllInOne, resultAllInOneSubdirectoryLength, filePairs, jsonGroupDirectory, extension);
|
||||
static int MaybeMove(string directory, string resultAllInOne, int resultAllInOneSubdirectoryLength, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
||||
XDirectory.MaybeMove(directory, resultAllInOne, resultAllInOneSubdirectoryLength, filePairs, jsonGroupDirectory, extension);
|
||||
|
||||
List<FilePair> TestStatic_GetFiles(List<string[]> filesCollection, IReadOnlyDictionary<string, List<string>> fileNamesToFiles, string extension, IReadOnlyDictionary<string, List<string>> compareFileNamesToFiles) =>
|
||||
GetFiles(filesCollection, fileNamesToFiles, extension, compareFileNamesToFiles);
|
||||
|
@ -1,3 +1,5 @@
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
public interface IPath
|
||||
@ -59,9 +61,14 @@ public interface IPath
|
||||
static string GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
||||
XPath.GetDirectory(sourceDirectory, level, directoryName);
|
||||
|
||||
Dictionary<string, string[]> TestStatic_GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12) =>
|
||||
GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, directories, maxValue);
|
||||
static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12) =>
|
||||
XPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, directories, maxValue);
|
||||
(string, int) TestStatic_GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName) =>
|
||||
GetDirectoryNameAndIndex(resultAllInOneSubdirectoryLength, fileName);
|
||||
static (string, int) GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName) =>
|
||||
XPath.GetDirectoryNameAndIndex(resultAllInOneSubdirectoryLength, fileName);
|
||||
|
||||
Dictionary<string, string[]> TestStatic_GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories) =>
|
||||
GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, directories);
|
||||
static Dictionary<string, string[]> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories) =>
|
||||
XPath.GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, directories);
|
||||
|
||||
}
|
@ -61,6 +61,11 @@ public interface IProperty
|
||||
static bool NameWithoutExtensionIsIdFormat(string fileNameWithoutExtension) =>
|
||||
Property.NameWithoutExtensionIsIdFormat(fileNameWithoutExtension);
|
||||
|
||||
bool TestStatic_NameWithoutExtensionIsIdFormat(string[] validImageFormatExtensions, Models.FileHolder fileHolder) =>
|
||||
NameWithoutExtensionIsIdFormat(validImageFormatExtensions, fileHolder);
|
||||
static bool NameWithoutExtensionIsIdFormat(string[] validImageFormatExtensions, Models.FileHolder fileHolder) =>
|
||||
Property.NameWithoutExtensionIsIdFormat(validImageFormatExtensions, fileHolder);
|
||||
|
||||
bool TestStatic_NameWithoutExtensionIsIdFormat(Models.FileHolder fileHolder) =>
|
||||
NameWithoutExtensionIsIdFormat(fileHolder);
|
||||
static bool NameWithoutExtensionIsIdFormat(Models.FileHolder fileHolder) =>
|
||||
|
@ -364,6 +364,30 @@ internal abstract class Property
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static bool NameWithoutExtensionIsIdFormat(string[] validImageFormatExtensions, Models.FileHolder fileHolder)
|
||||
{
|
||||
bool result;
|
||||
bool changed;
|
||||
string? fileNameWithoutExtension = fileHolder.NameWithoutExtension;
|
||||
for (int i = 0; i < validImageFormatExtensions.Length; i++)
|
||||
{
|
||||
changed = false;
|
||||
foreach (string validImageFormatExtension in validImageFormatExtensions)
|
||||
{
|
||||
if (fileNameWithoutExtension.EndsWith(validImageFormatExtension))
|
||||
{
|
||||
changed = true;
|
||||
fileNameWithoutExtension = fileNameWithoutExtension[..^validImageFormatExtension.Length];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!changed)
|
||||
break;
|
||||
}
|
||||
result = NameWithoutExtensionIsIdFormat(fileNameWithoutExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
internal static (DateTime?, DateTime?[], int?, string?) Get(Models.FileHolder fileHolder, bool isIgnoreExtension, bool isValidImageFormatExtension)
|
||||
|
@ -175,17 +175,17 @@ internal abstract partial class XDirectory
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void IsUniqueLoop(string resultAllInOne, string resultAllInOneDirectory, FilePair item, List<(string, string)> rename)
|
||||
private static void IsUniqueLoop(string resultAllInOne, string resultAllInOneDirectory, int resultAllInOneSubdirectoryLength, FilePair item, List<(string, string)> rename)
|
||||
{
|
||||
char directory;
|
||||
string fileName;
|
||||
string directoryName;
|
||||
foreach (string path in item.Collection)
|
||||
{
|
||||
if (path.Contains(resultAllInOne))
|
||||
continue;
|
||||
fileName = Path.GetFileName(path);
|
||||
directory = IDirectory.GetDirectory(fileName);
|
||||
rename.Add(new(path, Path.Combine(resultAllInOneDirectory, directory.ToString(), fileName)));
|
||||
(directoryName, _) = IPath.GetDirectoryNameAndIndex(resultAllInOneSubdirectoryLength, fileName);
|
||||
rename.Add(new(path, Path.Combine(resultAllInOneDirectory, directoryName, fileName)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ internal abstract partial class XDirectory
|
||||
}
|
||||
}
|
||||
|
||||
internal static int MaybeMove(string directory, string resultAllInOne, List<FilePair> filePairs, string jsonGroupDirectory, string extension)
|
||||
internal static int MaybeMove(string directory, string resultAllInOne, int resultAllInOneSubdirectoryLength, List<FilePair> filePairs, string jsonGroupDirectory, string extension)
|
||||
{
|
||||
FileInfo? toFileInfo;
|
||||
FileInfo fromFileInfo;
|
||||
@ -212,7 +212,7 @@ internal abstract partial class XDirectory
|
||||
foreach (FilePair item in filePairs)
|
||||
{
|
||||
if (item.IsUnique)
|
||||
IsUniqueLoop(resultAllInOne, resultAllInOneDirectory, item, rename);
|
||||
IsUniqueLoop(resultAllInOne, resultAllInOneDirectory, resultAllInOneSubdirectoryLength, item, rename);
|
||||
else
|
||||
IsNotUniqueLoop(directory, resultAllInOne, jsonGroupDirectory, extension, item, rename);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class XPath
|
||||
@ -257,15 +259,31 @@ internal abstract class XPath
|
||||
}
|
||||
}
|
||||
|
||||
internal static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12)
|
||||
internal static (string, int) GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName)
|
||||
{
|
||||
int converted;
|
||||
string result;
|
||||
string check = fileName.Length < resultAllInOneSubdirectoryLength ? new('-', resultAllInOneSubdirectoryLength) : fileName.Split('.')[0][^resultAllInOneSubdirectoryLength..];
|
||||
if (check.Any(l => !char.IsNumber(l)))
|
||||
{
|
||||
result = new('-', resultAllInOneSubdirectoryLength);
|
||||
converted = int.Parse($"1{new string('0', resultAllInOneSubdirectoryLength)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = check;
|
||||
converted = int.Parse(check);
|
||||
}
|
||||
return (result, converted);
|
||||
}
|
||||
|
||||
internal static Dictionary<string, string[]> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories)
|
||||
{
|
||||
Dictionary<string, string[]> results = new();
|
||||
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||
string checkDirectory;
|
||||
int minusOne = maxValue - 1;
|
||||
int minusTwo = maxValue - 2;
|
||||
int minusThree = maxValue - 3;
|
||||
int plusOne = converted + 1;
|
||||
List<string> collection = new();
|
||||
int length = minusThree.ToString().Length;
|
||||
if (directories is not null)
|
||||
{
|
||||
foreach (string key in directories)
|
||||
@ -273,14 +291,12 @@ internal abstract class XPath
|
||||
if (resultsFullGroupDirectory is null)
|
||||
continue;
|
||||
collection.Clear();
|
||||
for (int i = 0; i < maxValue; i++)
|
||||
for (int i = 0; i < plusOne; i++)
|
||||
{
|
||||
if (i == minusTwo)
|
||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('-', length));
|
||||
else if (i == minusOne)
|
||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('_', length));
|
||||
if (i == converted)
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||
else
|
||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, i.ToString().PadLeft(length, '0'));
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
collection.Add(checkDirectory);
|
||||
|
@ -255,43 +255,6 @@ public partial class UnitTestCalculations
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMovingFiles()
|
||||
{
|
||||
char directory;
|
||||
string fileName;
|
||||
string checkFile;
|
||||
int directoryIndex;
|
||||
string checkDirectory;
|
||||
List<string> collection = new();
|
||||
string source = "C:/1234567890123456789";
|
||||
if (Directory.Exists(source))
|
||||
{
|
||||
for (int i = 0; i < 11; i++)
|
||||
{
|
||||
if (i == 10)
|
||||
checkDirectory = Path.Combine(source, "-");
|
||||
else
|
||||
checkDirectory = Path.Combine(source, i.ToString());
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
collection.Add(checkDirectory);
|
||||
}
|
||||
Dictionary<string, string[]> jsonGroups = new() { { "{}", collection.ToArray() } };
|
||||
foreach (string file in Directory.GetFiles(source))
|
||||
{
|
||||
fileName = Path.GetFileName(file);
|
||||
directory = IDirectory.GetDirectory(fileName);
|
||||
directoryIndex = IDirectory.GetDirectory(directory);
|
||||
checkFile = Path.Combine(jsonGroups["{}"][directoryIndex], fileName);
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodMonth()
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ public class UnitTestResize
|
||||
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality);
|
||||
B_Metadata metadata = new(_Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, bResultsFullGroupDirectory);
|
||||
_ = metadata.ToString();
|
||||
C_Resize resize = new(_Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
||||
C_Resize resize = new(_Configuration.PropertyConfiguration, _Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
||||
_ = resize.ToString();
|
||||
bool isUniqueFileName = false;
|
||||
bool? isNotUniqueAndNeedsReview = null;
|
||||
@ -164,7 +164,7 @@ public class UnitTestResize
|
||||
string relativePath = IPath.GetRelativePath(fileHolder.FullName, length);
|
||||
string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName));
|
||||
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory);
|
||||
resize.SetAngleBracketCollection(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, sourceDirectory);
|
||||
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
||||
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
||||
Assert.IsNotNull(item.ImageFileHolder);
|
||||
if (item.Property is null)
|
||||
@ -175,7 +175,7 @@ public class UnitTestResize
|
||||
if (property is null || item.Property is null)
|
||||
throw new NullReferenceException(nameof(property));
|
||||
resizedFileHolder = resize.GetResizedFileHolder(item);
|
||||
Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration.ResultAllInOne, resultsFullGroupDirectory: null);
|
||||
Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration, resultsFullGroupDirectory: null);
|
||||
_ = blurHasher.Encode(resizedFileHolder);
|
||||
item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder);
|
||||
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item);
|
||||
|
@ -228,7 +228,7 @@ public class UnitTestFace
|
||||
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality);
|
||||
B_Metadata metadata = new(_Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, bResultsFullGroupDirectory);
|
||||
_ = metadata.ToString();
|
||||
C_Resize resize = new(_Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
||||
C_Resize resize = new(_Configuration.PropertyConfiguration, _Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
||||
_ = resize.ToString();
|
||||
bool isUniqueFileName = false;
|
||||
bool? isNotUniqueAndNeedsReview = null;
|
||||
@ -238,7 +238,7 @@ public class UnitTestFace
|
||||
string relativePath = IPath.GetRelativePath(fileHolder.FullName, length);
|
||||
string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName));
|
||||
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory);
|
||||
resize.SetAngleBracketCollection(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, sourceDirectory);
|
||||
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
||||
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
||||
Assert.IsNotNull(item.ImageFileHolder);
|
||||
if (item.Property is null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user