Get Segments
This commit is contained in:
@ -6,7 +6,7 @@ public interface ILocation
|
||||
string TestStatic_GetRightPadded(int locationDigits, string value) =>
|
||||
GetRightPadded(locationDigits, value);
|
||||
static string GetRightPadded(int locationDigits, string value) =>
|
||||
value.PadRight(locationDigits, '0');
|
||||
value.Length == locationDigits ? value : value.Length > locationDigits ? value[..locationDigits] : value.PadRight(locationDigits, '0');
|
||||
|
||||
string TestStatic_GetRightPadded(int locationDigits, int value) =>
|
||||
GetRightPadded(locationDigits, value);
|
||||
|
@ -6,10 +6,10 @@ public interface IMapping
|
||||
static string GetDeterministicHashCodeKey(int id, int normalizedPixelPercentage)
|
||||
=> $"{id}.{normalizedPixelPercentage}";
|
||||
|
||||
(string?, string?, string?, bool?) TestStatic_GetSegments(string facesFileNameExtension, string fileName)
|
||||
=> GetSegments(facesFileNameExtension, fileName);
|
||||
static (string?, string?, string?, bool?) GetSegments(string facesFileNameExtension, string fileName)
|
||||
=> Mapping.GetSegments(facesFileNameExtension, fileName);
|
||||
(string?, string?, string?, bool?) TestStatic_GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||
=> GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||
static (string?, string?, string?, bool?) GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||
=> Mapping.GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||
|
||||
(int?, int?, List<Models.Face>?) TestStatic_GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, string file) =>
|
||||
GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, file);
|
||||
|
@ -18,7 +18,7 @@ internal abstract class Mapping
|
||||
int? id;
|
||||
List<Models.Face>? faces;
|
||||
int? normalizedPixelPercentage;
|
||||
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = GetSegments(facesFileNameExtension, fileName);
|
||||
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
|
||||
{
|
||||
id = null;
|
||||
@ -45,7 +45,7 @@ internal abstract class Mapping
|
||||
return new(id, normalizedPixelPercentage, faces);
|
||||
}
|
||||
|
||||
internal static (string?, string?, string?, bool?) GetSegments(string facesFileNameExtension, string fileName)
|
||||
internal static (string?, string?, string?, bool?) GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||
{
|
||||
string[] segments = fileName.Split('.');
|
||||
string? id;
|
||||
@ -63,8 +63,8 @@ internal abstract class Mapping
|
||||
{
|
||||
id = segments[0];
|
||||
extensionLowered = $".{segments[2]}";
|
||||
normalizedPixelPercentage = segments[1];
|
||||
needsFacesFileNameExtension = segments.Length == 3;
|
||||
normalizedPixelPercentage = ILocation.GetRightPadded(locationDigits, segments[1]);
|
||||
}
|
||||
return new(id, normalizedPixelPercentage, extensionLowered, needsFacesFileNameExtension);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ internal abstract class PersonContainer
|
||||
if (personDisplayDirectoryAllFile.EndsWith(".lnk"))
|
||||
continue;
|
||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is not null && normalizedPixelPercentage is not null)
|
||||
if (id is not null && normalizedPixelPercentage is not null && !personDisplayDirectoryAllFile.EndsWith(".json"))
|
||||
continue;
|
||||
checkDirectory = Path.GetDirectoryName(personDisplayDirectoryAllFile);
|
||||
if (string.IsNullOrEmpty(checkDirectory))
|
||||
|
Reference in New Issue
Block a user