mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix: Crash because of no file found error while uploading
This commit is contained in:
parent
461ca3add6
commit
16ee2b87ec
2 changed files with 15 additions and 2 deletions
|
|
@ -387,7 +387,12 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
public UploadResult uploadFile(String filename, InputStream file, long dataLength, String pageContents, String editSummary, final ProgressListener progressListener) throws IOException {
|
public UploadResult uploadFile(String filename,
|
||||||
|
@NonNull InputStream file,
|
||||||
|
long dataLength,
|
||||||
|
String pageContents,
|
||||||
|
String editSummary,
|
||||||
|
final ProgressListener progressListener) throws IOException {
|
||||||
ApiResult result = api.upload(filename, file, dataLength, pageContents, editSummary, progressListener::onProgress);
|
ApiResult result = api.upload(filename, file, dataLength, pageContents, editSummary, progressListener::onProgress);
|
||||||
|
|
||||||
Log.e("WTF", "Result: " + result.toString());
|
Log.e("WTF", "Result: " + result.toString());
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
private void uploadContribution(Contribution contribution) {
|
private void uploadContribution(Contribution contribution) {
|
||||||
MediaWikiApi api = app.getMWApi();
|
MediaWikiApi api = app.getMWApi();
|
||||||
|
|
||||||
InputStream file = null;
|
InputStream file;
|
||||||
|
|
||||||
String notificationTag = contribution.getLocalUri().toString();
|
String notificationTag = contribution.getLocalUri().toString();
|
||||||
|
|
||||||
|
|
@ -193,6 +193,14 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
Timber.d("File not found");
|
Timber.d("File not found");
|
||||||
Toast fileNotFound = Toast.makeText(this, R.string.upload_failed, Toast.LENGTH_LONG);
|
Toast fileNotFound = Toast.makeText(this, R.string.upload_failed, Toast.LENGTH_LONG);
|
||||||
fileNotFound.show();
|
fileNotFound.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//As the file is null there's no point in continuing the upload process
|
||||||
|
//mwapi.upload accepts a NonNull input stream
|
||||||
|
if(file == null) {
|
||||||
|
Timber.d("File not found");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.d("Before execution!");
|
Timber.d("Before execution!");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue