From bb82ea27d37d8de9f25712fb334324c473c2ed9c Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 9 Aug 2024 20:38:13 +0200 Subject: [PATCH] Various changes after handling many error reports --- assets/layers/sport_pitch/sport_pitch.json | 2 +- scripts/handleErrors.ts | 27 +++++++++++----------- src/Logic/Osm/Changes.ts | 20 ++++++++-------- src/Logic/Osm/ChangesetHandler.ts | 6 ++++- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/assets/layers/sport_pitch/sport_pitch.json b/assets/layers/sport_pitch/sport_pitch.json index 8081d8a7a..2e5539fa6 100644 --- a/assets/layers/sport_pitch/sport_pitch.json +++ b/assets/layers/sport_pitch/sport_pitch.json @@ -163,7 +163,7 @@ }, "tags": [ "leisure=pitch", - "fixme=Toegevoegd met MapComplete, geometry nog uit te tekenen" + "fixme=Geometry to be drawn, added by MapComplete" ] } ], diff --git a/scripts/handleErrors.ts b/scripts/handleErrors.ts index 74887276f..43070dc4d 100644 --- a/scripts/handleErrors.ts +++ b/scripts/handleErrors.ts @@ -60,7 +60,6 @@ class HandleErrors extends Script { console.log("Skipping GRB ") continue } - console.log(e.username, e.layout, e.message, parsed.date) for (const pendingChange of e.pendingChanges) { console.log( "\t https://osm.org/" + pendingChange.type + "/" + pendingChange.id, @@ -75,6 +74,8 @@ class HandleErrors extends Script { } for (const parsed of all) { + console.log(parsed.message.username, parsed.message.layout, parsed.message.message, parsed.date) + const e = parsed.message const neededIds = Changes.GetNeededIds(e.pendingChanges) // We _do not_ pass in the Changes object itself - we want the data from OSM directly in order to apply the changes @@ -98,10 +99,7 @@ class HandleErrors extends Script { newObjects: OsmObject[] modifiedObjects: OsmObject[] deletedObjects: OsmObject[] - } = new Changes({ - dryRun: new ImmutableStore(true), - osmConnection, - }).CreateChangesetObjects(toUpload, objects) + } = changesObj.CreateChangesetObjects(toUpload, objects) const changeset = Changes.createChangesetFor("", changes) const path = @@ -110,31 +108,34 @@ class HandleErrors extends Script { changeset === `` ) { - console.log( + /*console.log( "Changes for " + parsed.index + ": empty changeset, not creating a file for it" - ) + )*/ } else if (createdChangesets.has(changeset)) { - console.log( + /* console.log( "Changeset " + parsed.index + " is identical to previously seen changeset, not writing to file" - ) + )*/ } else { - writeFileSync(path, changeset, "utf8") + const changesetWithMsg = ` +${changeset}` + writeFileSync(path, changesetWithMsg, "utf8") createdChangesets.add(changeset) + console.log("Written", path, "with " + e.pendingChanges.length + " changes") } const refusedContent = JSON.stringify(refused) if (refusedFiles.has(refusedContent)) { - console.log( + /* console.log( "Refused changes for " + parsed.index + " is identical to previously seen changeset, not writing to file" - ) + )*/ } else { writeFileSync(path + ".refused.json", refusedContent, "utf8") refusedFiles.add(refusedContent) + console.log("Written refused", path) } - console.log("Written", path, "with " + e.pendingChanges.length + " changes") } } } diff --git a/src/Logic/Osm/Changes.ts b/src/Logic/Osm/Changes.ts index eb7c3ff73..cf17f08e5 100644 --- a/src/Logic/Osm/Changes.ts +++ b/src/Logic/Osm/Changes.ts @@ -440,15 +440,17 @@ export class Changes { } }) - console.debug( - "Calculated the pending changes: ", - result.newObjects.length, - "new; ", - result.modifiedObjects.length, - "modified;", - result.deletedObjects, - "deleted" - ) + if(!(result.newObjects.length === 0 && result.modifiedObjects.length === 0 && result.deletedObjects.length === 0)) { + console.debug( + "Calculated the pending changes: ", + result.newObjects.length, + "new; ", + result.modifiedObjects.length, + "modified;", + result.deletedObjects.length, + "deleted" + ) + } return result } diff --git a/src/Logic/Osm/ChangesetHandler.ts b/src/Logic/Osm/ChangesetHandler.ts index 4b5846ba9..ac8b0f910 100644 --- a/src/Logic/Osm/ChangesetHandler.ts +++ b/src/Logic/Osm/ChangesetHandler.ts @@ -154,6 +154,10 @@ export class ChangesetHandler { if (this._reportError) { this._reportError(e) } + if(( e).status === 400){ + // This request is invalid. We simply drop the changes and hope that someone will analyze what went wrong with it in the upload; we pretend everything went fine + return + } console.warn( "Could not open/upload changeset due to ", e, @@ -195,7 +199,7 @@ export class ChangesetHandler { "Could not reuse changeset " + csId + ", might be closed: " + - (e.stacktrace ?? "" + e) + (e.stacktrace ?? e.status ?? "" + e) ) } console.warn("Could not upload, changeset is probably closed: ", e)