[db] return error when trying to add archive repo

This commit is contained in:
Torsten Grote
2024-01-31 14:21:37 -03:00
parent 218a9ebb59
commit dec7c4d260
2 changed files with 10 additions and 2 deletions

View File

@@ -37,6 +37,7 @@ import org.fdroid.index.TempFileProvider
import org.fdroid.repo.AddRepoError.ErrorType.INVALID_FINGERPRINT
import org.fdroid.repo.AddRepoError.ErrorType.INVALID_INDEX
import org.fdroid.repo.AddRepoError.ErrorType.IO_ERROR
import org.fdroid.repo.AddRepoError.ErrorType.IS_ARCHIVE_REPO
import org.fdroid.repo.AddRepoError.ErrorType.UNKNOWN_SOURCES_DISALLOWED
import java.io.IOException
import java.net.Proxy
@@ -82,6 +83,7 @@ public data class AddRepoError(
public enum class ErrorType {
UNKNOWN_SOURCES_DISALLOWED,
INVALID_FINGERPRINT,
IS_ARCHIVE_REPO,
INVALID_INDEX,
IO_ERROR,
}
@@ -141,6 +143,10 @@ internal class RepoAdder(
addRepoState.value = AddRepoError(INVALID_INDEX, e)
return
}
if (nUri.uri.lastPathSegment == "archive") {
addRepoState.value = AddRepoError(IS_ARCHIVE_REPO)
return
}
// some plumping to receive the repo preview
var receivedRepo: Repository? = null

View File

@@ -49,10 +49,12 @@ internal object RepoUriGetter {
// do some path auto-adding, if it is missing
if (pathSegments.size >= 2 &&
pathSegments[pathSegments.lastIndex - 1] == "fdroid" &&
pathSegments.last() == "repo"
(pathSegments.last() == "repo" || pathSegments.last() == "archive")
) {
// path already is /fdroid/repo, use as is
} else if (pathSegments.lastOrNull() == "repo") {
} else if (pathSegments.lastOrNull() == "repo" ||
pathSegments.lastOrNull() == "archive"
) {
// path already ends in /repo, use as is
} else if (pathSegments.size >= 1 && pathSegments.last() == "fdroid") {
// path is /fdroid with missing /repo, so add that