Skip to content

Commit

Permalink
Merge pull request #82 from ajordens/handle-deleted-items-while-refre…
Browse files Browse the repository at this point in the history
…shing

It's possible that an item could be removed mid-refresh cycle
  • Loading branch information
ajordens committed Mar 22, 2016
2 parents 99b3f8e + 3ae0245 commit a277d8a
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,19 @@ protected Set<T> fetchAllItems(Set<T> existingItems) {
.buffer(10)
.flatMap(ids -> Observable
.from(ids)
.flatMap(s3ObjectSummary ->
Observable.just(amazonS3.getObject(s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey()))
.flatMap(s3ObjectSummary -> {
try {
return Observable.just(amazonS3.getObject(s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey()));
} catch (AmazonS3Exception e) {
if (e.getStatusCode() == 404) {
// an item has been removed between the time that object summaries were fetched and now
existingItemsByName.remove(extractItemName(s3ObjectSummary));
return Observable.empty();
}

throw e;
}
}
)
.subscribeOn(scheduler)
)
Expand Down Expand Up @@ -292,5 +303,6 @@ private String extractItemName(S3ObjectSummary s3ObjectSummary) {
}

abstract Class<T> getSerializedClass();

abstract String getMetadataFilename();
}

0 comments on commit a277d8a

Please sign in to comment.