moves all classes to use serilog
All checks were successful
PiwigoDirectorySync/pipeline/head This commit looks good
All checks were successful
PiwigoDirectorySync/pipeline/head This commit looks good
This commit is contained in:
parent
e6f4ebe4cb
commit
5123b59f70
@ -1,7 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Services;
|
||||
using Serilog;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace PiwigoDirectorySync.Commands;
|
||||
@ -9,23 +9,22 @@ namespace PiwigoDirectorySync.Commands;
|
||||
internal class DownloadImagesCommand : CancellableAsyncCommand<DownloadImagesCommand.DownloadImagesSettings>
|
||||
{
|
||||
private readonly IImageSynchronizer _imageSynchronizer;
|
||||
private readonly ILogger<DownloadImagesCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<DownloadImagesCommand>();
|
||||
|
||||
public DownloadImagesCommand(IImageSynchronizer imageSynchronizer, ILogger<DownloadImagesCommand> logger)
|
||||
public DownloadImagesCommand(IImageSynchronizer imageSynchronizer)
|
||||
{
|
||||
_imageSynchronizer = imageSynchronizer;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, DownloadImagesSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Starting image download for piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
_logger.Information("Starting image download for piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
|
||||
await _imageSynchronizer.DownloadImagesAsync(settings.PiwigoServerId, cancellationToken);
|
||||
|
||||
stopWatch.Stop();
|
||||
_logger.LogInformation("Synchronized all images with piwigo server {SettingsPiwigoServerId} in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
_logger.Information("Synchronized all images with piwigo server {SettingsPiwigoServerId} in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
stopWatch.Elapsed.TotalSeconds);
|
||||
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
@ -9,24 +9,22 @@ namespace PiwigoDirectorySync.Commands;
|
||||
|
||||
internal class PiwigoAddCommand : CancellableAsyncCommand<PiwigoAddCommand.PiwigoAddSettings>
|
||||
{
|
||||
private readonly ILogger<PiwigoAddCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<PiwigoAddCommand>();
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
|
||||
public PiwigoAddCommand(ILogger<PiwigoAddCommand> logger, PersistenceContext persistenceContext)
|
||||
public PiwigoAddCommand(PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_persistenceContext = persistenceContext ?? throw new ArgumentNullException(nameof(persistenceContext));
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, PiwigoAddSettings settings, CancellationToken cancellation)
|
||||
{
|
||||
_logger.LogInformation("Adding piwigo server {SettingsServerName} with user {SettingsUserName} and url {SettingsUrl}", settings.ServerName, settings.UserName,
|
||||
settings.Url);
|
||||
_logger.Information("Adding piwigo server {SettingsServerName} with user {SettingsUserName} and url {SettingsUrl}", settings.ServerName, settings.UserName, settings.Url);
|
||||
|
||||
var count = await _persistenceContext.PiwigoServers.Where(s => s.Name == settings.ServerName).CountAsync(cancellation);
|
||||
if (count > 0)
|
||||
{
|
||||
_logger.LogWarning("Server with name {SettingsServerName} already exists. Not updated", settings.ServerName);
|
||||
_logger.Warning("Server with name {SettingsServerName} already exists. Not updated", settings.ServerName);
|
||||
AnsiConsole.MarkupLine($"[maroon]There is already a server with the name {settings.ServerName}[/]");
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Spectre.Console;
|
||||
@ -9,13 +8,11 @@ namespace PiwigoDirectorySync.Commands;
|
||||
|
||||
internal class PiwigoListCommand : CancellableAsyncCommand<PiwigoListCommand.PiwigoListSettings>
|
||||
{
|
||||
private readonly ILogger<PiwigoListCommand> _logger;
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
|
||||
public PiwigoListCommand(ILogger<PiwigoListCommand> logger, PersistenceContext persistenceContext)
|
||||
public PiwigoListCommand(PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_persistenceContext = persistenceContext ?? throw new ArgumentNullException(nameof(persistenceContext));
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, PiwigoListSettings settings, CancellationToken cancellation)
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
@ -9,12 +9,11 @@ namespace PiwigoDirectorySync.Commands;
|
||||
|
||||
internal class PiwigoRemoveCommand : CancellableAsyncCommand<PiwigoRemoveCommand.PiwigoRemoveSettings>
|
||||
{
|
||||
private readonly ILogger<PiwigoRemoveCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<PiwigoRemoveCommand>();
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
|
||||
public PiwigoRemoveCommand(ILogger<PiwigoRemoveCommand> logger, PersistenceContext persistenceContext)
|
||||
public PiwigoRemoveCommand(PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
|
||||
@ -23,29 +22,44 @@ internal class PiwigoRemoveCommand : CancellableAsyncCommand<PiwigoRemoveCommand
|
||||
var server = await _persistenceContext.PiwigoServers.FindByIdAsync(settings.PiwigoServerId, cancellation);
|
||||
if (server is null)
|
||||
{
|
||||
_logger.LogWarning("Could not find server with id {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
_logger.Warning("Could not find server with id {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
AnsiConsole.MarkupLine($"[maroon]Could not find server with id {settings.PiwigoServerId}[/]");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!AnsiConsole.Confirm($"[orange3]Do you really want to remove {server.Name} ({server.Id}) from this database?[/]", false))
|
||||
var serverName = server.Name;
|
||||
var serverId = server.Id;
|
||||
if (!AnsiConsole.Confirm($"[orange3]Do you really want to remove {serverName} ({serverId}) from this database?[/]", false))
|
||||
{
|
||||
_logger.LogInformation("Do not remove server {ServerName}", server.Name);
|
||||
_logger.Information("Do not remove server {ServerName}", serverName);
|
||||
AnsiConsole.MarkupLine("[green]Remove cancelled![/]");
|
||||
return 1;
|
||||
}
|
||||
|
||||
AnsiConsole.MarkupLine($"[orange3]Removing image metadata of server {server.Name}![/]");
|
||||
await _persistenceContext.PiwigoImages.Where(i => i.Album.ServerId == server.Id).ExecuteDeleteAsync(cancellation);
|
||||
await _persistenceContext.SaveChangesAsync(cancellation);
|
||||
_logger.Information("Removing {ServerName} including images and albums from database", serverName);
|
||||
|
||||
AnsiConsole.MarkupLine($"[orange3]Removing album metadata of server {server.Name}![/]");
|
||||
await _persistenceContext.PiwigoAlbums.Where(a => a.ServerId == server.Id).ExecuteDeleteAsync(cancellation);
|
||||
await AnsiConsole.Status()
|
||||
.Spinner(Spinner.Known.Star)
|
||||
.SpinnerStyle(Style.Parse("green bold"))
|
||||
.StartAsync("[orange3]Updating database[/]", async ctx =>
|
||||
{
|
||||
ctx.Status($"[orange3]Removing image metadata of server {serverName}![/]");
|
||||
var deletedImages = await _persistenceContext.PiwigoImages.Where(i => i.Album.ServerId == serverId).ExecuteDeleteAsync(cancellation);
|
||||
await _persistenceContext.SaveChangesAsync(cancellation);
|
||||
ctx.Status($"[green]Deleted {deletedImages} images from database[/]");
|
||||
|
||||
AnsiConsole.MarkupLine($"[orange3]Removing server {server.Name}![/]");
|
||||
await _persistenceContext.PiwigoServers.Where(s => s.Id == server.Id).ExecuteDeleteAsync(cancellation);
|
||||
ctx.Status($"[orange3]Removing album metadata of server {serverName}![/]");
|
||||
var deletedAlbums = await _persistenceContext.PiwigoAlbums.Where(a => a.ServerId == serverId).ExecuteDeleteAsync(cancellation);
|
||||
await _persistenceContext.SaveChangesAsync(cancellation);
|
||||
ctx.Status($"[green]Deleted {deletedAlbums} albums from database[/]");
|
||||
|
||||
ctx.Status($"[orange3]Removing server {serverName}![/]");
|
||||
await _persistenceContext.PiwigoServers.Where(s => s.Id == serverId).ExecuteDeleteAsync(cancellation);
|
||||
await _persistenceContext.SaveChangesAsync(cancellation);
|
||||
ctx.Status($"[green]Deleted piwigo server {serverName}[/]");
|
||||
});
|
||||
|
||||
_logger.Information("Removed {ServerName} including images and albums from database", serverName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
@ -10,24 +10,23 @@ namespace PiwigoDirectorySync.Commands;
|
||||
|
||||
internal class PiwigoUpdateCommand : CancellableAsyncCommand<PiwigoUpdateCommand.PiwigoUpdateSettings>
|
||||
{
|
||||
private readonly ILogger<PiwigoUpdateCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<PiwigoUpdateCommand>();
|
||||
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
|
||||
public PiwigoUpdateCommand(ILogger<PiwigoUpdateCommand> logger, PersistenceContext persistenceContext)
|
||||
public PiwigoUpdateCommand(PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_persistenceContext = persistenceContext ?? throw new ArgumentNullException(nameof(persistenceContext));
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, PiwigoUpdateSettings settings, CancellationToken cancellation)
|
||||
{
|
||||
_logger.LogInformation("Updating piwigo server {SettingsServerName} with user {SettingsUserName} and url {SettingsUrl}", settings.ServerName, settings.UserName,
|
||||
settings.Url);
|
||||
_logger.Information("Updating piwigo server {SettingsServerName} with user {SettingsUserName} and url {SettingsUrl}", settings.ServerName, settings.UserName, settings.Url);
|
||||
|
||||
var count = await _persistenceContext.PiwigoServers.Where(s => s.Name == settings.ServerName && s.Id != settings.PiwigoServerId).CountAsync(cancellation);
|
||||
if (count > 0)
|
||||
{
|
||||
_logger.LogWarning("Server with name {SettingsServerName} already exists. Not updated", settings.ServerName);
|
||||
_logger.Warning("Server with name {SettingsServerName} already exists. Not updated", settings.ServerName);
|
||||
AnsiConsole.MarkupLine(
|
||||
$"[maroon]You can not rename the server with id {settings.PiwigoServerId} to {settings.ServerName} as there is already a server with this name[/]");
|
||||
return -1;
|
||||
@ -36,7 +35,7 @@ internal class PiwigoUpdateCommand : CancellableAsyncCommand<PiwigoUpdateCommand
|
||||
var server = await _persistenceContext.PiwigoServers.FindByIdAsync(settings.PiwigoServerId, cancellation);
|
||||
if (server is null)
|
||||
{
|
||||
_logger.LogWarning("Could not find server with id {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
_logger.Warning("Could not find server with id {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
AnsiConsole.MarkupLine($"[maroon]Could not find server with id {settings.PiwigoServerId}[/]");
|
||||
return -2;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Channels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Services;
|
||||
using Serilog;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
@ -14,11 +14,10 @@ internal class ScanCommand : CancellableAsyncCommand<ScanCommand.ScanSettings>
|
||||
{
|
||||
private readonly IFileIndexer _fileIndexer;
|
||||
private readonly IFileSystemScanner _fileSystemScanner;
|
||||
private readonly ILogger<ScanCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<ScanCommand>();
|
||||
|
||||
public ScanCommand(ILogger<ScanCommand> logger, IFileIndexer fileIndexer, IFileSystemScanner fileSystemScanner)
|
||||
public ScanCommand(IFileIndexer fileIndexer, IFileSystemScanner fileSystemScanner)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileIndexer = fileIndexer;
|
||||
_fileSystemScanner = fileSystemScanner;
|
||||
}
|
||||
@ -32,7 +31,7 @@ internal class ScanCommand : CancellableAsyncCommand<ScanCommand.ScanSettings>
|
||||
internal static async Task ScanDirectory(ILogger logger, IFileIndexer fileIndexer, IFileSystemScanner fileSystemScanner, int piwigoServerId, CancellationToken ct)
|
||||
{
|
||||
//TODO: check files for deletion -> files in db but no longer exist
|
||||
logger.LogInformation("Starting scanner and remover");
|
||||
logger.Information("Starting scanner and remover");
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
var fileQueue = Channel.CreateUnbounded<string>();
|
||||
|
||||
@ -42,12 +41,12 @@ internal class ScanCommand : CancellableAsyncCommand<ScanCommand.ScanSettings>
|
||||
await Task.WhenAll(scannerTask, indexerTask);
|
||||
|
||||
stopWatch.Stop();
|
||||
logger.LogInformation("Processed {IndexerTotalFilesScanned} image files in {ElapsedTotalSeconds} seconds", fileIndexer.TotalFilesScanned, stopWatch.Elapsed.TotalSeconds);
|
||||
logger.Information("Processed {IndexerTotalFilesScanned} image files in {ElapsedTotalSeconds} seconds", fileIndexer.TotalFilesScanned, stopWatch.Elapsed.TotalSeconds);
|
||||
|
||||
foreach (var failedFilePath in fileIndexer.FailedFiles)
|
||||
{
|
||||
AnsiConsole.MarkupLine($"[red]Failed to index file {failedFilePath}[/]");
|
||||
logger.LogError("Failed to index file {FailedFilePath}", failedFilePath);
|
||||
logger.Error("Failed to index file {FailedFilePath}", failedFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Services;
|
||||
using Serilog;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace PiwigoDirectorySync.Commands;
|
||||
@ -10,24 +10,23 @@ namespace PiwigoDirectorySync.Commands;
|
||||
internal class SyncAlbumsCommand : CancellableAsyncCommand<SyncAlbumsCommand.SyncAlbumsSettings>
|
||||
{
|
||||
private readonly IAlbumSynchronizer _albumSynchronizer;
|
||||
private readonly ILogger<SyncAlbumsCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<SyncAlbumsCommand>();
|
||||
|
||||
public SyncAlbumsCommand(ILogger<SyncAlbumsCommand> logger, IAlbumSynchronizer albumSynchronizer)
|
||||
public SyncAlbumsCommand(IAlbumSynchronizer albumSynchronizer)
|
||||
{
|
||||
_logger = logger;
|
||||
_albumSynchronizer = albumSynchronizer;
|
||||
}
|
||||
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, SyncAlbumsSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Starting album synchronization for piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
_logger.Information("Starting album synchronization for piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
|
||||
await _albumSynchronizer.SynchronizeAlbums(settings.PiwigoServerId, settings.CreateAlbumsOnServer, cancellationToken);
|
||||
|
||||
stopWatch.Stop();
|
||||
_logger.LogInformation("Synchronized all albums with piwigo server {SettingsPiwigoServerId} in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
_logger.Information("Synchronized all albums with piwigo server {SettingsPiwigoServerId} in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
stopWatch.Elapsed.TotalSeconds);
|
||||
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Services;
|
||||
using Serilog;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace PiwigoDirectorySync.Commands;
|
||||
@ -12,34 +12,32 @@ internal class SyncFullCommand : CancellableAsyncCommand<SyncFullCommand.SyncFul
|
||||
private readonly IFileIndexer _fileIndexer;
|
||||
private readonly IFileSystemScanner _fileSystemScanner;
|
||||
private readonly IImageSynchronizer _imageSynchronizer;
|
||||
private readonly ILogger<SyncFullCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<SyncFullCommand>();
|
||||
|
||||
public SyncFullCommand(IAlbumSynchronizer albumSynchronizer, IFileIndexer fileIndexer, IFileSystemScanner fileSystemScanner, IImageSynchronizer imageSynchronizer,
|
||||
ILogger<SyncFullCommand> logger)
|
||||
public SyncFullCommand(IAlbumSynchronizer albumSynchronizer, IFileIndexer fileIndexer, IFileSystemScanner fileSystemScanner, IImageSynchronizer imageSynchronizer)
|
||||
{
|
||||
_albumSynchronizer = albumSynchronizer;
|
||||
_fileIndexer = fileIndexer;
|
||||
_fileSystemScanner = fileSystemScanner;
|
||||
_imageSynchronizer = imageSynchronizer;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, SyncFullSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Starting full synchronization for piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
_logger.Information("Starting full synchronization for piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
|
||||
_logger.LogInformation("running file system scan");
|
||||
_logger.Information("running file system scan");
|
||||
await ScanCommand.ScanDirectory(_logger, _fileIndexer, _fileSystemScanner, settings.PiwigoServerId, cancellationToken);
|
||||
|
||||
_logger.LogInformation("running album synchronization");
|
||||
_logger.Information("running album synchronization");
|
||||
await _albumSynchronizer.SynchronizeAlbums(settings.PiwigoServerId, true, cancellationToken);
|
||||
|
||||
_logger.LogInformation("running image synchronization");
|
||||
_logger.Information("running image synchronization");
|
||||
await _imageSynchronizer.SynchronizeImagesAsync(settings.PiwigoServerId, cancellationToken);
|
||||
|
||||
stopWatch.Stop();
|
||||
_logger.LogInformation("Full synchronization for piwigo server {SettingsPiwigoServerId} finished in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
_logger.Information("Full synchronization for piwigo server {SettingsPiwigoServerId} finished in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
stopWatch.Elapsed.TotalSeconds);
|
||||
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Services;
|
||||
using Serilog;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace PiwigoDirectorySync.Commands;
|
||||
@ -9,23 +9,22 @@ namespace PiwigoDirectorySync.Commands;
|
||||
internal class SyncImagesCommand : CancellableAsyncCommand<SyncImagesCommand.SyncImagesSettings>
|
||||
{
|
||||
private readonly IImageSynchronizer _imageSynchronizer;
|
||||
private readonly ILogger<SyncImagesCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<SyncImagesCommand>();
|
||||
|
||||
public SyncImagesCommand(ILogger<SyncImagesCommand> logger, IImageSynchronizer imageSynchronizer)
|
||||
public SyncImagesCommand(IImageSynchronizer imageSynchronizer)
|
||||
{
|
||||
_logger = logger;
|
||||
_imageSynchronizer = imageSynchronizer;
|
||||
}
|
||||
|
||||
protected override async Task<int> ExecuteAsync(CommandContext context, SyncImagesSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Starting image synchronization of piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
_logger.Information("Starting image synchronization of piwigo server {SettingsPiwigoServerId}", settings.PiwigoServerId);
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
|
||||
await _imageSynchronizer.SynchronizeImagesAsync(settings.PiwigoServerId, cancellationToken);
|
||||
|
||||
stopWatch.Stop();
|
||||
_logger.LogInformation("Synchronized all images with piwigo server {SettingsPiwigoServerId} in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
_logger.Information("Synchronized all images with piwigo server {SettingsPiwigoServerId} in {ElapsedTotalSeconds} seconds", settings.PiwigoServerId,
|
||||
stopWatch.Elapsed.TotalSeconds);
|
||||
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
@ -9,12 +9,11 @@ namespace PiwigoDirectorySync.Commands;
|
||||
|
||||
internal class UpdateDatabaseCommand : CancellableAsyncCommand<UpdateDatabaseCommand.UpdateDatabaseSettings>
|
||||
{
|
||||
private readonly ILogger<UpdateDatabaseCommand> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<UpdateDatabaseCommand>();
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
|
||||
public UpdateDatabaseCommand(ILogger<UpdateDatabaseCommand> logger, PersistenceContext persistenceContext)
|
||||
public UpdateDatabaseCommand(PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
|
||||
@ -31,7 +30,7 @@ internal class UpdateDatabaseCommand : CancellableAsyncCommand<UpdateDatabaseCom
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogCritical(ex, "Could not update database due to an error {ExMessage}", ex.Message);
|
||||
_logger.Fatal(ex, "Could not update database due to an error {ExMessage}", ex.Message);
|
||||
AnsiConsole.WriteException(ex);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ using Serilog.Events;
|
||||
using Serilog.Sinks.SystemConsole.Themes;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
const string outputTemplateConsole = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}: {Message}";
|
||||
const string outputTemplateConsole = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}: {Message}{NewLine}";
|
||||
const string outputTemplateFile = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{NewLine}{Exception}{NewLine}";
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
@ -20,7 +20,7 @@ Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.Override("System", LogEventLevel.Warning)
|
||||
.MinimumLevel.Override("Piwigo.Client", LogEventLevel.Warning)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console(LogEventLevel.Warning, outputTemplateConsole, theme: AnsiConsoleTheme.Literate)
|
||||
.WriteTo.Console(LogEventLevel.Information, outputTemplateConsole, theme: AnsiConsoleTheme.Code)
|
||||
.WriteTo.File("logs/PiwigoDirectorySync.txt", LogEventLevel.Debug, outputTemplate:outputTemplateFile, rollingInterval: RollingInterval.Day)
|
||||
.CreateLogger();
|
||||
|
||||
|
@ -1,21 +1,20 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Piwigo.Client;
|
||||
using Piwigo.Client.Albums;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
|
||||
namespace PiwigoDirectorySync.Services;
|
||||
|
||||
internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
{
|
||||
private readonly ILogger<AlbumSynchronizer> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<AlbumSynchronizer>();
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
private readonly IPiwigoClientFactory _piwigoClientFactory;
|
||||
|
||||
public AlbumSynchronizer(ILogger<AlbumSynchronizer> logger, IPiwigoClientFactory piwigoClientFactory, PersistenceContext persistenceContext)
|
||||
public AlbumSynchronizer(IPiwigoClientFactory piwigoClientFactory, PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_piwigoClientFactory = piwigoClientFactory;
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
@ -25,7 +24,7 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
var piwigoServer = await _persistenceContext.PiwigoServers.FindAsync(new object?[] { piwigoServerId }, ct);
|
||||
if (piwigoServer is null)
|
||||
{
|
||||
_logger.LogError("Could not sync albums with piwigo server {PiwigoServerId}", piwigoServerId);
|
||||
_logger.Error("Could not sync albums with piwigo server {PiwigoServerId}", piwigoServerId);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -34,12 +33,12 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
await UpdatePiwigoAlbumsFromServerAsync(piwigoClient, piwigoServer, ct);
|
||||
if (createAlbumsOnServer)
|
||||
{
|
||||
_logger.LogInformation("Creating missing albums on server {PiwigoServerId} - {PiwigoServerName}", piwigoServer.Id, piwigoServer.Name);
|
||||
_logger.Information("Creating missing albums on server {PiwigoServerId} - {PiwigoServerName}", piwigoServer.Id, piwigoServer.Name);
|
||||
await AddMissingAlbumsToServerAsync(piwigoClient, piwigoServer, ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Skipping album creation on server {PiwigoServerId} - {PiwigoServerName}", piwigoServer.Id, piwigoServer.Name);
|
||||
_logger.Information("Skipping album creation on server {PiwigoServerId} - {PiwigoServerName}", piwigoServer.Id, piwigoServer.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +68,7 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
|
||||
foreach (var serverAlbum in serverAlbums)
|
||||
{
|
||||
_logger.LogInformation("Updating piwigo server album {ServerAlbumName} with piwigo id {ServerAlbumId}", serverAlbum.Name, serverAlbum.Id);
|
||||
_logger.Information("Updating piwigo server album {ServerAlbumName} with piwigo id {ServerAlbumId}", serverAlbum.Name, serverAlbum.Id);
|
||||
|
||||
var albumEntity = await GetOrAddPiwigoAlbumEntityFromServerAsync(piwigoServer, serverAlbum, serverAlbumDictionary, ct);
|
||||
if (serverAlbum.IdUpperCat.HasValue)
|
||||
@ -88,7 +87,7 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
var albumEntity = await _persistenceContext.PiwigoAlbums.FindByServerIdAsync(piwigoServer.Id, serverAlbum.Id, ct);
|
||||
if (albumEntity != null)
|
||||
{
|
||||
_logger.LogDebug("Found existing album {AlbumEntityName} with local id {AlbumEntityId} and piwigo server id {ServerAlbumId}", albumEntity.Name, albumEntity.Id,
|
||||
_logger.Debug("Found existing album {AlbumEntityName} with local id {AlbumEntityId} and piwigo server id {ServerAlbumId}", albumEntity.Name, albumEntity.Id,
|
||||
albumEntity.ServerAlbumId);
|
||||
return albumEntity;
|
||||
}
|
||||
@ -100,7 +99,7 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
if (albumEntity != null)
|
||||
{
|
||||
albumEntity.ServerAlbumId = serverAlbum.Id;
|
||||
_logger.LogInformation("Linking existing album {AlbumEntityName} with local id {AlbumEntityId} to piwigo server id {ServerAlbumId}", albumEntity.Name, albumEntity.Id,
|
||||
_logger.Information("Linking existing album {AlbumEntityName} with local id {AlbumEntityId} to piwigo server id {ServerAlbumId}", albumEntity.Name, albumEntity.Id,
|
||||
albumEntity.ServerAlbumId);
|
||||
return albumEntity;
|
||||
}
|
||||
@ -113,7 +112,7 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
ServerAlbumId = serverAlbum.Id,
|
||||
Path = path
|
||||
};
|
||||
_logger.LogInformation("Adding piwigo album {AlbumEntityName} with local id {AlbumEntityId} and piwigo server id {ServerAlbumId}", albumEntity.Name, albumEntity.Id,
|
||||
_logger.Information("Adding piwigo album {AlbumEntityName} with local id {AlbumEntityId} and piwigo server id {ServerAlbumId}", albumEntity.Name, albumEntity.Id,
|
||||
albumEntity.ServerAlbumId);
|
||||
_persistenceContext.PiwigoAlbums.Add(albumEntity);
|
||||
|
||||
@ -136,7 +135,7 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
parentId = currentParent.IdUpperCat ?? 0;
|
||||
}
|
||||
|
||||
_logger.LogDebug("Generated path {Path} for album with piwigo id {ServerAlbumId}", path, serverAlbum.Id);
|
||||
_logger.Debug("Generated path {Path} for album with piwigo id {ServerAlbumId}", path, serverAlbum.Id);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
@ -2,22 +2,22 @@
|
||||
using System.Threading.Channels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
|
||||
namespace PiwigoDirectorySync.Services;
|
||||
|
||||
internal class FileIndexer : IFileIndexer
|
||||
{
|
||||
private readonly ConcurrentBag<string> _failedFiles = new();
|
||||
private readonly ILogger<FileIndexer> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<FileIndexer>();
|
||||
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private int _totalFilesScanned;
|
||||
|
||||
public FileIndexer(ILogger<FileIndexer> logger, IServiceProvider serviceProvider)
|
||||
public FileIndexer(IServiceProvider serviceProvider)
|
||||
{
|
||||
_logger = logger;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
@ -42,16 +42,16 @@ internal class FileIndexer : IFileIndexer
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogWarning("Indexing cancelled");
|
||||
_logger.Warning("Indexing cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Indexing file {FullFilePath}", fullFilePath);
|
||||
_logger.Information("Indexing file {FullFilePath}", fullFilePath);
|
||||
var fileInfo = new FileInfo(fullFilePath);
|
||||
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
_logger.LogWarning("File {FullFilePath} not found", fullFilePath);
|
||||
_logger.Warning("File {FullFilePath} not found", fullFilePath);
|
||||
_failedFiles.Add(fullFilePath);
|
||||
return;
|
||||
}
|
||||
@ -82,7 +82,7 @@ internal class FileIndexer : IFileIndexer
|
||||
catch (Exception ex)
|
||||
{
|
||||
_failedFiles.Add(fullFilePath);
|
||||
_logger.LogError(ex, "could not index file {FullFilePath}", fullFilePath);
|
||||
_logger.Error(ex, "could not index file {FullFilePath}", fullFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,16 @@
|
||||
using System.Threading.Channels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
|
||||
namespace PiwigoDirectorySync.Services;
|
||||
|
||||
internal class FileSystemScanner : IFileSystemScanner
|
||||
{
|
||||
private readonly ILogger<FileSystemScanner> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<FileSystemScanner>();
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
|
||||
|
||||
public FileSystemScanner(ILogger<FileSystemScanner> logger, PersistenceContext persistenceContext)
|
||||
public FileSystemScanner(PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
|
||||
@ -21,7 +19,7 @@ internal class FileSystemScanner : IFileSystemScanner
|
||||
try
|
||||
{
|
||||
var piwigoServer = await _persistenceContext.PiwigoServers.GetByIdAsync(piwigoServerId, ct);
|
||||
_logger.LogInformation("Scanning files for piwigo server {PiwigoServerName} in directory {PiwigoServerRootDirectory}", piwigoServer.Name, piwigoServer.RootDirectory);
|
||||
_logger.Information("Scanning files for piwigo server {PiwigoServerName} in directory {PiwigoServerRootDirectory}", piwigoServer.Name, piwigoServer.RootDirectory);
|
||||
|
||||
await ScanRootDirectory(fileQueue, new DirectoryInfo(piwigoServer.RootDirectory), ct);
|
||||
}
|
||||
@ -33,7 +31,7 @@ internal class FileSystemScanner : IFileSystemScanner
|
||||
|
||||
private async ValueTask ScanRootDirectory(Channel<string> fileQueue, DirectoryInfo directory, CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Scanning root directory {DirectoryFullName} for sidecars to delete", directory.FullName);
|
||||
_logger.Information("Scanning root directory {DirectoryFullName} for sidecars to delete", directory.FullName);
|
||||
var parallelOptions = new ParallelOptions
|
||||
{
|
||||
CancellationToken = ct
|
||||
@ -45,7 +43,7 @@ internal class FileSystemScanner : IFileSystemScanner
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Scanning directory {DirectoryFullName} for images", directory.FullName);
|
||||
_logger.Information("Scanning directory {DirectoryFullName} for images", directory.FullName);
|
||||
|
||||
var imageFiles = AppSettings.SupportedExtensions.SelectMany(ext => directory.GetFiles($"*.{ext}", SearchOption.TopDirectoryOnly))
|
||||
.Select(f => f.FullName)
|
||||
@ -53,19 +51,19 @@ internal class FileSystemScanner : IFileSystemScanner
|
||||
|
||||
if (!imageFiles.Any())
|
||||
{
|
||||
_logger.LogDebug("No images in {DirectoryFullName} found, skipping", directory.FullName);
|
||||
_logger.Debug("No images in {DirectoryFullName} found, skipping", directory.FullName);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var imageFile in imageFiles.Select(f => new FileInfo(f)))
|
||||
{
|
||||
_logger.LogDebug("Found image {ImageFileFullName}, enqueue index", imageFile.FullName);
|
||||
_logger.Debug("Found image {ImageFileFullName}, enqueue index", imageFile.FullName);
|
||||
await fileQueue.Writer.WriteAsync(imageFile.FullName, ct);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "could not scan directory {DirectoryFullName}", directory.FullName);
|
||||
_logger.Error(ex, "could not scan directory {DirectoryFullName}", directory.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,22 @@
|
||||
using Flurl.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Piwigo.Client;
|
||||
using Piwigo.Client.Albums;
|
||||
using Piwigo.Client.Images;
|
||||
using PiwigoDirectorySync.Infrastructure;
|
||||
using PiwigoDirectorySync.Persistence;
|
||||
using Serilog;
|
||||
|
||||
namespace PiwigoDirectorySync.Services;
|
||||
|
||||
internal class ImageSynchronizer : IImageSynchronizer
|
||||
{
|
||||
private readonly ILogger<ImageSynchronizer> _logger;
|
||||
private readonly ILogger _logger = Log.ForContext<ImageSynchronizer>();
|
||||
private readonly PersistenceContext _persistenceContext;
|
||||
private readonly IPiwigoClientFactory _piwigoClientFactory;
|
||||
|
||||
public ImageSynchronizer(ILogger<ImageSynchronizer> logger, IPiwigoClientFactory piwigoClientFactory, PersistenceContext persistenceContext)
|
||||
public ImageSynchronizer(IPiwigoClientFactory piwigoClientFactory, PersistenceContext persistenceContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_piwigoClientFactory = piwigoClientFactory;
|
||||
_persistenceContext = persistenceContext;
|
||||
}
|
||||
@ -27,11 +26,11 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
var piwigoServer = await _persistenceContext.PiwigoServers.FindAsync(new object?[] { piwigoServerId }, ct);
|
||||
if (piwigoServer is null)
|
||||
{
|
||||
_logger.LogError("Could not sync images with piwigo server {PiwigoServerId}", piwigoServerId);
|
||||
_logger.Error("Could not sync images with piwigo server {PiwigoServerId}", piwigoServerId);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Downloading missing images of piwigo server {PiwigoServerName} using base path {PiwigoServerRootDirectory}", piwigoServer.Name,
|
||||
_logger.Information("Downloading missing images of piwigo server {PiwigoServerName} using base path {PiwigoServerRootDirectory}", piwigoServer.Name,
|
||||
piwigoServer.RootDirectory);
|
||||
|
||||
var piwigoClient = await _piwigoClientFactory.GetPiwigoClientAsync(piwigoServer, ct);
|
||||
@ -43,7 +42,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
var albumInfos = await piwigoClient.Album.GetListAsync(albumId, false, false, ThumbnailSize.Thumb, ct);
|
||||
var albumInfo = albumInfos.First();
|
||||
|
||||
_logger.LogInformation("Starting downloads for album {AlbumInfoName}", albumInfo.Name);
|
||||
_logger.Information("Starting downloads for album {AlbumInfoName}", albumInfo.Name);
|
||||
|
||||
await DownloadImagesForAlbumAsync(piwigoClient, piwigoServer, albumId, albumInfo, ct);
|
||||
}
|
||||
@ -54,11 +53,11 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
var piwigoServer = await _persistenceContext.PiwigoServers.FindAsync(new object?[] { piwigoServerId }, ct);
|
||||
if (piwigoServer is null)
|
||||
{
|
||||
_logger.LogError("Could not sync images with piwigo server {PiwigoServerId}", piwigoServerId);
|
||||
_logger.Error("Could not sync images with piwigo server {PiwigoServerId}", piwigoServerId);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Synchronizing images of piwigo server {PiwigoServerName} using base path {PiwigoServerRootDirectory}", piwigoServer.Name,
|
||||
_logger.Information("Synchronizing images of piwigo server {PiwigoServerName} using base path {PiwigoServerRootDirectory}", piwigoServer.Name,
|
||||
piwigoServer.RootDirectory);
|
||||
|
||||
var piwigoClient = await _piwigoClientFactory.GetPiwigoClientAsync(piwigoServer, ct);
|
||||
@ -72,7 +71,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
{
|
||||
if (albumInfo.NbImages is null or <= 0)
|
||||
{
|
||||
_logger.LogInformation("No images to download for empty album {AlbumId} / {AlbumInfoName}", albumId, albumInfo.Name);
|
||||
_logger.Information("No images to download for empty album {AlbumId} / {AlbumInfoName}", albumId, albumInfo.Name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
var localAlbum = await _persistenceContext.PiwigoAlbums.FindByServerIdAsync(piwigoServer.Id, albumInfo.Id, ct);
|
||||
if (localAlbum is null)
|
||||
{
|
||||
_logger.LogWarning("Could not add image {ImageId} / {ImageFile}: album with server id {AlbumInfoId} / {AlbumInfoName} not found", image.Id, image.File, albumInfo.Id,
|
||||
_logger.Warning("Could not add image {ImageId} / {ImageFile}: album with server id {AlbumInfoId} / {AlbumInfoName} not found", image.Id, image.File, albumInfo.Id,
|
||||
albumInfo.Name);
|
||||
return;
|
||||
}
|
||||
@ -109,7 +108,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
var fileInfo = new FileInfo(Path.Combine(piwigoServer.RootDirectory, localImage.FilePath));
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
_logger.LogWarning("Tried to download image {ImageFile} but it already exists", image.File);
|
||||
_logger.Warning("Tried to download image {ImageFile} but it already exists", image.File);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,7 +143,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
.Where(i => i.ServerImageId != null && i.Album.ServerId == piwigoServer.Id && i.UploadRequired)
|
||||
.ToListAsync(ct);
|
||||
|
||||
_logger.LogInformation("Updating {Count} images", imagesToUpload.Count);
|
||||
_logger.Information("Updating {Count} images", imagesToUpload.Count);
|
||||
|
||||
foreach (var imageEntity in imagesToUpload)
|
||||
{
|
||||
@ -155,7 +154,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
imageEntity.ServerImageId = imageUploaded.ImageId;
|
||||
imageEntity.UploadRequired = false;
|
||||
|
||||
_logger.LogInformation("Updated image {ImageEntityName} ({ImageEntityId}) on piwigo server with id {ImageEntityServerImageId}", imageEntity.Name, imageEntity.Id,
|
||||
_logger.Information("Updated image {ImageEntityName} ({ImageEntityId}) on piwigo server with id {ImageEntityServerImageId}", imageEntity.Name, imageEntity.Id,
|
||||
imageEntity.ServerImageId);
|
||||
|
||||
await _persistenceContext.SaveChangesAsync(ct);
|
||||
@ -168,7 +167,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
.Where(i => i.ServerImageId == null && i.Album.ServerId == piwigoServer.Id && i.Album.ServerAlbumId != null)
|
||||
.ToListAsync(ct);
|
||||
|
||||
_logger.LogInformation("Uploading {Count} images", imagesToUpload.Count);
|
||||
_logger.Information("Uploading {Count} images", imagesToUpload.Count);
|
||||
|
||||
foreach (var imageEntity in imagesToUpload)
|
||||
{
|
||||
@ -179,7 +178,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
imageEntity.ServerImageId = imageUploaded.ImageId;
|
||||
imageEntity.UploadRequired = false;
|
||||
|
||||
_logger.LogInformation("Uploaded image {ImageEntityName} ({ImageEntityId}) to piwigo server with id {ImageEntityServerImageId}", imageEntity.Name, imageEntity.Id,
|
||||
_logger.Information("Uploaded image {ImageEntityName} ({ImageEntityId}) to piwigo server with id {ImageEntityServerImageId}", imageEntity.Name, imageEntity.Id,
|
||||
imageEntity.ServerImageId);
|
||||
|
||||
await _persistenceContext.SaveChangesAsync(ct);
|
||||
@ -205,7 +204,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
.Where(i => i.ServerImageId == null && i.Album.ServerId == piwigoServer.Id)
|
||||
.ToListAsync(ct);
|
||||
|
||||
_logger.LogInformation("Checking {Count} images if they exist", imagesToSearch.Count);
|
||||
_logger.Information("Checking {Count} images if they exist", imagesToSearch.Count);
|
||||
|
||||
var md5SumsToCheck = imagesToSearch.Where(i => i.Md5Sum != null).DistinctBy(i => i.Md5Sum).ToDictionary(i => i.Md5Sum!, i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
@ -221,7 +220,7 @@ internal class ImageSynchronizer : IImageSynchronizer
|
||||
imageEntity.ServerImageId = existingImage.Value;
|
||||
imageEntity.UploadRequired = false;
|
||||
|
||||
_logger.LogInformation("Found image {ImageEntityName} ({ImageEntityId}) on piwigo server with id {ImageEntityServerImageId}", imageEntity.Name, imageEntity.Id,
|
||||
_logger.Information("Found image {ImageEntityName} ({ImageEntityId}) on piwigo server with id {ImageEntityServerImageId}", imageEntity.Name, imageEntity.Id,
|
||||
imageEntity.ServerImageId);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user