mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #31 from brion/upload-fail-fix
Fix for crash report if network down when upload starts
This commit is contained in:
commit
830545af9b
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