mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-05-18 21:47:37 -04:00
Explicitly bubble up NotFoundException to UI
Otherwise, the UI might not catch it and crash. This can happen if a file is not available anymore on all mirrors.
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
ddb6d46b6f
commit
ddabd8375b
@@ -20,6 +20,7 @@ import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import org.fdroid.database.Repository;
|
||||
import org.fdroid.download.Downloader;
|
||||
import org.fdroid.download.NotFoundException;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.NotificationHelper;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
@@ -129,7 +130,7 @@ public class SwapService extends Service {
|
||||
}
|
||||
|
||||
private void updateRepo(@NonNull Peer peer, Repository repo)
|
||||
throws IOException, InterruptedException, SigningException {
|
||||
throws IOException, InterruptedException, SigningException, NotFoundException {
|
||||
Uri uri = Uri.parse(repo.getAddress()).buildUpon().appendPath("index-v1.jar").build();
|
||||
FileV2 indexFile = FileV2.fromPath("/index-v1.jar");
|
||||
File swapJarFile =
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.util.LogPrinter;
|
||||
import org.fdroid.database.FDroidDatabase;
|
||||
import org.fdroid.database.Repository;
|
||||
import org.fdroid.download.Downloader;
|
||||
import org.fdroid.download.NotFoundException;
|
||||
import org.fdroid.fdroid.BuildConfig;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.ProgressListener;
|
||||
@@ -284,7 +285,7 @@ public class DownloaderService extends Service {
|
||||
sendBroadcast(uri, DownloaderService.ACTION_INTERRUPTED, localFile, repoId, canonicalUrl);
|
||||
} catch (ConnectException | HttpRetryException | NoRouteToHostException | SocketTimeoutException
|
||||
| SSLHandshakeException | SSLKeyException | SSLPeerUnverifiedException | SSLProtocolException
|
||||
| ProtocolException | UnknownHostException e) {
|
||||
| ProtocolException | UnknownHostException | NotFoundException e) {
|
||||
// if the above list of exceptions changes, also change it in IndexV1Updater.update()
|
||||
Log.e(TAG, "CONNECTION_FAILED: " + e.getLocalizedMessage());
|
||||
sendBroadcast(uri, DownloaderService.ACTION_CONNECTION_FAILED, localFile, repoId, canonicalUrl);
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class Downloader constructor(
|
||||
* Call this to start the download.
|
||||
* Never call this more than once. Create a new [Downloader], if you need to download again!
|
||||
*/
|
||||
@Throws(IOException::class, InterruptedException::class)
|
||||
@Throws(IOException::class, InterruptedException::class, NotFoundException::class)
|
||||
public abstract fun download()
|
||||
|
||||
@Throws(IOException::class, NotFoundException::class)
|
||||
@@ -92,7 +92,12 @@ public abstract class Downloader constructor(
|
||||
}
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
@Throws(InterruptedException::class, IOException::class, NoResumeException::class)
|
||||
@Throws(
|
||||
InterruptedException::class,
|
||||
IOException::class,
|
||||
NoResumeException::class,
|
||||
NotFoundException::class,
|
||||
)
|
||||
protected suspend fun downloadFromBytesReceiver(isResume: Boolean) {
|
||||
try {
|
||||
val messageDigest: MessageDigest? = if (indexFile.sha256 == null) null else {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class HttpDownloader constructor(
|
||||
throw NotImplementedError("Use getInputStreamSuspend instead.")
|
||||
}
|
||||
|
||||
@Throws(IOException::class, NoResumeException::class)
|
||||
@Throws(IOException::class, NoResumeException::class, NotFoundException::class)
|
||||
protected override suspend fun getBytes(resumable: Boolean, receiver: BytesReceiver) {
|
||||
val skipBytes = if (resumable) outputFile.length() else null
|
||||
return try {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class HttpDownloaderV2 constructor(
|
||||
throw NotImplementedError("Use getInputStreamSuspend instead.")
|
||||
}
|
||||
|
||||
@Throws(IOException::class, NoResumeException::class)
|
||||
@Throws(IOException::class, NoResumeException::class, NotFoundException::class)
|
||||
protected override suspend fun getBytes(resumable: Boolean, receiver: BytesReceiver) {
|
||||
val skipBytes = if (resumable) outputFile.length() else null
|
||||
return try {
|
||||
@@ -57,7 +57,7 @@ public class HttpDownloaderV2 constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(IOException::class, InterruptedException::class)
|
||||
@Throws(IOException::class, InterruptedException::class, NotFoundException::class)
|
||||
public override fun download() {
|
||||
var resumable = false
|
||||
val fileLength = outputFile.length()
|
||||
|
||||
@@ -91,6 +91,7 @@ public open class HttpManager @JvmOverloads constructor(
|
||||
* This is useful for checking if the repository index has changed before downloading it again.
|
||||
* However, due to non-standard ETags on mirrors, change detection is unreliable.
|
||||
*/
|
||||
@Throws(NotFoundException::class)
|
||||
public suspend fun head(request: DownloadRequest, eTag: String? = null): HeadInfo? {
|
||||
val response: HttpResponse = try {
|
||||
mirrorChooser.mirrorRequest(request) { mirror, url ->
|
||||
|
||||
Reference in New Issue
Block a user