From d412e05eaa6268d648469536ac8a77a7184959fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 11 Jul 2013 22:45:32 +0200 Subject: [PATCH] Ignore albums without inserted images when calculating the fingerprint. --- src/main/java/net/pterodactylus/sone/data/Album.java | 10 +++++++++- src/main/java/net/pterodactylus/sone/data/Sone.java | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index aa14ede..c47d83f 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -86,11 +86,19 @@ public class Album implements Fingerprintable { @Override public boolean apply(Album album) { + /* so, we flatten all albums below the given one and check whether at least one album… */ return FluentIterable.from(asList(album)).transformAndConcat(FLATTENER).anyMatch(new Predicate() { @Override public boolean apply(Album album) { - return !album.getImages().isEmpty(); + /* …contains any inserted images. */ + return !album.getImages().isEmpty() && FluentIterable.from(album.getImages()).allMatch(new Predicate() { + + @Override + public boolean apply(Image input) { + return input.isInserted(); + } + }); } }); } diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 22dc593..eb52860 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -832,7 +832,10 @@ public class Sone implements Fingerprintable, Comparable { hash.putString(")"); hash.putString("Albums("); - for (Album album : albums) { + for (Album album : rootAlbum.getAlbums()) { + if (!Album.NOT_EMPTY.apply(album)) { + continue; + } hash.putString(album.getFingerprint()); } hash.putString(")"); -- 2.7.4