person-key-to-immich-import birthday json (Day-Helper-2024-05-18)

csharp_prefer_braces = true
This commit is contained in:
2025-09-06 11:16:55 -07:00
parent 8ec89953bc
commit 6102da7266
54 changed files with 2218 additions and 1721 deletions

View File

@ -1,10 +1,8 @@
using File_Folder_Helper.Models;
using Microsoft.Extensions.Logging;
using System.Collections.ObjectModel;
using System.Text.Json;
using File_Folder_Helper.Models;
using Microsoft.Extensions.Logging;
namespace File_Folder_Helper.ADO2025.PI5;
internal static partial class Helper20250305 {
@ -28,14 +26,15 @@ internal static partial class Helper20250305 {
#if ShellProgressBar
progressBar.Tick();
#endif
if (record.TotalSeconds is null)
if (record.TotalSeconds is null) {
Download(record);
else if (record.TotalSeconds.Value == 0)
} else if (record.TotalSeconds.Value == 0) {
logger.LogInformation("Different lengths");
else if (record.TotalSeconds.Value > 0)
} else if (record.TotalSeconds.Value > 0) {
logger.LogInformation("Overwrite remote (https)");
else
} else {
logger.LogInformation("Overwrite local");
}
}
#if ShellProgressBar
progressBar.Dispose();
@ -50,18 +49,21 @@ internal static partial class Helper20250305 {
NginxFileSystem nginxFileSystem;
ReadOnlyCollection<Record> records;
string checkDirectory = $"{compareDirectory}\\{string.Join('\\', directoryNames)}";
if (!Directory.Exists(checkDirectory))
if (!Directory.Exists(checkDirectory)) {
_ = Directory.CreateDirectory(checkDirectory);
}
for (int i = 0; i < nginxFileSystems.Count; i++) {
nginxFileSystem = NginxFileSystem.Get(format, timeZoneInfo, uri, nginxFileSystems[i]);
if (nginxFileSystem.Type == "file") {
Record? record = CompareFile(host, directoryNames, compareDirectory, nginxFileSystem);
if (record is not null)
if (record is not null) {
results.Add(record);
}
} else {
records = CompareDirectory(format, timeZoneInfo, host, directoryNames, compareDirectory, nginxFileSystem);
foreach (Record record in records)
foreach (Record record in records) {
results.Add(record);
}
}
}
}
@ -72,18 +74,18 @@ internal static partial class Helper20250305 {
List<NginxFileSystem>? results;
Task<HttpResponseMessage> taskHttpResponseMessage = _HttpClient.GetAsync(uri);
taskHttpResponseMessage.Wait();
if (!taskHttpResponseMessage.Result.IsSuccessStatusCode)
if (!taskHttpResponseMessage.Result.IsSuccessStatusCode) {
results = null;
else {
} else {
Task<string> taskString = taskHttpResponseMessage.Result.Content.ReadAsStringAsync();
taskString.Wait();
if (taskString.Result.StartsWith('<'))
if (taskString.Result.StartsWith('<')) {
results = null;
else {
} else {
NginxFileSystem[]? nginxFileSystems = JsonSerializer.Deserialize(taskString.Result, NginxFileSystemCollectionSourceGenerationContext.Default.NginxFileSystemArray);
if (nginxFileSystems is null)
if (nginxFileSystems is null) {
results = null;
else {
} else {
results = [];
NginxFileSystem nginxFileSystem;
for (int i = 0; i < nginxFileSystems.Length; i++) {
@ -98,21 +100,22 @@ internal static partial class Helper20250305 {
private static Record? CompareFile(string host, ReadOnlyCollection<string> directoryNames, string compareDirectory, NginxFileSystem nginxFileSystem) {
Record? result;
if (nginxFileSystem.LastModified is null || nginxFileSystem.Length is null)
if (nginxFileSystem.LastModified is null || nginxFileSystem.Length is null) {
result = null;
else {
} else {
Uri uri = new($"https://{host}/{string.Join('/', directoryNames)}/{nginxFileSystem.Name}");
FileInfo fileInfo = new($"{compareDirectory}\\{string.Join('\\', directoryNames)}\\{nginxFileSystem.Name}");
if (!fileInfo.Exists)
if (!fileInfo.Exists) {
result = new(URI: uri, Path: fileInfo.FullName, LastModified: nginxFileSystem.LastModified.Value, TotalSeconds: null);
else {
} else {
int totalSeconds = (int)new TimeSpan(fileInfo.LastWriteTime.Ticks - nginxFileSystem.LastModified.Value.Ticks).TotalSeconds;
if (totalSeconds is not < 2 or not > -2)
if (totalSeconds is not < 2 or not > -2) {
result = new(URI: uri, Path: fileInfo.FullName, LastModified: nginxFileSystem.LastModified.Value, TotalSeconds: totalSeconds);
else if (fileInfo.Length != nginxFileSystem.Length.Value)
} else if (fileInfo.Length != nginxFileSystem.Length.Value) {
result = new(URI: uri, Path: fileInfo.FullName, LastModified: nginxFileSystem.LastModified.Value, TotalSeconds: 0);
else
} else {
result = null;
}
}
}
return result;