Dump torrents job

This commit is contained in:
Ben Sarmiento
2024-05-26 03:49:16 +02:00
parent 249eebbea9
commit 17059e6a4a
5 changed files with 114 additions and 9 deletions

View File

@@ -163,7 +163,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
<td>%s</td>
</tr>
<tr>
<td rowspan="22">Config</td>
<td rowspan="23">Config</td>
<td>Version</td>
<td>%s</td>
</tr>
@@ -223,6 +223,14 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
<td>Refresh Download Mount Every...</td>
<td>%d mins</td>
</tr>
<tr>
<td>Get downloads limit</td>
<td>%d items</td>
</tr>
<tr>
<td>Dump Torrents Every...</td>
<td>%d mins</td>
</tr>
<tr>
<td>Rate Limit Sleep for...</td>
<td>%d secs</td>
@@ -273,6 +281,9 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
<form method="post" action="/remount/downloads">
<input type="submit" value="Remount downloads" />
</form>
<form method="post" action="/dump/torrents">
<input type="submit" value="Dump torrents" />
</form>
</td>
</tr>
</table>
@@ -323,6 +334,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
response.Config.GetTorrentsCount(),
response.Config.GetDownloadTimeoutSecs(),
response.Config.GetDownloadsEveryMins(),
response.Config.GetDownloadsLimit(),
response.Config.GetDumpTorrentsEveryMins(),
response.Config.GetRateLimitSleepSecs(),
response.Config.GetRetriesUntilFailed(),
response.Config.GetNetworkBufferSize(),
@@ -367,6 +380,13 @@ func (zr *Handlers) handleRemountDownloads(resp http.ResponseWriter, req *http.R
fmt.Fprint(resp, "Remounting downloads...")
}
func (zr *Handlers) handleDumpTorrents(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("Refresh", "2; url=/")
zr.torMgr.DumpTrigger <- struct{}{}
zr.log.Infof("Triggered dump of torrents")
fmt.Fprint(resp, "Dumping torrents...")
}
func bToMb(b uint64) uint64 {
return b / 1024 / 1024
}