Various changes after handling many error reports
This commit is contained in:
parent
9b7cdb3c17
commit
bb82ea27d3
4 changed files with 31 additions and 24 deletions
|
@ -163,7 +163,7 @@
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
"leisure=pitch",
|
"leisure=pitch",
|
||||||
"fixme=Toegevoegd met MapComplete, geometry nog uit te tekenen"
|
"fixme=Geometry to be drawn, added by MapComplete"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -60,7 +60,6 @@ class HandleErrors extends Script {
|
||||||
console.log("Skipping GRB ")
|
console.log("Skipping GRB ")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
console.log(e.username, e.layout, e.message, parsed.date)
|
|
||||||
for (const pendingChange of e.pendingChanges) {
|
for (const pendingChange of e.pendingChanges) {
|
||||||
console.log(
|
console.log(
|
||||||
"\t https://osm.org/" + pendingChange.type + "/" + pendingChange.id,
|
"\t https://osm.org/" + pendingChange.type + "/" + pendingChange.id,
|
||||||
|
@ -75,6 +74,8 @@ class HandleErrors extends Script {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const parsed of all) {
|
for (const parsed of all) {
|
||||||
|
console.log(parsed.message.username, parsed.message.layout, parsed.message.message, parsed.date)
|
||||||
|
|
||||||
const e = parsed.message
|
const e = parsed.message
|
||||||
const neededIds = Changes.GetNeededIds(e.pendingChanges)
|
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
|
// 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[]
|
newObjects: OsmObject[]
|
||||||
modifiedObjects: OsmObject[]
|
modifiedObjects: OsmObject[]
|
||||||
deletedObjects: OsmObject[]
|
deletedObjects: OsmObject[]
|
||||||
} = new Changes({
|
} = changesObj.CreateChangesetObjects(toUpload, objects)
|
||||||
dryRun: new ImmutableStore(true),
|
|
||||||
osmConnection,
|
|
||||||
}).CreateChangesetObjects(toUpload, objects)
|
|
||||||
|
|
||||||
const changeset = Changes.createChangesetFor("", changes)
|
const changeset = Changes.createChangesetFor("", changes)
|
||||||
const path =
|
const path =
|
||||||
|
@ -110,31 +108,34 @@ class HandleErrors extends Script {
|
||||||
changeset ===
|
changeset ===
|
||||||
`<osmChange version='0.6' generator='Mapcomplete ${Constants.vNumber}'></osmChange>`
|
`<osmChange version='0.6' generator='Mapcomplete ${Constants.vNumber}'></osmChange>`
|
||||||
) {
|
) {
|
||||||
console.log(
|
/*console.log(
|
||||||
"Changes for " + parsed.index + ": empty changeset, not creating a file for it"
|
"Changes for " + parsed.index + ": empty changeset, not creating a file for it"
|
||||||
)
|
)*/
|
||||||
} else if (createdChangesets.has(changeset)) {
|
} else if (createdChangesets.has(changeset)) {
|
||||||
console.log(
|
/* console.log(
|
||||||
"Changeset " +
|
"Changeset " +
|
||||||
parsed.index +
|
parsed.index +
|
||||||
" is identical to previously seen changeset, not writing to file"
|
" is identical to previously seen changeset, not writing to file"
|
||||||
)
|
)*/
|
||||||
} else {
|
} else {
|
||||||
writeFileSync(path, changeset, "utf8")
|
const changesetWithMsg = `<!-- User: ${parsed.message.username} (${parsed.message.userid}) ${parsed.message.layout}; Version ${parsed.message.version}; Not uploaded due to ${parsed.message.message} -->
|
||||||
|
${changeset}`
|
||||||
|
writeFileSync(path, changesetWithMsg, "utf8")
|
||||||
createdChangesets.add(changeset)
|
createdChangesets.add(changeset)
|
||||||
|
console.log("Written", path, "with " + e.pendingChanges.length + " changes")
|
||||||
}
|
}
|
||||||
const refusedContent = JSON.stringify(refused)
|
const refusedContent = JSON.stringify(refused)
|
||||||
if (refusedFiles.has(refusedContent)) {
|
if (refusedFiles.has(refusedContent)) {
|
||||||
console.log(
|
/* console.log(
|
||||||
"Refused changes for " +
|
"Refused changes for " +
|
||||||
parsed.index +
|
parsed.index +
|
||||||
" is identical to previously seen changeset, not writing to file"
|
" is identical to previously seen changeset, not writing to file"
|
||||||
)
|
)*/
|
||||||
} else {
|
} else {
|
||||||
writeFileSync(path + ".refused.json", refusedContent, "utf8")
|
writeFileSync(path + ".refused.json", refusedContent, "utf8")
|
||||||
refusedFiles.add(refusedContent)
|
refusedFiles.add(refusedContent)
|
||||||
|
console.log("Written refused", path)
|
||||||
}
|
}
|
||||||
console.log("Written", path, "with " + e.pendingChanges.length + " changes")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,15 +440,17 @@ export class Changes {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
console.debug(
|
if(!(result.newObjects.length === 0 && result.modifiedObjects.length === 0 && result.deletedObjects.length === 0)) {
|
||||||
"Calculated the pending changes: ",
|
console.debug(
|
||||||
result.newObjects.length,
|
"Calculated the pending changes: ",
|
||||||
"new; ",
|
result.newObjects.length,
|
||||||
result.modifiedObjects.length,
|
"new; ",
|
||||||
"modified;",
|
result.modifiedObjects.length,
|
||||||
result.deletedObjects,
|
"modified;",
|
||||||
"deleted"
|
result.deletedObjects.length,
|
||||||
)
|
"deleted"
|
||||||
|
)
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,10 @@ export class ChangesetHandler {
|
||||||
if (this._reportError) {
|
if (this._reportError) {
|
||||||
this._reportError(e)
|
this._reportError(e)
|
||||||
}
|
}
|
||||||
|
if((<XMLHttpRequest> 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(
|
console.warn(
|
||||||
"Could not open/upload changeset due to ",
|
"Could not open/upload changeset due to ",
|
||||||
e,
|
e,
|
||||||
|
@ -195,7 +199,7 @@ export class ChangesetHandler {
|
||||||
"Could not reuse changeset " +
|
"Could not reuse changeset " +
|
||||||
csId +
|
csId +
|
||||||
", might be closed: " +
|
", might be closed: " +
|
||||||
(e.stacktrace ?? "" + e)
|
(e.stacktrace ?? e.status ?? "" + e)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
console.warn("Could not upload, changeset is probably closed: ", e)
|
console.warn("Could not upload, changeset is probably closed: ", e)
|
||||||
|
|
Loading…
Reference in a new issue