Facebook logic, IsDefaultName, GetFiles update and

HardCoded tests
This commit is contained in:
2023-04-01 11:29:00 -07:00
parent b0b6864841
commit ba5bc6347c
36 changed files with 1396 additions and 402 deletions

View File

@ -2,6 +2,7 @@
using Phares.Shared;
using Serilog;
using ShellProgressBar;
using System.Text.Json;
using View_by_Distance.Rename.Models;
using View_by_Distance.Shared.Models;
using View_by_Distance.Shared.Models.Methods;
@ -35,7 +36,6 @@ public class Rename
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
propertyConfiguration.Update();
string? comparePathRoot = Path.GetDirectoryName(appSettings.ComparePathsFile);
if (comparePathRoot is null || comparePathRoot == propertyConfiguration.RootDirectory)
@ -43,7 +43,7 @@ public class Rename
log.Information(propertyConfiguration.RootDirectory);
Verify();
string json = File.ReadAllText(appSettings.ComparePathsFile);
MatchNginx[]? matchNginxCollection = System.Text.Json.JsonSerializer.Deserialize<MatchNginx[]>(json);
MatchNginx[]? matchNginxCollection = JsonSerializer.Deserialize<MatchNginx[]>(json);
if (matchNginxCollection is null)
throw new NullReferenceException(nameof(matchNginxCollection));
if (matchNginxCollection.Length == 0 && matchNginxCollection[0].ConvertedPath.Contains("~~~"))
@ -52,7 +52,7 @@ public class Rename
Rename2000(matchNginxCollection);
else if (matchNginxCollection.Any())
{
List<string> lines = RenameFilesInDirectories(log, options, matchNginxCollection);
List<string> lines = RenameFilesInDirectories(log, matchNginxCollection);
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
if (comparePathRoot != Path.GetPathRoot(matchNginxCollection[0].ConvertedPath))
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(comparePathRoot);
@ -71,6 +71,8 @@ public class Rename
{ }
if (_WorkingDirectory is null)
{ }
if (_PropertyConfiguration is null)
{ }
}
private static void MoveMatches(MatchNginx matchNginx)
@ -384,7 +386,7 @@ public class Rename
return results;
}
private List<string> RenameFilesInDirectories(ILogger log, ProgressBarOptions options, MatchNginx[] matchNginxCollection)
private List<string> RenameFilesInDirectories(ILogger log, MatchNginx[] matchNginxCollection)
{
List<string> results = new();
string[] files;
@ -393,6 +395,7 @@ public class Rename
List<(FileHolder, string)> toDoCollection;
List<(FileHolder, string)> verifiedToDoCollection;
List<string> allFiles = GetAllFiles(matchNginxCollection);
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
for (int i = 1; i < 3; i++)
{
message = $"{i}) Renaming files";

View File

@ -3,7 +3,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

View File

@ -1,5 +1,5 @@
{
"ComparePathsFile": "C:/Users/mikep/AppData/Local/PharesApps/Drag-Drop-Explorer/2023_06/638111927302288853.json",
"ComparePathsFile": "C:/Users/mikep/AppData/Local/PharesApps/Drag-Drop-Explorer/2023_13/638158781544395303.json",
"CopyTo": "",
"Logging": {
"LogLevel": {