Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fec4c52a1 | ||
|
|
32182b592e | ||
|
|
bb7dc9a700 |
@@ -26,8 +26,8 @@ android {
|
||||
applicationId "com.example.androidbackupgui"
|
||||
minSdk 24
|
||||
targetSdk 34
|
||||
versionCode 6
|
||||
versionName "1.5"
|
||||
versionCode 9
|
||||
versionName "1.8"
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
|
||||
@@ -68,7 +68,7 @@ class RestBridgeRunner {
|
||||
val bridge = ResticRestBridge(transport, remoteBase, cacheDir)
|
||||
|
||||
try {
|
||||
bridge.start(300_000)
|
||||
bridge.start(0)
|
||||
val port = bridge.listeningPort
|
||||
if (port < 0) {
|
||||
throw IllegalStateException("REST bridge failed to bind a port")
|
||||
|
||||
@@ -110,13 +110,19 @@ class ResticRestBridge(
|
||||
* Returns the temp file (caller must delete).
|
||||
*/
|
||||
private fun streamBodyToFile(session: IHTTPSession, tmpDir: File): Result<File> {
|
||||
val started = System.currentTimeMillis()
|
||||
return try {
|
||||
val tmpFile = File(tmpDir, "restic_blob_${UUID.randomUUID()}")
|
||||
val input = (session as NanoHTTPD.HTTPSession).inputStream
|
||||
Log.d(TAG, "streamBodyToFile: reading body...")
|
||||
tmpFile.outputStream().use { output -> input.copyTo(output) }
|
||||
val elapsed = System.currentTimeMillis() - started
|
||||
val bytes = tmpFile.length()
|
||||
Log.i(TAG, "streamBodyToFile: read $bytes bytes in ${elapsed}ms")
|
||||
Result.success(tmpFile)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "stream body to file failed", e)
|
||||
val elapsed = System.currentTimeMillis() - started
|
||||
Log.w(TAG, "streamBodyToFile failed after ${elapsed}ms", e)
|
||||
Result.failure(e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user