docs: protected synchronized void completeSnapshot(Snapshot snapshot) {
      checkNotNull(snapshot, "snapshot cannot be null");
  
      Map.Entry<Long, Snapshot> lastEntry = snapshots.lastEntry();
      if (lastEntry == null) {
        snapshots.put(snapshot.index(), snapshot);
      } else if (lastEntry.getValue().index() < snapshot.index()) {
        snapshots.put(snapshot.index(), snapshot);
        Snapshot lastSnapshot = lastEntry.getValue();
        lastSnapshot.close();
        lastSnapshot.delete();
      } else if (storage.isRetainStaleSnapshots()) {
        snapshots.put(snapshot.index(), snapshot);
      } else {
        snapshot.close();
        snapshot.delete();
      }
    }