adds a bit of logging when creating missing albums
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
f924c2a7d7
commit
662df35f6a
@ -53,21 +53,27 @@ internal class AlbumSynchronizer : IAlbumSynchronizer
|
||||
|
||||
private async Task AddMissingAlbumsToServerAsync(IPiwigoClient piwigoClient, ServerEntity piwigoServer, CancellationToken ct)
|
||||
{
|
||||
var albumsToCreate = await _persistenceContext.PiwigoAlbums.Where(a => a.ServerAlbumId == null && a.ServerId == piwigoServer.Id)
|
||||
.OrderBy(a => a.Path)
|
||||
.Select(a => a.Id)
|
||||
.ToListAsync(ct);
|
||||
var albumsToCreate = await _persistenceContext.PiwigoAlbums.Where(a => a.ServerAlbumId == null && a.ServerId == piwigoServer.Id).OrderBy(a => a.Path).ToListAsync(ct);
|
||||
|
||||
foreach (var albumId in albumsToCreate)
|
||||
foreach (var albumEntity in albumsToCreate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var albumEntity = await _persistenceContext.PiwigoAlbums.GetByIdAsync(albumId, ct);
|
||||
var piwigoParentId = albumEntity.ParentId.HasValue ? (await _persistenceContext.PiwigoAlbums.GetByIdAsync(albumEntity.ParentId.Value, ct)).ServerAlbumId : null;
|
||||
_logger.Information("Creating album {AlbumName} ({AlbumPath}) on piwigo server {PiwigoServerName} ({PiwigoServerId})", albumEntity.Name, albumEntity.Path,
|
||||
piwigoServer.Name, piwigoServer.Id);
|
||||
|
||||
albumEntity.ServerAlbumId = await piwigoClient.Album.AddAsync(albumEntity.Name, piwigoParentId, visible: true, position: AlbumPosition.First,
|
||||
status: AlbumStatus.Public, cancellationToken: ct);
|
||||
|
||||
await _persistenceContext.SaveChangesAsync(ct);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.Debug("Cancel adding missing albums to server {PiwigoServerName} ({PiwigoServerId})", piwigoServer.Name, piwigoServer.Id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdatePiwigoAlbumsFromServerAsync(IPiwigoClient piwigoClient, ServerEntity piwigoServer, CancellationToken ct)
|
||||
|
Loading…
Reference in New Issue
Block a user