Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c320094b authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Service detection: ignore HTTP 4xx errors when looking for homesets

parent 5b120153
Loading
Loading
Loading
Loading
+33 −16
Original line number Diff line number Diff line
@@ -181,8 +181,11 @@ class DavService: Service() {

            /**
             * Checks if the given URL defines home sets and adds them to the home set list.
             *
             * @throws IOException
             * @throws HttpException
             * @throws DavException
             */
            @Throws(IOException::class, HttpException::class, DavException::class)
            fun queryHomeSets(client: OkHttpClient, url: HttpUrl, recurse: Boolean = true) {
                var related = setOf<HttpUrl>()

@@ -219,25 +222,39 @@ class DavService: Service() {
                val dav = DavResource(client, url)
                when (serviceType) {
                    Services.SERVICE_CARDDAV ->
                        try {
                            dav.propfind(0, AddressbookHomeSet.NAME, GroupMembership.NAME) { response, _ ->
                            response[AddressbookHomeSet::class.java]?.let {
                                for (href in it.hrefs)
                                response[AddressbookHomeSet::class.java]?.let { homeSet ->
                                    for (href in homeSet.hrefs)
                                        dav.location.resolve(href)?.let { homeSets += UrlUtils.withTrailingSlash(it) }
                                }

                                if (recurse)
                                    findRelated(dav.location, response)
                            }
                        } catch (e: HttpException) {
                            if (e.code/100 == 4)
                                Logger.log.log(Level.INFO, "Ignoring Client Error 4xx while looking for addressbook home sets", e)
                            else
                                throw e
                        }
                    Services.SERVICE_CALDAV -> {
                        try {
                            dav.propfind(0, CalendarHomeSet.NAME, CalendarProxyReadFor.NAME, CalendarProxyWriteFor.NAME, GroupMembership.NAME) { response, _ ->
                            response[CalendarHomeSet::class.java]?.let {
                                for (href in it.hrefs)
                                response[CalendarHomeSet::class.java]?.let { homeSet ->
                                    for (href in homeSet.hrefs)
                                        dav.location.resolve(href)?.let { homeSets.add(UrlUtils.withTrailingSlash(it)) }
                                }

                                if (recurse)
                                    findRelated(dav.location, response)
                            }
                        } catch (e: HttpException) {
                            if (e.code/100 == 4)
                                Logger.log.log(Level.INFO, "Ignoring Client Error 4xx while looking for calendar home sets", e)
                            else
                                throw e
                        }
                    }
                }

Compare a477313f to 10abc3ec
Original line number Diff line number Diff line
Subproject commit a477313f75d169072a80e4bfce8a95f990f00c30
Subproject commit 10abc3ec7989214f17e5448d2289f03135670031