Removed R from Container class

This commit is contained in:
2022-09-15 21:38:13 -07:00
parent 7390c13751
commit deff6f484c
18 changed files with 154 additions and 132 deletions

View File

@ -568,12 +568,11 @@ public class A_Property
}
}
private void ParallelWork(bool firstPass, List<Exception> exceptions, List<Tuple<string, DateTime>> sourceDirectoryChanges, int containersCount, Shared.Models.Container container, Item[] filteredItems, int totalSeconds)
private void ParallelWork(bool firstPass, List<Exception> exceptions, List<Tuple<string, DateTime>> sourceDirectoryChanges, Shared.Models.Container container, Item[] filteredItems, string message)
{
List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples = new();
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _MaxDegreeOfParallelism };
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
string message = $"{container.R:000}.{container.G} / {containersCount:000}) {filteredItems.Length:000} file(s) - {totalSeconds} total second(s) - {container.SourceDirectory}";
using ProgressBar progressBar = new(filteredItems.Length, message, options);
_ = Parallel.For(0, filteredItems.Length, parallelOptions, (i, state) =>
{
@ -619,15 +618,18 @@ public class A_Property
{
if (_Log is null)
throw new NullReferenceException(nameof(_Log));
string message;
int totalSeconds;
bool? anyFilesMoved;
Item[] filteredItems;
Shared.Models.Container container;
List<Exception> exceptions = new();
int containersCount = containers.Length;
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
string propertyRoot = IResult.GetResultsGroupDirectory(_Configuration, nameof(A_Property));
foreach (Shared.Models.Container container in containers)
for (int i = 0; i < containers.Length; i++)
{
container = containers[i];
if (!container.Items.Any())
continue;
sourceDirectoryChanges.Clear();
@ -637,9 +639,10 @@ public class A_Property
filteredItems = (from l in container.Items where l.ImageFileHolder is not null && !_Configuration.IgnoreExtensions.Contains(l.ImageFileHolder.ExtensionLowered) select l).ToArray();
if (!filteredItems.Any())
continue;
totalSeconds = (int)Math.Truncate(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
SetAngleBracketCollection(container.SourceDirectory);
ParallelWork(firstPass, exceptions, sourceDirectoryChanges, containersCount, container, filteredItems, totalSeconds);
totalSeconds = (int)Math.Truncate(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
message = $"{i:000}.{container.G} / {containersCount:000}) {filteredItems.Length:000} file(s) - {totalSeconds} total second(s) - {container.SourceDirectory}";
ParallelWork(firstPass, exceptions, sourceDirectoryChanges, container, filteredItems, message);
foreach (Exception exception in exceptions)
_Log.Error(string.Concat(container.SourceDirectory, Environment.NewLine, exception.Message, Environment.NewLine, exception.StackTrace), exception);
if (exceptions.Count == filteredItems.Length)
@ -710,17 +713,17 @@ public class A_Property
return results.OrderBy(l => l.Ticks).ToArray();
}
public static Shared.Models.Container[] Get(Configuration configuration, A_Property propertyLogic)
public static (int, int, int, Shared.Models.Container[]) Get(Configuration configuration, A_Property propertyLogic)
{
Shared.Models.Container[] results;
bool firstRun = false;
long ticks = DateTime.Now.Ticks;
List<string> exceptionsDirectories = new();
results = Stateless.Container.GetContainers(configuration, firstRun, propertyLogic);
(int j, int f, int t, results) = Stateless.Container.GetContainers(configuration, firstRun, propertyLogic);
propertyLogic.ParallelWork(ticks, results, firstPass: false);
if (exceptionsDirectories.Any())
throw new Exception();
return results;
return new(j, f, t, results);
}
}