Ticket #23738: 23738-3.patch
File 23738-3.patch, 3.1 KB (added by , 14 months ago) |
---|
-
src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
260 260 try { 261 261 getProgressMonitor().subTask( 262 262 trn("Uploading {0} object...", "Uploading {0} objects...", toUpload.getSize(), toUpload.getSize())); 263 getProgressMonitor().setTicks(0); // needed in 2nd and further loop executions 263 264 synchronized (this) { 264 265 writer = new OsmServerWriter(); 265 266 } -
src/org/openstreetmap/josm/io/OsmServerWriter.java
5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 import static org.openstreetmap.josm.tools.I18n.trn; 7 7 8 import java.time.Instant; 8 9 import java.util.ArrayList; 9 10 import java.util.Collection; 10 11 import java.util.Iterator; … … 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 19 20 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 20 21 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 22 import org.openstreetmap.josm.io.ChangesetClosedException.Source; 21 23 import org.openstreetmap.josm.tools.CheckParameterUtil; 22 24 23 25 /** … … 155 157 progressMonitor.beginTask(tr("Starting to upload in chunks...")); 156 158 List<OsmPrimitive> chunk = new ArrayList<>(chunkSize); 157 159 Iterator<? extends OsmPrimitive> it = primitives.iterator(); 160 int maxChunkSize = api.getCapabilities().getMaxChangesetSize(); 158 161 int numChunks = (int) Math.ceil((double) primitives.size() / (double) chunkSize); 159 162 int i = 0; 160 163 while (it.hasNext()) { … … 162 165 if (canceled) return; 163 166 int j = 0; 164 167 chunk.clear(); 165 while (it.hasNext() && j < chunkSize) { 166 if (canceled) return; 168 while (it.hasNext() && j < chunkSize && processed.size() + j < maxChunkSize) { 167 169 j++; 168 170 chunk.add(it.next()); 169 171 } … … 172 174 "({0}/{1}) Uploading {2} objects...", 173 175 chunk.size(), i, numChunks, chunk.size())); 174 176 processed.addAll(api.uploadDiff(chunk, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false))); 177 // see #23738: server will close CS if maximum changeset size was reached 178 if (processed.size() >= maxChunkSize) { 179 throw new ChangesetClosedException(api.getChangeset().getId(), Instant.now(), Source.UPLOAD_DATA); 180 } 175 181 } 176 182 } finally { 177 183 progressMonitor.finishTask();