GetAlternateFileLines
This commit is contained in:
parent
1c5a2f1d93
commit
3c86acdbda
@ -92,9 +92,9 @@ public class CopyDistinct
|
|||||||
return (move, filesCollection, anyLenFiles, moveBack);
|
return (move, filesCollection, anyLenFiles, moveBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (string[], List<(FileHolder, string)>) GetMoveBackToDoCollection(List<string[]> filesCollection)
|
private static (string[], List<(FileHolder, string?, string)>) GetMoveBackToDoCollection(List<string[]> filesCollection)
|
||||||
{
|
{
|
||||||
List<(FileHolder, string)> results = new();
|
List<(FileHolder, string?, string)> results = new();
|
||||||
string key;
|
string key;
|
||||||
string? value;
|
string? value;
|
||||||
string fileName;
|
string fileName;
|
||||||
@ -146,7 +146,7 @@ public class CopyDistinct
|
|||||||
directory = Path.GetDirectoryName(value);
|
directory = Path.GetDirectoryName(value);
|
||||||
if (string.IsNullOrEmpty(directory))
|
if (string.IsNullOrEmpty(directory))
|
||||||
continue;
|
continue;
|
||||||
results.Add(new(new(file), value));
|
results.Add(new(new(file), null, value));
|
||||||
if (!distinctDirectories.Contains(directory))
|
if (!distinctDirectories.Contains(directory))
|
||||||
distinctDirectories.Add(directory);
|
distinctDirectories.Add(directory);
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ public class CopyDistinct
|
|||||||
string[] distinctDirectories;
|
string[] distinctDirectories;
|
||||||
ConsoleKey? consoleKey = null;
|
ConsoleKey? consoleKey = null;
|
||||||
string message = nameof(CopyDistinct);
|
string message = nameof(CopyDistinct);
|
||||||
List<(FileHolder, string)> toDoCollection;
|
List<(FileHolder, string?, string)> toDoCollection;
|
||||||
int count = filesCollection.Select(l => l.Length).Sum();
|
int count = filesCollection.Select(l => l.Length).Sum();
|
||||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||||
if (moveBack)
|
if (moveBack)
|
||||||
|
@ -189,7 +189,7 @@ public class DuplicateSearch
|
|||||||
if (mappingFromItem is not null)
|
if (mappingFromItem is not null)
|
||||||
{
|
{
|
||||||
resizedFileHolder = new(mappingFromItem.ResizedFileHolder.FullName.Replace($"0{duplicates}", $"1{duplicates}"));
|
resizedFileHolder = new(mappingFromItem.ResizedFileHolder.FullName.Replace($"0{duplicates}", $"1{duplicates}"));
|
||||||
collection[0] = new(mappingFromItem.ContainerDateTimes, item.Property.DateTimeDigitized, item.Property.DateTimeOriginal, mappingFromItem.Id, mappingFromItem.ImageFileHolder, mappingFromItem.IsWrongYear, item.Property.Keywords, mappingFromItem.MinimumDateTime, item.Property.Model, mappingFromItem.RelativePath, resizedFileHolder);
|
collection[0] = new(mappingFromItem.ContainerDateTimes, item.Property.DateTimeDigitized, item.Property.DateTimeOriginal, mappingFromItem.Id, mappingFromItem.ImageFileHolder, mappingFromItem.IsWrongYear, item.Property.Keywords ?? Array.Empty<string>(), mappingFromItem.MinimumDateTime, item.Property.Model, mappingFromItem.RelativePath, resizedFileHolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resizedFileHolder = new(string.Concat(Path.Combine(destinationRoot, directory), item.RelativePath));
|
resizedFileHolder = new(string.Concat(Path.Combine(destinationRoot, directory), item.RelativePath));
|
||||||
|
@ -1102,10 +1102,33 @@ public partial class DlibDotNet
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private (string, List<string[]>) GetFilesCollectionThenCopyOrMove(long ticks, string fileSearchFilter, string directorySearchFilter, ProgressBarOptions options, string outputResolution)
|
||||||
|
{
|
||||||
|
ProgressBar progressBar;
|
||||||
|
string filesCollectionRootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
||||||
|
(string cResultsFullGroupDirectory, _, _, _) = GetResultsFullGroupDirectories(outputResolution);
|
||||||
|
IReadOnlyDictionary<string, string[]> fileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, new string[] { _Configuration.PropertyConfiguration.ResultContent });
|
||||||
|
List<string[]> filesCollection = IDirectory.GetFilesCollection(filesCollectionRootDirectory, directorySearchFilter, fileSearchFilter, useCeilingAverage: false);
|
||||||
|
int count = filesCollection.Select(l => l.Length).Sum();
|
||||||
|
string message = $") Selecting for ## pattern directory - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
||||||
|
progressBar = new(count, message, options);
|
||||||
|
(string[] distinctDirectories, List<(FileHolder, string?, string)> toDoCollection) = IDirectory.GetToDoCollection(_Configuration.PropertyConfiguration, filesCollection, fileGroups[_Configuration.PropertyConfiguration.ResultContent], () => progressBar.Tick());
|
||||||
|
progressBar.Dispose();
|
||||||
|
foreach (string distinctDirectory in distinctDirectories)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(distinctDirectory))
|
||||||
|
_ = Directory.CreateDirectory(distinctDirectory);
|
||||||
|
}
|
||||||
|
message = $") Copying to ## pattern directory - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
||||||
|
progressBar = new(count, message, options);
|
||||||
|
_ = IDirectory.CopyOrMove(toDoCollection, move: false, moveBack: false, () => progressBar.Tick());
|
||||||
|
progressBar.Dispose();
|
||||||
|
return (filesCollectionRootDirectory, filesCollection);
|
||||||
|
}
|
||||||
|
|
||||||
private void Search(long ticks, ReadOnlyCollection<PersonContainer> personContainers, string argZero, string propertyRoot)
|
private void Search(long ticks, ReadOnlyCollection<PersonContainer> personContainers, string argZero, string propertyRoot)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
int count;
|
|
||||||
string message;
|
string message;
|
||||||
MapLogic? mapLogic;
|
MapLogic? mapLogic;
|
||||||
Container[] containers;
|
Container[] containers;
|
||||||
@ -1121,6 +1144,7 @@ public partial class DlibDotNet
|
|||||||
bool filesCollectionCountIsOne = false;
|
bool filesCollectionCountIsOne = false;
|
||||||
List<string[]>? filesCollection = null;
|
List<string[]>? filesCollection = null;
|
||||||
const string directorySearchFilter = "*";
|
const string directorySearchFilter = "*";
|
||||||
|
string? filesCollectionRootDirectory = null;
|
||||||
bool configurationOutputResolutionsHas = false;
|
bool configurationOutputResolutionsHas = false;
|
||||||
ReadOnlyDictionary<long, List<int>> personKeyToIds;
|
ReadOnlyDictionary<long, List<int>> personKeyToIds;
|
||||||
bool runToDoCollectionFirst = GetRunToDoCollectionFirst(ticks);
|
bool runToDoCollectionFirst = GetRunToDoCollectionFirst(ticks);
|
||||||
@ -1143,20 +1167,8 @@ public partial class DlibDotNet
|
|||||||
configurationOutputResolutionsHas = true;
|
configurationOutputResolutionsHas = true;
|
||||||
if (!runToDoCollectionFirst)
|
if (!runToDoCollectionFirst)
|
||||||
break;
|
break;
|
||||||
ProgressBar progressBar;
|
(filesCollectionRootDirectory, filesCollection) = GetFilesCollectionThenCopyOrMove(ticks, fileSearchFilter, directorySearchFilter, options, outputResolution);
|
||||||
(cResultsFullGroupDirectory, _, _, _) = GetResultsFullGroupDirectories(outputResolution);
|
|
||||||
IReadOnlyDictionary<string, string[]> fileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, new string[] { _Configuration.PropertyConfiguration.ResultContent });
|
|
||||||
filesCollection = IDirectory.GetFilesCollection(_Configuration.PropertyConfiguration.RootDirectory, directorySearchFilter, fileSearchFilter, useCeilingAverage: false);
|
|
||||||
message = $") Selecting for ## pattern directory - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
|
||||||
count = filesCollection.Select(l => l.Length).Sum();
|
|
||||||
filesCollectionCountIsOne = filesCollection.Count == 1;
|
filesCollectionCountIsOne = filesCollection.Count == 1;
|
||||||
progressBar = new(count, message, options);
|
|
||||||
(string[] distinctDirectories, List<(FileHolder, string)> toDoCollection) = IDirectory.GetToDoCollection(_Configuration.PropertyConfiguration, filesCollection, fileGroups[_Configuration.PropertyConfiguration.ResultContent], () => progressBar.Tick());
|
|
||||||
progressBar.Dispose();
|
|
||||||
message = $") Copying to ## pattern directory - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
|
||||||
progressBar = new(count, message, options);
|
|
||||||
_ = IDirectory.CopyOrMove(toDoCollection, move: false, moveBack: false, () => progressBar.Tick());
|
|
||||||
progressBar.Dispose();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fPhotoPrismContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(F_PhotoPrism), _Configuration.PropertyConfiguration.ResultContent);
|
fPhotoPrismContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(F_PhotoPrism), _Configuration.PropertyConfiguration.ResultContent);
|
||||||
@ -1184,17 +1196,19 @@ public partial class DlibDotNet
|
|||||||
}
|
}
|
||||||
if (configurationOutputResolutionsHas)
|
if (configurationOutputResolutionsHas)
|
||||||
{
|
{
|
||||||
|
int count;
|
||||||
foreach (string outputResolution in _Configuration.OutputResolutions)
|
foreach (string outputResolution in _Configuration.OutputResolutions)
|
||||||
{
|
{
|
||||||
if (outputResolution.Any(l => char.IsNumber(l)))
|
if (outputResolution.Any(l => char.IsNumber(l)))
|
||||||
continue;
|
continue;
|
||||||
(cResultsFullGroupDirectory, _, _, _) = GetResultsFullGroupDirectories(outputResolution);
|
(cResultsFullGroupDirectory, _, _, _) = GetResultsFullGroupDirectories(outputResolution);
|
||||||
filesCollection = IDirectory.GetFilesCollection(Path.Combine(cResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultContent, _Configuration.PropertyConfiguration.ResultAllInOne), directorySearchFilter, fileSearchFilter, useCeilingAverage: true);
|
filesCollectionRootDirectory = Path.Combine(cResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultContent, _Configuration.PropertyConfiguration.ResultAllInOne);
|
||||||
|
filesCollection = IDirectory.GetFilesCollection(filesCollectionRootDirectory, directorySearchFilter, fileSearchFilter, useCeilingAverage: true);
|
||||||
count = filesCollection.Select(l => l.Length).Sum();
|
count = filesCollection.Select(l => l.Length).Sum();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (filesCollection is null)
|
if (filesCollectionRootDirectory is null || filesCollection is null)
|
||||||
throw new NullReferenceException(nameof(filesCollection));
|
throw new NullReferenceException(nameof(filesCollection));
|
||||||
message = $") Building Container(s) - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
message = $") Building Container(s) - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
||||||
using (ProgressBar progressBar = new(2, message, options))
|
using (ProgressBar progressBar = new(2, message, options))
|
||||||
@ -1203,7 +1217,7 @@ public partial class DlibDotNet
|
|||||||
string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultSingleton);
|
string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultSingleton);
|
||||||
if (!Directory.Exists(aPropertySingletonDirectory))
|
if (!Directory.Exists(aPropertySingletonDirectory))
|
||||||
_ = Directory.CreateDirectory(aPropertySingletonDirectory);
|
_ = Directory.CreateDirectory(aPropertySingletonDirectory);
|
||||||
(t, containers) = Shared.Models.Stateless.Methods.IContainer.GetContainers(_Configuration.PropertyConfiguration, aPropertySingletonDirectory, filesCollection);
|
(t, containers) = Shared.Models.Stateless.Methods.IContainer.GetContainers(_Configuration.PropertyConfiguration, aPropertySingletonDirectory, filesCollectionRootDirectory, filesCollection);
|
||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
}
|
}
|
||||||
fileNameToCollection = !Directory.Exists(fPhotoPrismSingletonDirectory) ? fileNameToCollection = new() : F_PhotoPrism.GetFileNameToCollection(fPhotoPrismSingletonDirectory);
|
fileNameToCollection = !Directory.Exists(fPhotoPrismSingletonDirectory) ? fileNameToCollection = new() : F_PhotoPrism.GetFileNameToCollection(fPhotoPrismSingletonDirectory);
|
||||||
|
@ -281,7 +281,7 @@ internal abstract class MapLogic
|
|||||||
string manualCopyHumanized = nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title);
|
string manualCopyHumanized = nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title);
|
||||||
string forceSingleImageHumanized = nameof(Shared.Models.Stateless.IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
string forceSingleImageHumanized = nameof(Shared.Models.Stateless.IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||||
for (int i = 1; i < 3; i++)
|
for (int i = 1; i < 6; i++)
|
||||||
{
|
{
|
||||||
check = false;
|
check = false;
|
||||||
results.Clear();
|
results.Clear();
|
||||||
|
@ -99,7 +99,7 @@ public class A_Property
|
|||||||
if (item.Property is not null)
|
if (item.Property is not null)
|
||||||
result = item.Property;
|
result = item.Property;
|
||||||
else
|
else
|
||||||
result = JsonSerializer.Deserialize<Shared.Models.Property>(json);
|
result = JsonSerializer.Deserialize(json, PropertyGenerationContext.Default.Property);
|
||||||
if (result is not null && json.Contains("WrongYear"))
|
if (result is not null && json.Contains("WrongYear"))
|
||||||
{
|
{
|
||||||
id = result.Id;
|
id = result.Id;
|
||||||
|
@ -13,7 +13,7 @@ internal class Result
|
|||||||
|
|
||||||
internal static string GetResultsGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, bool create)
|
internal static string GetResultsGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, bool create)
|
||||||
{
|
{
|
||||||
string result = Path.Combine($"{propertyConfiguration.RootDirectory}-Results", description.Replace("_", ") "));
|
string result = Path.Combine($"{propertyConfiguration.RootDirectory}-Results", description.Replace('_', ')'));
|
||||||
if (create && !Directory.Exists(result))
|
if (create && !Directory.Exists(result))
|
||||||
_ = Directory.CreateDirectory(result);
|
_ = Directory.CreateDirectory(result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -30,7 +30,6 @@ taskTemplate: '^+^_${overdue ? ''^R'' : ''''}${name}^: ${relations ? (''\n^-^/^g
|
|||||||
- [use-eyes-to-find-orientation](tasks/use-eyes-to-find-orientation.md)
|
- [use-eyes-to-find-orientation](tasks/use-eyes-to-find-orientation.md)
|
||||||
- [find-incorrectly-mapped-faces](tasks/find-incorrectly-mapped-faces.md)
|
- [find-incorrectly-mapped-faces](tasks/find-incorrectly-mapped-faces.md)
|
||||||
- [nef-support](tasks/nef-support.md)
|
- [nef-support](tasks/nef-support.md)
|
||||||
- [reload-slideshow](tasks/reload-slideshow.md)
|
|
||||||
- [set-date-taken-when-missing](tasks/set-date-taken-when-missing.md)
|
- [set-date-taken-when-missing](tasks/set-date-taken-when-missing.md)
|
||||||
- [triangle-over-person-in-full-image-for-some](tasks/triangle-over-person-in-full-image-for-some.md)
|
- [triangle-over-person-in-full-image-for-some](tasks/triangle-over-person-in-full-image-for-some.md)
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ taskTemplate: '^+^_${overdue ? ''^R'' : ''''}${name}^: ${relations ? (''\n^-^/^g
|
|||||||
- [fix-random-logic](tasks/fix-random-logic.md)
|
- [fix-random-logic](tasks/fix-random-logic.md)
|
||||||
- [move-copy-manual-files-to-get-display-directory-all-files](tasks/move-copy-manual-files-to-get-display-directory-all-files.md)
|
- [move-copy-manual-files-to-get-display-directory-all-files](tasks/move-copy-manual-files-to-get-display-directory-all-files.md)
|
||||||
- [rename-files-to-padded-number-string](tasks/rename-files-to-padded-number-string.md)
|
- [rename-files-to-padded-number-string](tasks/rename-files-to-padded-number-string.md)
|
||||||
|
- [reload-slideshow](tasks/reload-slideshow.md)
|
||||||
- [genealogical-data-communication-as-golden](tasks/genealogical-data-communication-as-golden.md)
|
- [genealogical-data-communication-as-golden](tasks/genealogical-data-communication-as-golden.md)
|
||||||
- [look-for-family-from-jlink-in-x-mapped](tasks/look-for-family-from-jlink-in-x-mapped.md)
|
- [look-for-family-from-jlink-in-x-mapped](tasks/look-for-family-from-jlink-in-x-mapped.md)
|
||||||
- [move-over-2023-california-pictures](tasks/move-over-2023-california-pictures.md)
|
- [move-over-2023-california-pictures](tasks/move-over-2023-california-pictures.md)
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
---
|
---
|
||||||
created: 2023-08-08T05:37:00.125Z
|
created: 2023-08-08T05:37:00.125Z
|
||||||
updated: 2023-08-08T05:37:14.241Z
|
updated: 2023-08-14T02:08:22.605Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
started: 2023-08-08T05:37:10.651Z
|
started: 2023-08-08T05:37:10.651Z
|
||||||
|
completed: 2023-08-14T02:08:22.605Z
|
||||||
---
|
---
|
||||||
|
|
||||||
# Reload slideshow
|
# Reload slideshow
|
||||||
|
@ -6,6 +6,7 @@ namespace View_by_Distance.Shared.Models;
|
|||||||
public class Item : Properties.IItem
|
public class Item : Properties.IItem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected readonly string[] _AlternateFileLines;
|
||||||
protected List<Face> _Faces;
|
protected List<Face> _Faces;
|
||||||
protected readonly bool? _FileSizeChanged;
|
protected readonly bool? _FileSizeChanged;
|
||||||
protected readonly FileHolder _ImageFileHolder;
|
protected readonly FileHolder _ImageFileHolder;
|
||||||
@ -18,6 +19,7 @@ public class Item : Properties.IItem
|
|||||||
protected readonly string _RelativePath;
|
protected readonly string _RelativePath;
|
||||||
protected FileHolder? _ResizedFileHolder;
|
protected FileHolder? _ResizedFileHolder;
|
||||||
protected readonly FileHolder _SourceDirectoryFileHolder;
|
protected readonly FileHolder _SourceDirectoryFileHolder;
|
||||||
|
public string[] AlternateFileLines => _AlternateFileLines;
|
||||||
public List<Face> Faces => _Faces;
|
public List<Face> Faces => _Faces;
|
||||||
public bool? FileSizeChanged => _FileSizeChanged;
|
public bool? FileSizeChanged => _FileSizeChanged;
|
||||||
public FileHolder ImageFileHolder => _ImageFileHolder;
|
public FileHolder ImageFileHolder => _ImageFileHolder;
|
||||||
@ -32,8 +34,9 @@ public class Item : Properties.IItem
|
|||||||
public FileHolder SourceDirectoryFileHolder => _SourceDirectoryFileHolder;
|
public FileHolder SourceDirectoryFileHolder => _SourceDirectoryFileHolder;
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Item(List<Face> faces, bool? fileSizeChanged, FileHolder imageFileHolder, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, bool? lastWriteTimeChanged, bool? moved, Property? property, string relativePath, FileHolder? resizedFileHolder, FileHolder sourceDirectoryFileHolder)
|
public Item(string[] alternateFileLines, List<Face> faces, bool? fileSizeChanged, FileHolder imageFileHolder, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, bool? lastWriteTimeChanged, bool? moved, Property? property, string relativePath, FileHolder? resizedFileHolder, FileHolder sourceDirectoryFileHolder)
|
||||||
{
|
{
|
||||||
|
_AlternateFileLines = alternateFileLines;
|
||||||
_Faces = faces;
|
_Faces = faces;
|
||||||
_FileSizeChanged = fileSizeChanged;
|
_FileSizeChanged = fileSizeChanged;
|
||||||
_ImageFileHolder = imageFileHolder;
|
_ImageFileHolder = imageFileHolder;
|
||||||
@ -48,8 +51,8 @@ public class Item : Properties.IItem
|
|||||||
_SourceDirectoryFileHolder = sourceDirectoryFileHolder;
|
_SourceDirectoryFileHolder = sourceDirectoryFileHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item(FileHolder sourceDirectoryFileHolder, string relativePath, FileHolder imageFileInfo, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, Property? property, bool? abandoned, bool? fileSizeChanged, bool? lastWriteTimeChanged) :
|
public Item(FileHolder sourceDirectoryFileHolder, string relativePath, FileHolder imageFileInfo, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, Property? property, string[] alternateFileLines, bool? abandoned, bool? fileSizeChanged, bool? lastWriteTimeChanged) :
|
||||||
this(new(), fileSizeChanged, imageFileInfo, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, lastWriteTimeChanged, null, property, relativePath, null, sourceDirectoryFileHolder)
|
this(alternateFileLines, new(), fileSizeChanged, imageFileInfo, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, lastWriteTimeChanged, null, property, relativePath, null, sourceDirectoryFileHolder)
|
||||||
{
|
{
|
||||||
if (relativePath.EndsWith(".json"))
|
if (relativePath.EndsWith(".json"))
|
||||||
throw new ArgumentException("Can not be a *.json file!");
|
throw new ArgumentException("Can not be a *.json file!");
|
||||||
@ -58,7 +61,7 @@ public class Item : Properties.IItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Item(FileHolder sourceDirectoryFileHolder, string relativePath, bool isValidImageFormatExtension) :
|
public Item(FileHolder sourceDirectoryFileHolder, string relativePath, bool isValidImageFormatExtension) :
|
||||||
this(sourceDirectoryFileHolder, relativePath, sourceDirectoryFileHolder, null, false, isValidImageFormatExtension, null, null, null, null)
|
this(sourceDirectoryFileHolder, relativePath, sourceDirectoryFileHolder, null, false, isValidImageFormatExtension, null, Array.Empty<string>(), null, null, null)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -9,7 +9,7 @@ public record MappingFromItem(DateTime[] ContainerDateTimes,
|
|||||||
int Id,
|
int Id,
|
||||||
FileHolder ImageFileHolder,
|
FileHolder ImageFileHolder,
|
||||||
bool? IsWrongYear,
|
bool? IsWrongYear,
|
||||||
string[]? Keywords,
|
string[] Keywords,
|
||||||
DateTime MinimumDateTime,
|
DateTime MinimumDateTime,
|
||||||
string? Model,
|
string? Model,
|
||||||
string RelativePath,
|
string RelativePath,
|
||||||
@ -35,7 +35,7 @@ public record MappingFromItem(DateTime[] ContainerDateTimes,
|
|||||||
List<DateTime> dateTimes = item.Property.GetDateTimes();
|
List<DateTime> dateTimes = item.Property.GetDateTimes();
|
||||||
DateTime minimumDateTime = Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
DateTime minimumDateTime = Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||||
(bool? isWrongYear, _) = Stateless.Methods.IProperty.IsWrongYear(item.ImageFileHolder, item.Property.DateTimeOriginal, dateTimes);
|
(bool? isWrongYear, _) = Stateless.Methods.IProperty.IsWrongYear(item.ImageFileHolder, item.Property.DateTimeOriginal, dateTimes);
|
||||||
result = new(containerDateTimes, item.Property.DateTimeDigitized, item.Property.DateTimeOriginal, item.Property.Id.Value, item.ImageFileHolder, isWrongYear, item.Property.Keywords, minimumDateTime, item.Property.Model, item.RelativePath, resizedFileHolder);
|
result = new(containerDateTimes, item.Property.DateTimeDigitized, item.Property.DateTimeOriginal, item.Property.Id.Value, item.ImageFileHolder, isWrongYear, item.Property.Keywords ?? Array.Empty<string>(), minimumDateTime, item.Property.Model, item.RelativePath, resizedFileHolder);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ namespace View_by_Distance.Shared.Models.Properties;
|
|||||||
public interface IItem
|
public interface IItem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public string[] AlternateFileLines { get; }
|
||||||
public bool? FileSizeChanged { get; }
|
public bool? FileSizeChanged { get; }
|
||||||
public List<Face> Faces { get; }
|
public List<Face> Faces { get; }
|
||||||
public FileHolder ImageFileHolder { get; }
|
public FileHolder ImageFileHolder { get; }
|
||||||
|
@ -28,6 +28,23 @@ public record Property(DateTime CreationTime,
|
|||||||
|
|
||||||
public List<DateTime> GetDateTimes() => Stateless.Methods.Property.GetDateTimes(CreationTime, LastWriteTime, DateTime, DateTimeDigitized, DateTimeFromName, DateTimeOriginal, GPSDateStamp);
|
public List<DateTime> GetDateTimes() => Stateless.Methods.Property.GetDateTimes(CreationTime, LastWriteTime, DateTime, DateTimeDigitized, DateTimeFromName, DateTimeOriginal, GPSDateStamp);
|
||||||
|
|
||||||
|
public static Property GetProperty(Property property, string[] keywords) =>
|
||||||
|
new(property.CreationTime,
|
||||||
|
property.DateTime,
|
||||||
|
property.DateTimeDigitized,
|
||||||
|
property.DateTimeFromName,
|
||||||
|
property.DateTimeOriginal,
|
||||||
|
property.FileSize,
|
||||||
|
property.GPSDateStamp,
|
||||||
|
property.Height,
|
||||||
|
property.Id,
|
||||||
|
keywords,
|
||||||
|
property.LastWriteTime,
|
||||||
|
property.Make,
|
||||||
|
property.Model,
|
||||||
|
property.Orientation,
|
||||||
|
property.Width);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
@ -62,31 +62,59 @@ internal abstract class Container
|
|||||||
return filePairs;
|
return filePairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Models.Property? GetProperty(Models.FilePair filePair)
|
private static string[] GetAlternateFileLines(string? alternateFilesCollectionDirectory, Models.FilePair filePair)
|
||||||
{
|
{
|
||||||
Models.Property? property;
|
string[]? results;
|
||||||
|
string pathDirectoryName = Path.GetFileName(Path.GetDirectoryName(filePair.Path) ?? filePair.Path);
|
||||||
|
string? alternateFile = alternateFilesCollectionDirectory is null ? null : Path.Combine(alternateFilesCollectionDirectory, pathDirectoryName, $"{Path.GetFileName(filePair.Path)}.tsv");
|
||||||
|
if (!File.Exists(alternateFile))
|
||||||
|
results = Array.Empty<string>();
|
||||||
|
else
|
||||||
|
results = File.ReadAllLines(alternateFile);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static (Models.Property?, string[]) GetProperty(Models.FilePair filePair, string? alternateFilesCollectionDirectory)
|
||||||
|
{
|
||||||
|
string[] results;
|
||||||
|
Models.Property? result;
|
||||||
if (filePair.Match is null)
|
if (filePair.Match is null)
|
||||||
property = null;
|
(result, results) = (null, Array.Empty<string>());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string json = File.ReadAllText(filePair.Match);
|
string json = File.ReadAllText(filePair.Match);
|
||||||
if (string.IsNullOrEmpty(json))
|
if (string.IsNullOrEmpty(json))
|
||||||
property = null;
|
(result, results) = (null, Array.Empty<string>());
|
||||||
else
|
else
|
||||||
property = JsonSerializer.Deserialize<Models.Property>(json);
|
{
|
||||||
|
result = JsonSerializer.Deserialize(json, PropertyGenerationContext.Default.Property);
|
||||||
|
if (result is null)
|
||||||
|
results = Array.Empty<string>();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
results = alternateFilesCollectionDirectory is null ? Array.Empty<string>() : GetAlternateFileLines(alternateFilesCollectionDirectory, filePair);
|
||||||
|
if (results.Any(l => l.Contains('!')))
|
||||||
|
{
|
||||||
|
if (result.Keywords is null)
|
||||||
|
result = Models.Property.GetProperty(result, new string[] { "!" });
|
||||||
|
else
|
||||||
|
result = Models.Property.GetProperty(result, result.Keywords.Concat(new string[] { "!" }).ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return property;
|
return (result, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ParallelFor(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string extension, int length, Models.FilePair filePair, List<FilePair> results)
|
private static void ParallelFor(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string extension, int rootDirectoryLength, string? alternateFilesCollectionDirectory, Models.FilePair filePair, List<FilePair> results)
|
||||||
{
|
{
|
||||||
string fileName;
|
string fileName;
|
||||||
bool abandoned = false;
|
bool abandoned = false;
|
||||||
Models.FileHolder sourceDirectoryFileHolder;
|
Models.FileHolder sourceDirectoryFileHolder;
|
||||||
Models.Property? property = GetProperty(filePair);
|
|
||||||
Models.FileHolder imageFileInfo = new(filePair.Path);
|
Models.FileHolder imageFileInfo = new(filePair.Path);
|
||||||
|
(Models.Property? property, string[] alternateFileLines) = GetProperty(filePair, alternateFilesCollectionDirectory);
|
||||||
bool? fileSizeChanged = property is not null ? property.FileSize != imageFileInfo.Length : null;
|
bool? fileSizeChanged = property is not null ? property.FileSize != imageFileInfo.Length : null;
|
||||||
string relativePath = IPath.GetRelativePath(filePair.Path, length, forceExtensionToLower: true);
|
string relativePath = IPath.GetRelativePath(filePair.Path, rootDirectoryLength, forceExtensionToLower: true);
|
||||||
bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(imageFileInfo.ExtensionLowered);
|
bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(imageFileInfo.ExtensionLowered);
|
||||||
bool? lastWriteTimeChanged = property is not null ? propertyConfiguration.PropertiesChangedForProperty || property.LastWriteTime != imageFileInfo.LastWriteTime : null;
|
bool? lastWriteTimeChanged = property is not null ? propertyConfiguration.PropertiesChangedForProperty || property.LastWriteTime != imageFileInfo.LastWriteTime : null;
|
||||||
if (filePair.Match is not null)
|
if (filePair.Match is not null)
|
||||||
@ -104,22 +132,24 @@ internal abstract class Container
|
|||||||
File.SetCreationTime(sourceDirectoryFileHolder.FullName, imageFileInfo.LastWriteTime.Value);
|
File.SetCreationTime(sourceDirectoryFileHolder.FullName, imageFileInfo.LastWriteTime.Value);
|
||||||
File.SetLastWriteTime(sourceDirectoryFileHolder.FullName, sourceDirectoryFileHolder.LastWriteTime.Value);
|
File.SetLastWriteTime(sourceDirectoryFileHolder.FullName, sourceDirectoryFileHolder.LastWriteTime.Value);
|
||||||
}
|
}
|
||||||
Models.Item item = new(sourceDirectoryFileHolder, relativePath, imageFileInfo, filePair.IsNotUniqueAndNeedsReview, filePair.IsUnique, isValidImageFormatExtension, property, abandoned, fileSizeChanged, lastWriteTimeChanged);
|
Models.Item item = new(sourceDirectoryFileHolder, relativePath, imageFileInfo, filePair.IsNotUniqueAndNeedsReview, filePair.IsUnique, isValidImageFormatExtension, property, alternateFileLines, abandoned, fileSizeChanged, lastWriteTimeChanged);
|
||||||
lock (results)
|
lock (results)
|
||||||
results.Add(new(filePair.Path, imageFileInfo.DirectoryName, filePair.IsUnique, filePair.Collection, item));
|
results.Add(new(filePair.Path, imageFileInfo.DirectoryName, filePair.IsUnique, filePair.Collection, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<FilePair> GetFilePairs(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string extension, List<Models.FilePair> filePairs)
|
private static List<FilePair> GetFilePairs(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, string extension, List<Models.FilePair> filePairs)
|
||||||
{
|
{
|
||||||
List<FilePair> results = new();
|
List<FilePair> results = new();
|
||||||
int length = propertyConfiguration.RootDirectory.Length;
|
|
||||||
int maxDegreeOfParallelism = Environment.ProcessorCount;
|
int maxDegreeOfParallelism = Environment.ProcessorCount;
|
||||||
|
string? alternateResultAllInOne = !propertyConfiguration.ResultAllInOne.Contains(' ') ? null : propertyConfiguration.ResultAllInOne.Replace(' ', '-');
|
||||||
|
string? alternateFilesCollectionDirectory = alternateResultAllInOne is null ? null : Path.Combine(Path.GetDirectoryName(filesCollectionDirectory) ?? filesCollectionDirectory, alternateResultAllInOne);
|
||||||
|
int filesCollectionDirectoryLength = filesCollectionDirectory.Length;
|
||||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
|
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
|
||||||
_ = Parallel.For(0, filePairs.Count, parallelOptions, (i, state) => ParallelFor(propertyConfiguration, aPropertySingletonDirectory, extension, length, filePairs[i], results));
|
_ = Parallel.For(0, filePairs.Count, parallelOptions, (i, state) => ParallelFor(propertyConfiguration, aPropertySingletonDirectory, extension, filesCollectionDirectoryLength, alternateFilesCollectionDirectory, filePairs[i], results));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string directorySearchFilter, List<string[]> filesCollection)
|
private static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, List<string[]> filesCollection, string directorySearchFilter)
|
||||||
{
|
{
|
||||||
List<Models.Container> results = new();
|
List<Models.Container> results = new();
|
||||||
string? directory;
|
string? directory;
|
||||||
@ -145,7 +175,7 @@ internal abstract class Container
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Models.FilePair> filePairs = GetFilePairs(propertyConfiguration, directorySearchFilter, extension, aPropertySingletonDirectory, filesCollection);
|
List<Models.FilePair> filePairs = GetFilePairs(propertyConfiguration, directorySearchFilter, extension, aPropertySingletonDirectory, filesCollection);
|
||||||
List<FilePair> collection = GetFilePairs(propertyConfiguration, aPropertySingletonDirectory, extension, filePairs);
|
List<FilePair> collection = GetFilePairs(propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, extension, filePairs);
|
||||||
foreach (FilePair filePair in collection)
|
foreach (FilePair filePair in collection)
|
||||||
{
|
{
|
||||||
if (filePair.Directory is null)
|
if (filePair.Directory is null)
|
||||||
@ -168,12 +198,12 @@ internal abstract class Container
|
|||||||
return (collection.Count, results.ToArray());
|
return (collection.Count, results.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, List<string[]> filesCollection)
|
internal static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, List<string[]> filesCollection)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
Models.Container[] results;
|
Models.Container[] results;
|
||||||
const string directorySearchFilter = "*";
|
const string directorySearchFilter = "*";
|
||||||
(count, results) = GetContainers(propertyConfiguration, aPropertySingletonDirectory, directorySearchFilter, filesCollection);
|
(count, results) = GetContainers(propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, filesCollection, directorySearchFilter);
|
||||||
return (count, results);
|
return (count, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +215,7 @@ internal abstract class Container
|
|||||||
const string fileSearchFilter = "*";
|
const string fileSearchFilter = "*";
|
||||||
const string directorySearchFilter = "*";
|
const string directorySearchFilter = "*";
|
||||||
List<string[]> filesCollection = IDirectory.GetFilesCollection(propertyConfiguration.RootDirectory, directorySearchFilter, fileSearchFilter, useCeilingAverage);
|
List<string[]> filesCollection = IDirectory.GetFilesCollection(propertyConfiguration.RootDirectory, directorySearchFilter, fileSearchFilter, useCeilingAverage);
|
||||||
(count, results) = GetContainers(propertyConfiguration, aPropertySingletonDirectory, directorySearchFilter, filesCollection);
|
(count, results) = GetContainers(propertyConfiguration, aPropertySingletonDirectory, propertyConfiguration.RootDirectory, filesCollection, directorySearchFilter);
|
||||||
return (count, results);
|
return (count, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ public interface IContainer
|
|||||||
static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory) =>
|
static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory) =>
|
||||||
Container.GetContainers(propertyConfiguration, aPropertySingletonDirectory);
|
Container.GetContainers(propertyConfiguration, aPropertySingletonDirectory);
|
||||||
|
|
||||||
(int, Models.Container[]) TestStatic_GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, List<string[]> filesCollection) =>
|
(int, Models.Container[]) TestStatic_GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, List<string[]> filesCollection) =>
|
||||||
GetContainers(propertyConfiguration, aPropertySingletonDirectory, filesCollection);
|
GetContainers(propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, filesCollection);
|
||||||
static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, List<string[]> filesCollection) =>
|
static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, List<string[]> filesCollection) =>
|
||||||
Container.GetContainers(propertyConfiguration, aPropertySingletonDirectory, filesCollection);
|
Container.GetContainers(propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, filesCollection);
|
||||||
|
|
||||||
List<int> TestStatic_GetFilteredDistinctIds(Properties.IPropertyConfiguration propertyConfiguration, Models.Container[] containers) =>
|
List<int> TestStatic_GetFilteredDistinctIds(Properties.IPropertyConfiguration propertyConfiguration, Models.Container[] containers) =>
|
||||||
GetFilteredDistinctIds(propertyConfiguration, containers);
|
GetFilteredDistinctIds(propertyConfiguration, containers);
|
||||||
|
@ -69,19 +69,19 @@ public interface IDirectory
|
|||||||
static void MoveFiles(List<string> files, string find, string replace) =>
|
static void MoveFiles(List<string> files, string find, string replace) =>
|
||||||
XDirectory.MoveFiles(files, find, replace);
|
XDirectory.MoveFiles(files, find, replace);
|
||||||
|
|
||||||
(string[], List<(Models.FileHolder, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
(string[], List<(Models.FileHolder, string?, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
||||||
GetToDoCollection(propertyConfiguration, filesCollection, directories, tick);
|
GetToDoCollection(propertyConfiguration, filesCollection, directories, tick);
|
||||||
static (string[], List<(Models.FileHolder, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
static (string[], List<(Models.FileHolder, string?, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
||||||
XDirectory.GetToDoCollection(propertyConfiguration, copyDuplicates: false, ifCanUseId: true, filesCollection, directories, tick);
|
XDirectory.GetToDoCollection(propertyConfiguration, copyDuplicates: false, ifCanUseId: true, filesCollection, directories, tick);
|
||||||
|
|
||||||
(string[], List<(Models.FileHolder, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
(string[], List<(Models.FileHolder, string?, string)>) TestStatic_GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
||||||
GetToDoCollection(propertyConfiguration, copyDuplicates, ifCanUseId, filesCollection, directories, tick);
|
GetToDoCollection(propertyConfiguration, copyDuplicates, ifCanUseId, filesCollection, directories, tick);
|
||||||
static (string[], List<(Models.FileHolder, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
static (string[], List<(Models.FileHolder, string?, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, List<string[]> filesCollection, string[] directories, Action? tick) =>
|
||||||
XDirectory.GetToDoCollection(propertyConfiguration, copyDuplicates, ifCanUseId, filesCollection, directories, tick);
|
XDirectory.GetToDoCollection(propertyConfiguration, copyDuplicates, ifCanUseId, filesCollection, directories, tick);
|
||||||
|
|
||||||
List<string> TestStatic_CopyOrMove(List<(Models.FileHolder, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
List<string> TestStatic_CopyOrMove(List<(Models.FileHolder, string?, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
||||||
CopyOrMove(toDoCollection, move, moveBack, tick);
|
CopyOrMove(toDoCollection, move, moveBack, tick);
|
||||||
static List<string> CopyOrMove(List<(Models.FileHolder, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
static List<string> CopyOrMove(List<(Models.FileHolder, string?, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
||||||
XDirectory.CopyOrMove(toDoCollection, move, moveBack, tick);
|
XDirectory.CopyOrMove(toDoCollection, move, moveBack, tick);
|
||||||
|
|
||||||
(bool, int?) TestStatic_GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
(bool, int?) TestStatic_GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
||||||
|
@ -338,9 +338,9 @@ internal abstract partial class XDirectory
|
|||||||
return (from l in results orderby l.FileHolder.CreationTime, l.FileHolder.FullName.Length descending select l).ToArray();
|
return (from l in results orderby l.FileHolder.CreationTime, l.FileHolder.FullName.Length descending select l).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static (string[], List<(Models.FileHolder, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, List<string[]> filesCollection, string[] directories, Action? tick)
|
internal static (string[], List<(Models.FileHolder, string?, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, List<string[]> filesCollection, string[] directories, Action? tick)
|
||||||
{
|
{
|
||||||
List<(Models.FileHolder, string)> results = new();
|
List<(Models.FileHolder, string?, string)> results = new();
|
||||||
string paddedId;
|
string paddedId;
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string directory;
|
string directory;
|
||||||
@ -350,7 +350,10 @@ internal abstract partial class XDirectory
|
|||||||
bool wrapped = false;
|
bool wrapped = false;
|
||||||
string directoryName;
|
string directoryName;
|
||||||
bool paddedCheck = false;
|
bool paddedCheck = false;
|
||||||
|
string fileDirectoryName;
|
||||||
SortedRecord sortedRecord;
|
SortedRecord sortedRecord;
|
||||||
|
string? alternateCheckFile;
|
||||||
|
string? alternateDirectory;
|
||||||
Models.FileHolder fileHolder;
|
Models.FileHolder fileHolder;
|
||||||
List<int> distinctIds = new();
|
List<int> distinctIds = new();
|
||||||
List<string> distinct = new();
|
List<string> distinct = new();
|
||||||
@ -358,6 +361,7 @@ internal abstract partial class XDirectory
|
|||||||
List<string> distinctDirectories = new();
|
List<string> distinctDirectories = new();
|
||||||
int intMinValueLength = int.MinValue.ToString().Length;
|
int intMinValueLength = int.MinValue.ToString().Length;
|
||||||
SortedRecord[] sortedRecords = GetSortedRecords(filesCollection);
|
SortedRecord[] sortedRecords = GetSortedRecords(filesCollection);
|
||||||
|
string? alternateResultAllInOne = !propertyConfiguration.ResultAllInOne.Contains(' ') ? null : propertyConfiguration.ResultAllInOne.Replace(' ', '-');
|
||||||
for (int i = 0; i < sortedRecords.Length; i++)
|
for (int i = 0; i < sortedRecords.Length; i++)
|
||||||
{
|
{
|
||||||
tick?.Invoke();
|
tick?.Invoke();
|
||||||
@ -365,19 +369,24 @@ internal abstract partial class XDirectory
|
|||||||
fileHolder = sortedRecord.FileHolder;
|
fileHolder = sortedRecord.FileHolder;
|
||||||
if (fileHolder.Name.EndsWith("len") || fileHolder.ExtensionLowered == ".id" || fileHolder.ExtensionLowered == ".lsv" || fileHolder.DirectoryName is null)
|
if (fileHolder.Name.EndsWith("len") || fileHolder.ExtensionLowered == ".id" || fileHolder.ExtensionLowered == ".lsv" || fileHolder.DirectoryName is null)
|
||||||
continue;
|
continue;
|
||||||
(_, directoryIndex) = IPath.GetDirectoryNameAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, fileHolder.NameWithoutExtension);
|
(directoryName, directoryIndex) = IPath.GetDirectoryNameAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, fileHolder.NameWithoutExtension);
|
||||||
directoryName = Path.GetFileName(fileHolder.DirectoryName);
|
fileDirectoryName = Path.GetFileName(fileHolder.DirectoryName);
|
||||||
if (directoryName.Length < propertyConfiguration.ResultAllInOneSubdirectoryLength + 3 || !fileHolder.Name.StartsWith(directoryName))
|
if (fileDirectoryName.Length < propertyConfiguration.ResultAllInOneSubdirectoryLength + 3 || !fileHolder.Name.StartsWith(fileDirectoryName))
|
||||||
{
|
{
|
||||||
if (wrapped)
|
if (wrapped)
|
||||||
continue;
|
continue;
|
||||||
directory = directories[directoryIndex];
|
directory = directories[directoryIndex];
|
||||||
|
if (alternateResultAllInOne is null)
|
||||||
|
alternateDirectory = null;
|
||||||
|
else
|
||||||
|
alternateDirectory = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(directory)) ?? directory, alternateResultAllInOne, directoryName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!wrapped)
|
if (!wrapped)
|
||||||
wrapped = true;
|
wrapped = true;
|
||||||
directory = Path.Combine(directories[directoryIndex], directoryName);
|
alternateDirectory = null;
|
||||||
|
directory = Path.Combine(directories[directoryIndex], fileDirectoryName);
|
||||||
}
|
}
|
||||||
if (ifCanUseId && sortedRecord.NameWithoutExtensionIsIdFormat && sortedRecord.Id is not null && fileHolder.DirectoryName is not null)
|
if (ifCanUseId && sortedRecord.NameWithoutExtensionIsIdFormat && sortedRecord.Id is not null && fileHolder.DirectoryName is not null)
|
||||||
{
|
{
|
||||||
@ -401,6 +410,7 @@ internal abstract partial class XDirectory
|
|||||||
continue;
|
continue;
|
||||||
if (!copyDuplicates)
|
if (!copyDuplicates)
|
||||||
continue;
|
continue;
|
||||||
|
alternateDirectory = null;
|
||||||
for (int j = 1; j < int.MaxValue; j++)
|
for (int j = 1; j < int.MaxValue; j++)
|
||||||
{
|
{
|
||||||
fileInfo = new(checkFile);
|
fileInfo = new(checkFile);
|
||||||
@ -416,8 +426,9 @@ internal abstract partial class XDirectory
|
|||||||
}
|
}
|
||||||
if (distinct.Contains(checkFile))
|
if (distinct.Contains(checkFile))
|
||||||
continue;
|
continue;
|
||||||
|
alternateCheckFile = null;
|
||||||
distinct.Add(checkFile);
|
distinct.Add(checkFile);
|
||||||
results.Add(new(fileHolder, checkFile));
|
results.Add(new(fileHolder, alternateCheckFile, checkFile));
|
||||||
if (!distinctDirectories.Contains(directory))
|
if (!distinctDirectories.Contains(directory))
|
||||||
distinctDirectories.Add(directory);
|
distinctDirectories.Add(directory);
|
||||||
break;
|
break;
|
||||||
@ -427,7 +438,15 @@ internal abstract partial class XDirectory
|
|||||||
distinct.Add(checkFile);
|
distinct.Add(checkFile);
|
||||||
if (sortedRecord.Id is not null)
|
if (sortedRecord.Id is not null)
|
||||||
distinctIds.Add(sortedRecord.Id.Value);
|
distinctIds.Add(sortedRecord.Id.Value);
|
||||||
results.Add(new(fileHolder, checkFile));
|
if (string.IsNullOrEmpty(alternateDirectory))
|
||||||
|
alternateCheckFile = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alternateCheckFile = Path.Combine(alternateDirectory, $"{sortedRecord.Id}{fileHolder.ExtensionLowered}.tsv");
|
||||||
|
if (!distinctDirectories.Contains(alternateDirectory))
|
||||||
|
distinctDirectories.Add(alternateDirectory);
|
||||||
|
}
|
||||||
|
results.Add(new(fileHolder, alternateCheckFile, checkFile));
|
||||||
if (!distinctDirectories.Contains(directory))
|
if (!distinctDirectories.Contains(directory))
|
||||||
distinctDirectories.Add(directory);
|
distinctDirectories.Add(directory);
|
||||||
}
|
}
|
||||||
@ -436,13 +455,15 @@ internal abstract partial class XDirectory
|
|||||||
return (distinctDirectories.ToArray(), results);
|
return (distinctDirectories.ToArray(), results);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<string> CopyOrMove(List<(Models.FileHolder, string)> toDoCollection, bool move, bool moveBack, Action? tick)
|
internal static List<string> CopyOrMove(List<(Models.FileHolder, string?, string)> toDoCollection, bool move, bool moveBack, Action? tick)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
FileInfo fileInfo;
|
FileInfo fileInfo;
|
||||||
foreach ((Models.FileHolder fileHolder, string to) in toDoCollection)
|
foreach ((Models.FileHolder fileHolder, string? alternateFile, string to) in toDoCollection)
|
||||||
{
|
{
|
||||||
tick?.Invoke();
|
tick?.Invoke();
|
||||||
|
if (alternateFile is not null)
|
||||||
|
_ = XPath.WriteAllText(alternateFile, fileHolder.FullName, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
fileInfo = new(to);
|
fileInfo = new(to);
|
||||||
if (fileInfo.Exists)
|
if (fileInfo.Exists)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +141,7 @@ public class UnitTestResize
|
|||||||
Shared.Models.Property? property = null;
|
Shared.Models.Property? property = null;
|
||||||
const bool isValidImageFormatExtension = true;
|
const bool isValidImageFormatExtension = true;
|
||||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||||
|
string[] alternateFileLines = Array.Empty<string>();
|
||||||
List<KeyValuePair<string, string>> metadataCollection;
|
List<KeyValuePair<string, string>> metadataCollection;
|
||||||
int length = _PropertyConfiguration.RootDirectory.Length;
|
int length = _PropertyConfiguration.RootDirectory.Length;
|
||||||
string[] changesFrom = new string[] { nameof(A_Property) };
|
string[] changesFrom = new string[] { nameof(A_Property) };
|
||||||
@ -173,7 +174,7 @@ public class UnitTestResize
|
|||||||
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
||||||
resize.Update(cResultsFullGroupDirectory);
|
resize.Update(cResultsFullGroupDirectory);
|
||||||
blurHasher.Update(cResultsFullGroupDirectory);
|
blurHasher.Update(cResultsFullGroupDirectory);
|
||||||
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, alternateFileLines, false, false, false);
|
||||||
Assert.IsNotNull(item.ImageFileHolder);
|
Assert.IsNotNull(item.ImageFileHolder);
|
||||||
if (item.Property is null)
|
if (item.Property is null)
|
||||||
{
|
{
|
||||||
|
@ -216,6 +216,7 @@ public class UnitTestFace
|
|||||||
Shared.Models.Property? property = null;
|
Shared.Models.Property? property = null;
|
||||||
const bool isValidImageFormatExtension = true;
|
const bool isValidImageFormatExtension = true;
|
||||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||||
|
string[] alternateFileLines = Array.Empty<string>();
|
||||||
List<KeyValuePair<string, string>> metadataCollection;
|
List<KeyValuePair<string, string>> metadataCollection;
|
||||||
int length = _PropertyConfiguration.RootDirectory.Length;
|
int length = _PropertyConfiguration.RootDirectory.Length;
|
||||||
string[] changesFrom = new string[] { nameof(A_Property) };
|
string[] changesFrom = new string[] { nameof(A_Property) };
|
||||||
@ -248,7 +249,7 @@ public class UnitTestFace
|
|||||||
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
||||||
resize.Update(cResultsFullGroupDirectory);
|
resize.Update(cResultsFullGroupDirectory);
|
||||||
blurHasher.Update(cResultsFullGroupDirectory);
|
blurHasher.Update(cResultsFullGroupDirectory);
|
||||||
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, alternateFileLines, false, false, false);
|
||||||
Assert.IsNotNull(item.ImageFileHolder);
|
Assert.IsNotNull(item.ImageFileHolder);
|
||||||
if (item.Property is null)
|
if (item.Property is null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user