Skip to content

Commit

Permalink
Handle precondition failures caused by new ways (negative id) too
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Jan 25, 2024
1 parent c455c2d commit b1c9972
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions src/main/java/de/blau/android/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -4161,21 +4161,24 @@ protected void onPostExecute(UploadResult result) {
return;
}
if (!activity.isFinishing()) {
if (error == ErrorCodes.UPLOAD_CONFLICT) {
if (result.getOsmId() > 0) {
UploadConflict.showDialog(activity, result);
} else {
Log.e(DEBUG_TAG, "No OSM element found for conflict");
ErrorAlert.showDialog(activity, ErrorCodes.UPLOAD_PROBLEM);
}
} else if (error == ErrorCodes.INVALID_LOGIN) {
switch (error) {
case ErrorCodes.UPLOAD_CONFLICT:
UploadConflict.showDialog(activity, result);
break;
case ErrorCodes.INVALID_LOGIN:
InvalidLogin.showDialog(activity);
} else if (error == ErrorCodes.FORBIDDEN) {
break;
case ErrorCodes.FORBIDDEN:
ForbiddenLogin.showDialog(activity, result.getMessage());
} else if (error == ErrorCodes.BAD_REQUEST || error == ErrorCodes.NOT_FOUND || error == ErrorCodes.UNKNOWN_ERROR
|| error == ErrorCodes.UPLOAD_PROBLEM || error == ErrorCodes.UPLOAD_LIMIT_EXCEEDED) {
break;
case ErrorCodes.BAD_REQUEST:
case ErrorCodes.NOT_FOUND:
case ErrorCodes.UNKNOWN_ERROR:
case ErrorCodes.UPLOAD_PROBLEM:
case ErrorCodes.UPLOAD_LIMIT_EXCEEDED:
ErrorAlert.showDialog(activity, error, result.getMessage());
} else if (error != 0) {
break;
default:
ErrorAlert.showDialog(activity, error);
}
if (postUploadHandler != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/blau/android/osm/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ public void writeTo(BufferedSink sink) throws IOException {
private static final Pattern ERROR_MESSAGE_PRECONDITION_STILL_USED = Pattern
.compile("(?i)(?:Precondition failed: )?(Node|Way) ([0-9]+) is still used by (way|relation)[s]? ([0-9]+).*");
private static final Pattern ERROR_MESSAGE_PRECONDITION_REQUIRED_WAY_NODES = Pattern
.compile("(?i)(?:Precondition failed: )?Way ([0-9]+) requires the nodes with id in (([0-9]+,)+) which either do not exist, or are not visible.");
.compile("(?i)(?:Precondition failed: )?Way (-?[0-9]+) requires the nodes with id in (([0-9]+,)+) which either do not exist, or are not visible.");
private static final Pattern ERROR_MESSAGE_PRECONDITION_RELATION_RELATION = Pattern
.compile("(?i)(?:Precondition failed: )?The relation ([0-9]+) is used in relation ([0-9]+).");
public static final Pattern ERROR_MESSAGE_BAD_OAUTH_REQUEST = Pattern.compile("(?i)Bad OAuth request.*");
Expand Down

0 comments on commit b1c9972

Please sign in to comment.