Skip to content

Commit 88983fa

Browse files
Add expiry check only for SaltStoreWriter (#385)
1 parent 5236f04 commit 88983fa

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/com/uid2/admin/store/writer/SaltStoreWriter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ protected List<RotatingSaltProvider.SaltSnapshot> getSnapshots(RotatingSaltProvi
6060
List<RotatingSaltProvider.SaltSnapshot> filteredSnapshots = new ArrayList<>();
6161

6262
for (RotatingSaltProvider.SaltSnapshot snapshot : snapshots) {
63+
if (!now.isBefore(snapshot.getExpires())) {
64+
LOGGER.info("Skipping expired snapshot, effective=" + snapshot.getEffective() + ", expires=" + snapshot.getExpires());
65+
continue;
66+
}
6367
if (newestEffectiveSnapshot != null && snapshot != newestEffectiveSnapshot) {
6468
LOGGER.info("Skipping effective snapshot, effective=" + snapshot.getEffective() + ", expires=" + snapshot.getExpires()
6569
+ " in favour of newer snapshot, effective=" + newestEffectiveSnapshot.getEffective() + ", expires=" + newestEffectiveSnapshot.getExpires());
@@ -95,13 +99,7 @@ public void upload(RotatingSaltProvider.SaltSnapshot data) throws Exception {
9599
List<RotatingSaltProvider.SaltSnapshot> snapshots = this.getSnapshots(data);
96100

97101
for (RotatingSaltProvider.SaltSnapshot snapshot : snapshots) {
98-
if (!now.isBefore(snapshot.getExpires())) {
99-
LOGGER.info("Skipping expired snapshot, effective=" + snapshot.getEffective() + ", expires=" + snapshot.getExpires());
100-
continue;
101-
}
102-
103102
final String location = getSaltSnapshotLocation(snapshot);
104-
105103
final JsonObject snapshotMetadata = new JsonObject();
106104
snapshotMetadata.put("effective", snapshot.getEffective().toEpochMilli());
107105
snapshotMetadata.put("expires", snapshot.getExpires().toEpochMilli());

0 commit comments

Comments
 (0)