Mass push
This commit is contained in:
@ -313,12 +313,12 @@ public class C_Resize
|
||||
return results;
|
||||
}
|
||||
|
||||
public byte[] GetResizedBytes(string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> imageResizes)
|
||||
public byte[] GetResizedBytes(string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> imageResizeKeyValuePairs)
|
||||
{
|
||||
byte[] results;
|
||||
if (!imageResizes.ContainsKey(outputResolution))
|
||||
if (!imageResizeKeyValuePairs.ContainsKey(outputResolution))
|
||||
throw new Exception();
|
||||
int[] resize = imageResizes[outputResolution];
|
||||
int[] resize = imageResizeKeyValuePairs[outputResolution];
|
||||
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
|
||||
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
|
||||
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
|
||||
@ -327,34 +327,35 @@ public class C_Resize
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveResizedSubfile(Property.Models.Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, string original, Dictionary<string, int[]> imageResizes)
|
||||
public void SaveResizedSubfile(Property.Models.Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, string original, Dictionary<string, int[]> imageResizeKeyValuePairs)
|
||||
{
|
||||
if (mappingFromItem.ResizedFileHolder is null)
|
||||
throw new NullReferenceException(nameof(mappingFromItem.ResizedFileHolder));
|
||||
if (!imageResizes.ContainsKey(outputResolution))
|
||||
if (!imageResizeKeyValuePairs.ContainsKey(original))
|
||||
throw new Exception();
|
||||
if (!imageResizeKeyValuePairs.ContainsKey(outputResolution))
|
||||
throw new Exception();
|
||||
FileInfo fileInfo = new(mappingFromItem.ResizedFileHolder.FullName);
|
||||
if (!fileInfo.FullName.Contains(configuration.ResultAllInOne) && !fileInfo.Exists)
|
||||
{
|
||||
if (fileInfo.Directory?.Parent is null)
|
||||
throw new Exception();
|
||||
string parentCheck = Path.Combine(fileInfo.Directory.Parent.FullName, fileInfo.Name);
|
||||
if (File.Exists(parentCheck))
|
||||
{
|
||||
File.Move(parentCheck, fileInfo.FullName);
|
||||
item.SetResizedFileHolder(_FileNameExtension, Shared.Models.Stateless.Methods.IFileHolder.Refresh(mappingFromItem.ResizedFileHolder));
|
||||
fileInfo.Refresh();
|
||||
}
|
||||
}
|
||||
int[] resize = imageResizes[outputResolution];
|
||||
bool check = false;
|
||||
int[] resize = imageResizeKeyValuePairs[outputResolution];
|
||||
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
|
||||
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
|
||||
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
|
||||
int[] originalCollection = imageResizes[original];
|
||||
int[] originalCollection = imageResizeKeyValuePairs[original];
|
||||
string[] changesFrom = new string[] { nameof(Property.Models.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;
|
||||
else if (!fileInfo.Exists)
|
||||
check = true;
|
||||
if (outputResolutionWidth == originalCollection[_OutputResolutionWidthIndex] && outputResolutionHeight == originalCollection[_OutputResolutionHeightIndex] && outputResolutionOrientation == originalCollection[_OutputResolutionOrientationIndex])
|
||||
{
|
||||
if (!fileInfo.Exists)
|
||||
if (!check && dateTimes.Any() && dateTimes.Max() > fileInfo.CreationTime.AddDays(1))
|
||||
check = true;
|
||||
if (check)
|
||||
{
|
||||
if (fileInfo.Exists)
|
||||
File.Delete(fileInfo.FullName);
|
||||
File.Copy(mappingFromItem.ImageFileHolder.FullName, fileInfo.FullName);
|
||||
item.SetResizedFileHolder(_FileNameExtension, Shared.Models.Stateless.Methods.IFileHolder.Refresh(mappingFromItem.ResizedFileHolder));
|
||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now));
|
||||
@ -362,14 +363,7 @@ public class C_Resize
|
||||
}
|
||||
else
|
||||
{
|
||||
bool check = false;
|
||||
string[] changesFrom = new string[] { nameof(Property.Models.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;
|
||||
else if (!fileInfo.Exists)
|
||||
check = true;
|
||||
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
if (!check && dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
check = true;
|
||||
if (check)
|
||||
{
|
||||
@ -461,17 +455,6 @@ public class C_Resize
|
||||
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);
|
||||
if (!fileInfo.FullName.Contains(configuration.ResultAllInOne) && !fileInfo.Exists)
|
||||
{
|
||||
if (fileInfo.Directory?.Parent is null)
|
||||
throw new Exception();
|
||||
string parentCheck = Path.Combine(fileInfo.Directory.Parent.FullName, fileInfo.Name);
|
||||
if (File.Exists(parentCheck))
|
||||
{
|
||||
File.Move(parentCheck, fileInfo.FullName);
|
||||
fileInfo.Refresh();
|
||||
}
|
||||
}
|
||||
if (_ForceResizeLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
@ -535,4 +518,13 @@ public class C_Resize
|
||||
return results;
|
||||
}
|
||||
|
||||
public static byte[] GetBytes(string value)
|
||||
{
|
||||
byte[] results = new byte[value.Length + 1];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
results[i] = (byte)value[i];
|
||||
results[value.Length] = 0x00;
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user