Skip to content

Commit

Permalink
fix(client): use submitForm instead of get requests in some methods (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Garg authored Mar 3, 2023
1 parent 67fc689 commit 7d2f97f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId = "dev.yashgarg.qbit"
minSdk = 24
targetSdk = 33
versionCode = 10
versionName = "v0.2.$versionCode-$commitHash"
versionCode = 11
versionName = "v0.2.0-$commitHash"

multiDexEnabled = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
28 changes: 16 additions & 12 deletions client-wrapper/client/src/commonMain/kotlin/QBittorrentClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,10 @@ class QBittorrentClient(
@Throws(QBittorrentException::class, CancellationException::class)
suspend fun pauseTorrents(hashes: List<String> = allList) {
http
.get("${config.baseUrl}/api/v2/torrents/pause") {
parameter("hashes", hashes.joinToString("|"))
}
.submitForm(
"${config.baseUrl}/api/v2/torrents/pause",
formParameters = Parameters.build { append("hashes", hashes.joinToString("|")) }
)
.orThrow()
}

Expand All @@ -381,9 +382,10 @@ class QBittorrentClient(
@Throws(QBittorrentException::class, CancellationException::class)
suspend fun resumeTorrents(hashes: List<String> = allList) {
http
.get("${config.baseUrl}/api/v2/torrents/resume") {
parameter("hashes", hashes.joinToString("|"))
}
.submitForm(
"${config.baseUrl}/api/v2/torrents/resume",
formParameters = Parameters.build { append("hashes", hashes.joinToString("|")) }
)
.orThrow()
}

Expand Down Expand Up @@ -411,19 +413,21 @@ class QBittorrentClient(
@Throws(QBittorrentException::class, CancellationException::class)
suspend fun recheckTorrents(hashes: List<String> = allList) {
http
.get("${config.baseUrl}/api/v2/torrents/recheck") {
parameter("hashes", hashes.joinToString("|"))
}
.submitForm(
"${config.baseUrl}/api/v2/torrents/recheck",
formParameters = Parameters.build { append("hashes", hashes.joinToString("|")) }
)
.orThrow()
}

/** Reannounce a torrent. */
@Throws(QBittorrentException::class, CancellationException::class)
suspend fun reannounceTorrents(hashes: List<String> = allList) {
http
.get("${config.baseUrl}/api/v2/torrents/reannounce") {
parameter("hashes", hashes.joinToString("|"))
}
.submitForm(
"${config.baseUrl}/api/v2/torrents/reannounce",
formParameters = Parameters.build { append("hashes", hashes.joinToString("|")) }
)
.orThrow()
}

Expand Down

0 comments on commit 7d2f97f

Please sign in to comment.