mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix for crash report if network down when upload starts
Let the existing error handling detect the IOExceptions from the filename uniqueness check... this lets us fail gracefully.
This commit is contained in:
parent
8589aaab55
commit
c1191acd88
1 changed files with 7 additions and 11 deletions
|
|
@ -276,11 +276,11 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
contribution.save();
|
||||
}
|
||||
|
||||
private String findUniqueFilename(String fileName) {
|
||||
private String findUniqueFilename(String fileName) throws IOException {
|
||||
return findUniqueFilename(fileName, 1);
|
||||
}
|
||||
|
||||
private String findUniqueFilename(String fileName, int sequenceNumber) {
|
||||
private String findUniqueFilename(String fileName, int sequenceNumber) throws IOException {
|
||||
String sequenceFileName;
|
||||
if (sequenceNumber == 1) {
|
||||
sequenceFileName = fileName;
|
||||
|
|
@ -304,18 +304,14 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean fileExistsWithName(String fileName) {
|
||||
private boolean fileExistsWithName(String fileName) throws IOException {
|
||||
MWApi api = app.getApi();
|
||||
ApiResult result;
|
||||
|
||||
try {
|
||||
result = api.action("query")
|
||||
.param("prop", "imageinfo")
|
||||
.param("titles", "File:" + fileName)
|
||||
.get();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ArrayList<ApiResult> nodes = result.getNodes("/api/query/pages/page/imageinfo");
|
||||
return nodes.size() > 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue