From ed43852124780b8096c130204b22b58685762ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Tue, 3 Oct 2023 22:18:38 +0200 Subject: [PATCH] fixes pending count --- PiwigoDirectorySync/Services/AlbumSynchronizer.cs | 2 +- PiwigoDirectorySync/Services/ImageSynchronizer.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PiwigoDirectorySync/Services/AlbumSynchronizer.cs b/PiwigoDirectorySync/Services/AlbumSynchronizer.cs index 4f02bcd..808f459 100644 --- a/PiwigoDirectorySync/Services/AlbumSynchronizer.cs +++ b/PiwigoDirectorySync/Services/AlbumSynchronizer.cs @@ -44,7 +44,7 @@ internal class AlbumSynchronizer : IAlbumSynchronizer public async Task GetPendingChangesAsync(int piwigoServerId, CancellationToken ct) { - var getOrAdds = await _persistenceContext.PiwigoAlbums.Where(a => a.ServerAlbumId == null).CountAsync(ct); + var getOrAdds = await _persistenceContext.PiwigoAlbums.Where(a => a.ServerAlbumId == null && a.ServerId == piwigoServerId).CountAsync(ct); const int updates = 0; // not yet supported const int deletes = 0; // not yet supported diff --git a/PiwigoDirectorySync/Services/ImageSynchronizer.cs b/PiwigoDirectorySync/Services/ImageSynchronizer.cs index cbd0dbe..a44bec3 100644 --- a/PiwigoDirectorySync/Services/ImageSynchronizer.cs +++ b/PiwigoDirectorySync/Services/ImageSynchronizer.cs @@ -23,9 +23,9 @@ internal class ImageSynchronizer : IImageSynchronizer public async Task GetPendingChangesAsync(int piwigoServerId, CancellationToken ct) { - var getOrAdds = await _persistenceContext.PiwigoImages.Where(i => i.ServerImageId == null).CountAsync(ct); - var updates = await _persistenceContext.PiwigoImages.Where(i => i.ServerImageId != null && i.UploadRequired).CountAsync(ct); - var deletes = await _persistenceContext.PiwigoImages.Where(i => i.ServerImageId != null && i.DeleteRequired).CountAsync(ct); + var getOrAdds = await _persistenceContext.PiwigoImages.Where(i => i.Album.ServerId == piwigoServerId && i.ServerImageId == null).CountAsync(ct); + var updates = await _persistenceContext.PiwigoImages.Where(i => i.Album.ServerId == piwigoServerId && i.ServerImageId != null && i.UploadRequired).CountAsync(ct); + var deletes = await _persistenceContext.PiwigoImages.Where(i => i.Album.ServerId == piwigoServerId && i.ServerImageId != null && i.DeleteRequired).CountAsync(ct); return new PendingChange(getOrAdds, updates, deletes); } @@ -216,7 +216,7 @@ internal class ImageSynchronizer : IImageSynchronizer } catch (PiwigoException ex) { - _logger.Error(ex,"Could not update image {ImageEntityPath} ({ImageEntityId}) on piwigo server with id {ImageEntityServerImageId}", imageEntity.FilePath, + _logger.Error(ex, "Could not update image {ImageEntityPath} ({ImageEntityId}) on piwigo server with id {ImageEntityServerImageId}", imageEntity.FilePath, imageEntity.Id, imageEntity.ServerImageId); } }