Changeset 19098 in josm for trunk


Ignore:
Timestamp:
2024-06-09T09:47:14+02:00 (5 months ago)
Author:
GerdP
Message:

fix #23645: ChangesetCache: Is it useful as it is? Why isn't it always used?

  • use/update ChangesetCache when downloading changeset in HistoryBrowser
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java

    r19063 r19098  
    1010import java.util.ArrayList;
    1111import java.util.Collection;
     12import java.util.Iterator;
    1213import java.util.LinkedHashSet;
    1314import java.util.List;
     
    1617
    1718import org.openstreetmap.josm.data.osm.Changeset;
     19import org.openstreetmap.josm.data.osm.ChangesetCache;
    1820import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1921import org.openstreetmap.josm.data.osm.PrimitiveId;
     
    230232            OsmServerChangesetReader changesetReader = new OsmServerChangesetReader();
    231233            List<Long> changesetIds = new ArrayList<>(ds.getChangesetIds());
     234            Iterator<Long> iter = changesetIds.iterator();
     235            while (iter.hasNext()) {
     236                long id = iter.next();
     237                Changeset cs = ChangesetCache.getInstance().get((int) id);
     238                if (cs != null && !cs.isOpen()) {
     239                    ds.putChangeset(cs);
     240                    iter.remove();
     241                }
     242            }
    232243
    233244            // query changesets 100 by 100 (OSM API limit)
    234245            int n = ChangesetQuery.MAX_CHANGESETS_NUMBER;
    235246            for (int i = 0; i < changesetIds.size(); i += n) {
     247                List<Changeset> downloadedCS = new ArrayList<>(changesetIds.size());
    236248                for (Changeset c : changesetReader.queryChangesets(
    237249                        new ChangesetQuery().forChangesetIds(changesetIds.subList(i, Math.min(i + n, changesetIds.size()))),
    238250                        progressMonitor.createSubTaskMonitor(1, false))) {
    239251                    ds.putChangeset(c);
     252                    downloadedCS.add(c);
    240253                }
     254                ChangesetCache.getInstance().update(downloadedCS);
    241255            }
    242256        }
Note: See TracChangeset for help on using the changeset viewer.