Skip to content

Commit

Permalink
Merge pull request #857 from grote/davx-webdav-improvements
Browse files Browse the repository at this point in the history
Several assorted improvements
  • Loading branch information
grote authored Feb 13, 2025
2 parents 4fd962a + 61043ee commit 6945a10
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 11 deletions.
11 changes: 6 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
SPDX-FileCopyrightText: 2017-2019 Steve Soltys
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -73,7 +72,8 @@
tools:ignore="ProtectedPermissions" />

<!-- Used to get the name of the current profile -->
<uses-permission android:name="android.permission.QUERY_USERS"
<uses-permission
android:name="android.permission.QUERY_USERS"
tools:ignore="ProtectedPermissions" />

<!-- Used for periodic storage backups -->
Expand All @@ -94,6 +94,7 @@
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
Expand Down Expand Up @@ -134,11 +135,11 @@
<activity
android:name=".ui.check.AppCheckResultActivity"
android:label="@string/notification_checking_finished_title"
android:launchMode="singleTask"/>
android:launchMode="singleTask" />

<activity
android:name=".ui.check.FileCheckResultActivity"
android:launchMode="singleTask"/>
android:launchMode="singleTask" />

<service
android:name=".transport.ConfigurableBackupTransportService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ internal class RestoreViewModel(

internal fun loadRestoreSets() = viewModelScope.launch(ioDispatcher) {
val result = when (val backups = restoreCoordinator.getAvailableBackups()) {
is ErrorResult -> RestoreSetResult(
app.getString(R.string.restore_set_error) + "\n\n${backups.e}"
)
is ErrorResult -> {
val msg = if (backups.e == null) {
app.getString(R.string.restore_set_empty_result)
} else {
app.getString(R.string.restore_set_error) + "\n\n${backups.e}"
}
RestoreSetResult(msg)
}
is SuccessResult -> RestoreSetResult(backups.backups)
}
mRestoreSetResults.postValue(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class SettingsManager(private val context: Context) {
prefs.edit().putStringSet(PREF_KEY_BACKUP_APP_BLACKLIST, blacklistedApps).apply()
}

val quota: Long = 1024 * 1024 * 1024 // 1 GiB for now
val quota: Long = 3L * 1024 * 1024 * 1024 // 3 GiB for now

/**
* This assumes that if there's no storage plugin set, it is the first start.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ internal class BackupNotificationManager(private val context: Context) {
setProgress(0, 0, false)
priority = PRIORITY_LOW
}.build()
Log.i(TAG, "Canceling NOTIFICATION_ID_OBSERVER")
nm.cancel(NOTIFICATION_ID_OBSERVER)
nm.notify(NOTIFICATION_ID_SUCCESS, notification)
}
Expand All @@ -243,6 +244,7 @@ internal class BackupNotificationManager(private val context: Context) {
setProgress(0, 0, false)
priority = PRIORITY_LOW
}.build()
Log.i(TAG, "Canceling NOTIFICATION_ID_OBSERVER")
nm.cancel(NOTIFICATION_ID_OBSERVER)
nm.notify(NOTIFICATION_ID_ERROR, notification)
}
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?><!--
SPDX-FileCopyrightText: 2025 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<network-security-config xmlns:tools="http://schemas.android.com/tools">
<base-config cleartextTrafficPermitted="false">
<trust-anchors>
<!-- Trust preinstalled CAs -->
<certificates src="system" />
<!-- Additionally trust user added CAs -->
<certificates
src="user"
tools:ignore="AcceptsUserCertificates" />
</trust-anchors>
</base-config>
</network-security-config>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ internal class RetryBackend(private val delegate: Backend) : Backend {
delay(newDelayMs)
return retry(newRetries, newDelayMs, block)
} else {
log.warn { "Last retry reached, throwing exception..." }
throw e
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ internal fun DavCollection.ensureFoldersExist(log: KLogger, folders: MutableSet<
if (parent in folders) return
val parentCollection = DavCollection(httpClient, parent)
try {
parentCollection.head { response ->
log.debugLog { "head($parent) = $response" }
parentCollection.propfind(
depth = 0,
reqProp = arrayOf(DisplayName.NAME, ResourceType.NAME),
) { response, relation ->
log.debugLog { "propfind(0, $parent) = $response $relation" }
folders.add(parent)
}
} catch (e: NotFoundException) {
Expand Down

0 comments on commit 6945a10

Please sign in to comment.