Skip to content

Commit a845585

Browse files
committed
docs: add notes in UploadWorker for where we need to determine the error
1 parent 55346c1 commit a845585

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/src/main/java/fr/free/nrw/commons/upload/worker/UploadWorker.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
300300
if (contribution.localUri == null || contribution.localUri.path == null) {
301301
Timber.e("""upload: ${contribution.media.filename} failed, file path is null""")
302302
}
303+
// FP: this is an obvious genuine failure point
303304

304305
val media = contribution.media
305306
val displayTitle = contribution.media.displayTitle
@@ -377,6 +378,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
377378
showSuccessNotification(contribution)
378379

379380
} else {
381+
// FP: Here is a much more ambiguous failure point
380382
Timber.e("Stash Upload failed")
381383
showFailedNotification(contribution)
382384
contribution.state = Contribution.STATE_FAILED
@@ -385,6 +387,9 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
385387

386388
}
387389
}catch (exception : Exception){
390+
// FP: Exception in upload from stash.
391+
// Ambiguous in the sense that it is hard to determine from code, but we
392+
// at least have an exception to work with
388393
Timber.e(exception)
389394
Timber.e("Upload from stash failed for contribution : $filename")
390395
showFailedNotification(contribution)
@@ -401,6 +406,8 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
401406
contributionDao.saveSynchronous(contribution)
402407
}
403408
else -> {
409+
// FP: Error in upload to stash.
410+
// have a stashUploadResult to work with
404411
Timber.e("""upload file to stash failed with status: ${stashUploadResult.state}""")
405412
showFailedNotification(contribution)
406413
contribution.state = Contribution.STATE_FAILED
@@ -409,6 +416,9 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
409416
}
410417
}
411418
}catch (exception: Exception){
419+
// FP: Exception in upload to stash.
420+
// Ambiguous in the sense that it is hard to determine from code, but we
421+
// at least have an exception to work with
412422
Timber.e(exception)
413423
Timber.e("Stash upload failed for contribution: $filename")
414424
showFailedNotification(contribution)

0 commit comments

Comments
 (0)