Keyword to work with Amazon
This commit is contained in:
@ -48,6 +48,21 @@ public record FileHolder(DateTime? CreationTime,
|
||||
return result;
|
||||
}
|
||||
|
||||
public static FileHolder Get(FilePath filePath)
|
||||
{
|
||||
FileHolder result;
|
||||
result = new(new(filePath.CreationTicks),
|
||||
filePath.DirectoryName,
|
||||
true,
|
||||
filePath.ExtensionLowered,
|
||||
filePath.FullName,
|
||||
new(filePath.LastWriteTicks),
|
||||
filePath.Length,
|
||||
filePath.Name,
|
||||
Path.GetFileNameWithoutExtension(filePath.FullName));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
|
@ -10,6 +10,7 @@ public record FilePath(long CreationTicks,
|
||||
string FileNameFirstSegment,
|
||||
string FullName,
|
||||
int? Id,
|
||||
bool? IsIgnore,
|
||||
bool IsIntelligentIdFormat,
|
||||
long LastWriteTicks,
|
||||
long Length,
|
||||
@ -38,14 +39,15 @@ public record FilePath(long CreationTicks,
|
||||
string fileNameFirstSegment = fileHolder.Name.Split('.')[0];
|
||||
int sortOrderOnlyLengthIndex = propertyConfiguration.Offset.ToString().Length;
|
||||
string fileDirectoryName = fileHolder.DirectoryName ?? throw new NullReferenceException();
|
||||
bool fileNameFirstSegmentIsIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment);
|
||||
bool fileNameFirstSegmentIsPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(propertyConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
||||
bool fileNameFirstSegmentIsIdFormat = !fileNameFirstSegmentIsPaddedIntelligentIdFormat && !fileNameFirstSegmentIsIntelligentIdFormat && IId.NameWithoutExtensionIsIdFormat(propertyConfiguration, fileHolder);
|
||||
if (!fileNameFirstSegmentIsIdFormat && !fileNameFirstSegmentIsIntelligentIdFormat && !fileNameFirstSegmentIsPaddedIntelligentIdFormat)
|
||||
bool isIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment);
|
||||
bool isPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(propertyConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
||||
bool fileNameFirstSegmentIsIdFormat = !isPaddedIntelligentIdFormat && !isIntelligentIdFormat && IId.NameWithoutExtensionIsIdFormat(propertyConfiguration, fileHolder);
|
||||
bool? isIgnore = !isIntelligentIdFormat && !isPaddedIntelligentIdFormat ? null : fileNameFirstSegment[^1] is '2' or '8';
|
||||
if (!fileNameFirstSegmentIsIdFormat && !isIntelligentIdFormat && !isPaddedIntelligentIdFormat)
|
||||
(id, sortOder) = (null, null);
|
||||
else if (fileNameFirstSegmentIsIntelligentIdFormat)
|
||||
else if (isIntelligentIdFormat)
|
||||
(id, sortOder) = (IId.GetId(propertyConfiguration, fileNameFirstSegment), null);
|
||||
else if (fileNameFirstSegmentIsPaddedIntelligentIdFormat)
|
||||
else if (isPaddedIntelligentIdFormat)
|
||||
{
|
||||
if (!int.TryParse(fileNameFirstSegment[..sortOrderOnlyLengthIndex], out int absoluteValueOfSortOrder))
|
||||
(id, sortOder) = (null, null);
|
||||
@ -68,7 +70,8 @@ public record FilePath(long CreationTicks,
|
||||
fileNameFirstSegment,
|
||||
fileHolder.FullName,
|
||||
id,
|
||||
fileNameFirstSegmentIsIntelligentIdFormat,
|
||||
isIgnore,
|
||||
isIntelligentIdFormat,
|
||||
fileHolder.LastWriteTime.Value.Ticks,
|
||||
fileHolder.Length.Value,
|
||||
fileHolder.Name,
|
||||
|
@ -9,7 +9,6 @@ public class Item : Properties.IItem
|
||||
protected List<Face> _Faces;
|
||||
protected readonly bool? _FileSizeChanged;
|
||||
protected readonly FilePath _FilePath;
|
||||
protected readonly FileHolder _ImageFileHolder;
|
||||
protected bool? _IsNotUniqueAndNeedsReview;
|
||||
protected bool _IsUniqueFileName;
|
||||
protected bool _IsValidImageFormatExtension;
|
||||
@ -22,7 +21,6 @@ public class Item : Properties.IItem
|
||||
public List<Face> Faces => _Faces;
|
||||
public bool? FileSizeChanged => _FileSizeChanged;
|
||||
public FilePath FilePath => _FilePath;
|
||||
public FileHolder ImageFileHolder => _ImageFileHolder;
|
||||
public bool? IsNotUniqueAndNeedsReview => _IsNotUniqueAndNeedsReview;
|
||||
public bool IsUniqueFileName => _IsUniqueFileName;
|
||||
public bool IsValidImageFormatExtension => _IsValidImageFormatExtension;
|
||||
@ -34,12 +32,11 @@ public class Item : Properties.IItem
|
||||
public FileHolder SourceDirectoryFileHolder => _SourceDirectoryFileHolder;
|
||||
|
||||
[JsonConstructor]
|
||||
public Item(List<Face> faces, FilePath filePath, bool? fileSizeChanged, FileHolder imageFileHolder, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, bool? lastWriteTimeChanged, bool? moved, Property? property, string relativePath, FileHolder? resizedFileHolder, FileHolder sourceDirectoryFileHolder)
|
||||
public Item(List<Face> faces, FilePath filePath, bool? fileSizeChanged, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, bool? lastWriteTimeChanged, bool? moved, Property? property, string relativePath, FileHolder? resizedFileHolder, FileHolder sourceDirectoryFileHolder)
|
||||
{
|
||||
_Faces = faces;
|
||||
_FilePath = filePath;
|
||||
_FileSizeChanged = fileSizeChanged;
|
||||
_ImageFileHolder = imageFileHolder;
|
||||
_IsNotUniqueAndNeedsReview = isNotUniqueAndNeedsReview;
|
||||
_IsUniqueFileName = isUniqueFileName;
|
||||
_IsValidImageFormatExtension = isValidImageFormatExtension;
|
||||
@ -51,17 +48,17 @@ public class Item : Properties.IItem
|
||||
_SourceDirectoryFileHolder = sourceDirectoryFileHolder;
|
||||
}
|
||||
|
||||
public Item(FilePath filePath, FileHolder sourceDirectoryFileHolder, string relativePath, FileHolder imageFileInfo, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, Property? property, bool? abandoned, bool? fileSizeChanged, bool? lastWriteTimeChanged) :
|
||||
this([], filePath, fileSizeChanged, imageFileInfo, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, lastWriteTimeChanged, null, property, relativePath, null, sourceDirectoryFileHolder)
|
||||
public Item(FilePath filePath, FileHolder sourceDirectoryFileHolder, string relativePath, bool? isNotUniqueAndNeedsReview, bool isUniqueFileName, bool isValidImageFormatExtension, Property? property, bool? abandoned, bool? fileSizeChanged, bool? lastWriteTimeChanged) :
|
||||
this([], filePath, fileSizeChanged, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, lastWriteTimeChanged, null, property, relativePath, null, sourceDirectoryFileHolder)
|
||||
{
|
||||
if (relativePath.EndsWith(".json"))
|
||||
throw new ArgumentException("Can not be a *.json file!");
|
||||
if (imageFileInfo is not null && imageFileInfo.ExtensionLowered is ".json")
|
||||
if (filePath is not null && filePath.ExtensionLowered is ".json")
|
||||
throw new ArgumentException("Can not be a *.json file!");
|
||||
}
|
||||
|
||||
public Item(FilePath filePath, FileHolder sourceDirectoryFileHolder, string relativePath, bool isValidImageFormatExtension) :
|
||||
this(filePath, sourceDirectoryFileHolder, relativePath, sourceDirectoryFileHolder, null, false, isValidImageFormatExtension, null, null, null, null)
|
||||
this(filePath, sourceDirectoryFileHolder, relativePath, null, false, isValidImageFormatExtension, null, null, null, null)
|
||||
{ }
|
||||
|
||||
public override string ToString()
|
||||
|
@ -7,7 +7,7 @@ public record MappingFromItem(DateTime[] ContainerDateTimes,
|
||||
DateTime? DateTimeDigitized,
|
||||
DateTime? DateTimeOriginal,
|
||||
int Id,
|
||||
FileHolder ImageFileHolder,
|
||||
FilePath FilePath,
|
||||
bool? IsWrongYear,
|
||||
string[] Keywords,
|
||||
DateTime MinimumDateTime,
|
||||
@ -34,8 +34,8 @@ public record MappingFromItem(DateTime[] ContainerDateTimes,
|
||||
throw new NotSupportedException();
|
||||
List<DateTime> dateTimes = item.Property.GetDateTimes();
|
||||
DateTime minimumDateTime = Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||
(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);
|
||||
(bool? isWrongYear, _) = Stateless.Methods.IProperty.IsWrongYear(item.FilePath, item.Property.DateTimeOriginal, dateTimes);
|
||||
result = new(containerDateTimes, item.Property.DateTimeDigitized, item.Property.DateTimeOriginal, item.Property.Id.Value, item.FilePath, isWrongYear, item.Property.Keywords ?? [], minimumDateTime, item.Property.Model, item.RelativePath, resizedFileHolder);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,6 @@ namespace View_by_Distance.Shared.Models.Methods;
|
||||
public interface IMetadata<T>
|
||||
{
|
||||
|
||||
(DateTime?, DateTime?[]) GetDateTimes(FileHolder fileHolder, IReadOnlyList<T> directories);
|
||||
(DateTime?, DateTime?[]) GetDateTimes(FilePath filePath, IReadOnlyList<T> directories);
|
||||
|
||||
}
|
@ -6,7 +6,6 @@ public interface IItem
|
||||
public bool? FileSizeChanged { get; }
|
||||
public List<Face> Faces { get; }
|
||||
public FilePath FilePath { get; }
|
||||
public FileHolder ImageFileHolder { get; }
|
||||
public bool? IsNotUniqueAndNeedsReview { get; }
|
||||
public bool IsUniqueFileName { get; }
|
||||
public bool IsValidImageFormatExtension { get; }
|
||||
|
@ -11,17 +11,9 @@ internal abstract class Container
|
||||
internal static DateTime[] GetContainerDateTimes(IEnumerable<Models.Item> items)
|
||||
{
|
||||
DateTime[] results;
|
||||
DateTime? containerMinimumDateTime;
|
||||
DateTime? containerMaximumDateTime;
|
||||
containerMinimumDateTime = (from l in items select l.ImageFileHolder.LastWriteTime).Min();
|
||||
if (containerMinimumDateTime is null)
|
||||
containerMaximumDateTime = null;
|
||||
else
|
||||
containerMaximumDateTime = (from l in items select l.ImageFileHolder.LastWriteTime).Max();
|
||||
if (containerMinimumDateTime is null || containerMaximumDateTime is null)
|
||||
results = [];
|
||||
else
|
||||
results = [containerMinimumDateTime.Value, containerMaximumDateTime.Value];
|
||||
long containerMinimumTicks = (from l in items select l.FilePath.LastWriteTicks).Min();
|
||||
long containerMaximumTicks = (from l in items select l.FilePath.LastWriteTicks).Max();
|
||||
results = [new(containerMinimumTicks), new(containerMaximumTicks)];
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -30,9 +22,8 @@ internal abstract class Container
|
||||
List<Models.Item> results = [];
|
||||
foreach (Models.Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is not null
|
||||
&& item.IsValidImageFormatExtension
|
||||
&& !propertyConfiguration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered))
|
||||
if (item.IsValidImageFormatExtension
|
||||
&& !propertyConfiguration.IgnoreExtensions.Contains(item.FilePath.ExtensionLowered))
|
||||
results.Add(item);
|
||||
}
|
||||
return results.ToArray();
|
||||
@ -87,12 +78,23 @@ internal abstract class Container
|
||||
FilePath filePath = FilePath.Get(propertyConfiguration, imageFileInfo, index: null);
|
||||
bool? fileSizeChanged = property is not null ? property.FileSize != filePath.Length : null;
|
||||
bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(filePath.ExtensionLowered);
|
||||
if (property is not null && property.Keywords is not null && !IId.IsIgnore(filePath) && propertyConfiguration.IgnoreRulesKeyWords.Any(l => property.Keywords.Contains(l)))
|
||||
if (property is not null && property.Keywords is not null)
|
||||
{
|
||||
if (filePath.DirectoryName.Contains("Results") && filePath.DirectoryName.Contains("Resize"))
|
||||
File.Delete(filePath.FullName);
|
||||
else
|
||||
throw new NotSupportedException($"Rename File! <{filePath.FileNameFirstSegment}>");
|
||||
if (filePath.IsIgnore is null)
|
||||
throw new NullReferenceException();
|
||||
bool shouldIgnore = propertyConfiguration.IgnoreRulesKeyWords.Any(l => property.Keywords.Contains(l));
|
||||
if (shouldIgnore)
|
||||
{
|
||||
if (shouldIgnore)
|
||||
{ }
|
||||
}
|
||||
if (filePath.IsIgnore.Value != shouldIgnore)
|
||||
{
|
||||
if (filePath.DirectoryName.Contains("Results") && filePath.DirectoryName.Contains("Resize"))
|
||||
File.Delete(filePath.FullName);
|
||||
else
|
||||
throw new NotSupportedException($"Rename File! <{filePath.FileNameFirstSegment}>");
|
||||
}
|
||||
}
|
||||
string relativePath = IPath.GetRelativePath(filePair.Path, rootDirectoryLength, forceExtensionToLower: true);
|
||||
bool? lastWriteTimeChanged = property is not null ? propertyConfiguration.PropertiesChangedForProperty || property.LastWriteTime.Ticks != filePath.LastWriteTicks : null;
|
||||
@ -111,17 +113,19 @@ internal abstract class Container
|
||||
File.SetCreationTime(sourceDirectoryFileHolder.FullName, new(filePath.LastWriteTicks));
|
||||
File.SetLastWriteTime(sourceDirectoryFileHolder.FullName, sourceDirectoryFileHolder.LastWriteTime.Value);
|
||||
}
|
||||
Models.Item item = new(filePath, sourceDirectoryFileHolder, relativePath, imageFileInfo, filePair.IsNotUniqueAndNeedsReview, filePair.IsUnique, isValidImageFormatExtension, property, abandoned, fileSizeChanged, lastWriteTimeChanged);
|
||||
Models.Item item = new(filePath, sourceDirectoryFileHolder, relativePath, filePair.IsNotUniqueAndNeedsReview, filePair.IsUnique, isValidImageFormatExtension, property, abandoned, fileSizeChanged, lastWriteTimeChanged);
|
||||
lock (results)
|
||||
results.Add(new(filePair.IsUnique, filePair.Collection, filePath, item));
|
||||
}
|
||||
|
||||
private static List<FilePair> GetFilePairs(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, string extension, List<Models.FilePair> filePairs)
|
||||
private static List<FilePair> GetFilePairs(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, ReadOnlyCollection<string[]> filesCollection, string directorySearchFilter)
|
||||
{
|
||||
List<FilePair> results = [];
|
||||
const string extension = ".json";
|
||||
int maxDegreeOfParallelism = Environment.ProcessorCount;
|
||||
int filesCollectionDirectoryLength = filesCollectionDirectory.Length;
|
||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
|
||||
List<Models.FilePair> filePairs = GetFilePairs(propertyConfiguration, directorySearchFilter, extension, aPropertySingletonDirectory, filesCollection);
|
||||
_ = Parallel.For(0, filePairs.Count, parallelOptions, (i, state) => ParallelFor(propertyConfiguration, aPropertySingletonDirectory, extension, filesCollectionDirectoryLength, filePairs[i], results));
|
||||
return results;
|
||||
}
|
||||
@ -133,7 +137,6 @@ internal abstract class Container
|
||||
List<Models.Item>? items;
|
||||
Models.Container container;
|
||||
List<string> directories = [];
|
||||
const string extension = ".json";
|
||||
Dictionary<string, List<Models.Item>> directoryToItems = [];
|
||||
foreach (string[] files in filesCollection)
|
||||
{
|
||||
@ -151,9 +154,8 @@ internal abstract class Container
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
List<Models.FilePair> filePairs = GetFilePairs(propertyConfiguration, directorySearchFilter, extension, aPropertySingletonDirectory, filesCollection);
|
||||
List<FilePair> collection = GetFilePairs(propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, extension, filePairs);
|
||||
foreach (FilePair filePair in collection)
|
||||
List<FilePair> filePairs = GetFilePairs(propertyConfiguration, aPropertySingletonDirectory, filesCollectionDirectory, filesCollection, directorySearchFilter);
|
||||
foreach (FilePair filePair in filePairs)
|
||||
{
|
||||
if (!directoryToItems.TryGetValue(filePair.FilePath.DirectoryName, out items))
|
||||
{
|
||||
@ -170,7 +172,7 @@ internal abstract class Container
|
||||
container = new(keyValuePair.Key, keyValuePair.Value);
|
||||
results.Add(container);
|
||||
}
|
||||
return (collection.Count, results.ToArray());
|
||||
return (filePairs.Count, results.ToArray());
|
||||
}
|
||||
|
||||
internal static (int, Models.Container[]) GetContainers(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string filesCollectionDirectory, ReadOnlyCollection<string[]> filesCollection)
|
||||
|
@ -3,9 +3,9 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
public interface IId
|
||||
{ // ...
|
||||
|
||||
string TestStatic_GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool ignore) =>
|
||||
string TestStatic_GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore) =>
|
||||
GetIntelligentId(propertyConfiguration, id, ignore);
|
||||
static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool ignore) =>
|
||||
static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore) =>
|
||||
Id.GetIntelligentId(propertyConfiguration, id, ignore);
|
||||
|
||||
int TestStatic_GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
|
||||
@ -13,15 +13,10 @@ public interface IId
|
||||
static int GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
|
||||
Id.GetId(propertyConfiguration, intelligentId);
|
||||
|
||||
string TestStatic_GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, int? index) =>
|
||||
GetPaddedId(propertyConfiguration, id, index);
|
||||
static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, int? index) =>
|
||||
Id.GetPaddedId(propertyConfiguration, id, index);
|
||||
|
||||
bool TestStatic_IsIgnore(FilePath filePath) =>
|
||||
IsIgnore(filePath);
|
||||
static bool IsIgnore(FilePath filePath) =>
|
||||
filePath.FileNameFirstSegment[^1] is '2' or '8';
|
||||
string TestStatic_GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index) =>
|
||||
GetPaddedId(propertyConfiguration, id, ignore, index);
|
||||
static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index) =>
|
||||
Id.GetPaddedId(propertyConfiguration, id, ignore, index);
|
||||
|
||||
string TestStatic_GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
|
||||
GetIgnoreFullPath(filePath, fileHolder);
|
||||
|
@ -33,10 +33,10 @@ public interface IProperty
|
||||
static (bool?, string[]) IsWrongYear(string[] segments, string year) =>
|
||||
Property.IsWrongYear(segments, year);
|
||||
|
||||
(bool?, string[]) TestStatic_IsWrongYear(Models.FileHolder fileHolder, DateTime? dateTimeOriginal, List<DateTime> dateTimes) =>
|
||||
IsWrongYear(fileHolder, dateTimeOriginal, dateTimes);
|
||||
static (bool?, string[]) IsWrongYear(Models.FileHolder fileHolder, DateTime? dateTimeOriginal, List<DateTime> dateTimes) =>
|
||||
Property.IsWrongYear(fileHolder, dateTimeOriginal, dateTimes);
|
||||
(bool?, string[]) TestStatic_IsWrongYear(FilePath filePath, DateTime? dateTimeOriginal, List<DateTime> dateTimes) =>
|
||||
IsWrongYear(filePath, dateTimeOriginal, dateTimes);
|
||||
static (bool?, string[]) IsWrongYear(FilePath filePath, DateTime? dateTimeOriginal, List<DateTime> dateTimes) =>
|
||||
Property.IsWrongYear(filePath, dateTimeOriginal, dateTimes);
|
||||
|
||||
List<DateTime> TestStatic_GetDateTimes(Models.Property property) =>
|
||||
GetDateTimes(property);
|
||||
|
@ -35,7 +35,7 @@ internal abstract class Id
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool ignore)
|
||||
internal static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool? ignore)
|
||||
{
|
||||
string result;
|
||||
StringBuilder stringBuilder = new();
|
||||
@ -46,12 +46,12 @@ internal abstract class Id
|
||||
List<char> resultAllInOneSubdirectoryChars = [];
|
||||
if (id > -1)
|
||||
{
|
||||
key = ignore ? 8 : 9;
|
||||
key = ignore is not null && ignore.Value ? 8 : 9;
|
||||
value = id.ToString().PadLeft(propertyConfiguration.IntMinValueLength, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
key = ignore ? 2 : 1;
|
||||
key = ignore is not null && ignore.Value ? 2 : 1;
|
||||
value = id.ToString()[1..].PadLeft(propertyConfiguration.IntMinValueLength, '0');
|
||||
}
|
||||
for (int i = value.Length - propertyConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--)
|
||||
@ -62,14 +62,14 @@ internal abstract class Id
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, int? index)
|
||||
internal static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, bool? ignore, int? index)
|
||||
{
|
||||
string result;
|
||||
if (propertyConfiguration.Offset < 0)
|
||||
result = Guid.NewGuid().ToString();
|
||||
else
|
||||
{
|
||||
string intelligentId = GetIntelligentId(propertyConfiguration, id, ignore: false);
|
||||
string intelligentId = GetIntelligentId(propertyConfiguration, id, ignore);
|
||||
int check = GetId(propertyConfiguration, intelligentId);
|
||||
if (check != id)
|
||||
throw new NotSupportedException();
|
||||
|
@ -10,11 +10,11 @@ internal abstract class Item
|
||||
foreach (Models.Item item in itemsA)
|
||||
{
|
||||
results.Add(item);
|
||||
collection.Add(item.ImageFileHolder.FullName);
|
||||
collection.Add(item.FilePath.FullName);
|
||||
}
|
||||
foreach (Models.Item item in itemsB)
|
||||
{
|
||||
if (collection.Contains(item.ImageFileHolder.FullName))
|
||||
if (collection.Contains(item.FilePath.FullName))
|
||||
continue;
|
||||
results.Add(item);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ internal abstract class Property
|
||||
return new(result, results);
|
||||
}
|
||||
|
||||
internal static (bool?, string[]) IsWrongYear(Models.FileHolder fileHolder, DateTime? dateTimeOriginal, List<DateTime> dateTimes)
|
||||
internal static (bool?, string[]) IsWrongYear(FilePath filePath, DateTime? dateTimeOriginal, List<DateTime> dateTimes)
|
||||
{
|
||||
string[] results = [];
|
||||
bool? result = null;
|
||||
@ -55,8 +55,8 @@ internal abstract class Property
|
||||
string directoryName;
|
||||
string[] directorySegments;
|
||||
List<DateTime> collection = [];
|
||||
string? check = Path.GetFullPath(fileHolder.FullName);
|
||||
string? pathRoot = Path.GetPathRoot(fileHolder.FullName);
|
||||
string? check = Path.GetFullPath(filePath.FullName);
|
||||
string? pathRoot = Path.GetPathRoot(filePath.FullName);
|
||||
if (string.IsNullOrEmpty(pathRoot))
|
||||
throw new Exception();
|
||||
if (dateTimeOriginal is not null)
|
||||
|
@ -291,7 +291,6 @@ internal abstract partial class XDirectory
|
||||
FileInfo fileInfo;
|
||||
FilePath filePath;
|
||||
int directoryIndex;
|
||||
bool ignore = false;
|
||||
string paddedIdFile;
|
||||
bool wrapped = false;
|
||||
string intelligentId;
|
||||
@ -324,7 +323,7 @@ internal abstract partial class XDirectory
|
||||
}
|
||||
if (ifCanUseId && filePath.IsIntelligentIdFormat && filePath.Id is not null && filePath.DirectoryName is not null)
|
||||
{
|
||||
paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, i);
|
||||
paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.IsIgnore, i);
|
||||
paddedIdFile = Path.Combine(filePath.DirectoryName, $"{paddedId}{filePath.ExtensionLowered}");
|
||||
if (!File.Exists(paddedIdFile))
|
||||
{
|
||||
@ -342,7 +341,7 @@ internal abstract partial class XDirectory
|
||||
{
|
||||
if (filePath.Id is null)
|
||||
throw new NullReferenceException(nameof(filePath.Id));
|
||||
intelligentId = IId.GetIntelligentId(propertyConfiguration, filePath.Id.Value, ignore);
|
||||
intelligentId = IId.GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.IsIgnore);
|
||||
checkFile = Path.Combine(directory, $"{intelligentId}{filePath.ExtensionLowered}");
|
||||
}
|
||||
if ((filePath.Id is not null && distinctIds.Contains(filePath.Id.Value)) || distinct.Contains(checkFile))
|
||||
@ -396,10 +395,9 @@ internal abstract partial class XDirectory
|
||||
fileInfo = new(to);
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
if (filePath.Length != fileInfo.Length || filePath.LastWriteTicks != fileInfo.LastWriteTime.Ticks)
|
||||
fileInfo.Delete();
|
||||
else
|
||||
if (filePath.Length == fileInfo.Length && filePath.LastWriteTicks == fileInfo.LastWriteTime.Ticks)
|
||||
continue;
|
||||
fileInfo.Delete();
|
||||
}
|
||||
results.Add(filePath.NameWithoutExtension);
|
||||
try
|
||||
|
Reference in New Issue
Block a user