Repair enqueque
This commit is contained in:
@@ -18,24 +18,25 @@ type SponsorResponse struct {
|
||||
Paypal string `json:"paypal"`
|
||||
}
|
||||
type RootResponse struct {
|
||||
Version string `json:"version"`
|
||||
BuiltAt string `json:"built_at"`
|
||||
GitCommit string `json:"git_commit"`
|
||||
Html string `json:"html"`
|
||||
Dav string `json:"dav"`
|
||||
Infuse string `json:"infuse"`
|
||||
Logs string `json:"logs"`
|
||||
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
|
||||
LibrarySize int `json:"library_size"` // Number of torrents in the library
|
||||
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
|
||||
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
|
||||
Sys uint64 `json:"sys"` // System memory in MB
|
||||
NumGC uint32 `json:"num_gc"` // Number of completed GC cycles
|
||||
PID int `json:"pid"` // Process ID
|
||||
Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links
|
||||
Config config.ZurgConfig `json:"config"`
|
||||
ImmediateBin []string `json:"immediate_bin"`
|
||||
OnceDoneBin []string `json:"once_done_bin"`
|
||||
Version string `json:"version"`
|
||||
BuiltAt string `json:"built_at"`
|
||||
GitCommit string `json:"git_commit"`
|
||||
Html string `json:"html"`
|
||||
Dav string `json:"dav"`
|
||||
Infuse string `json:"infuse"`
|
||||
Logs string `json:"logs"`
|
||||
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
|
||||
LibrarySize int `json:"library_size"` // Number of torrents in the library
|
||||
RepairQueueStr string `json:"repair_queue"` // List of torrents in the repair queue
|
||||
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
|
||||
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
|
||||
Sys uint64 `json:"sys"` // System memory in MB
|
||||
NumGC uint32 `json:"num_gc"` // Number of completed GC cycles
|
||||
PID int `json:"pid"` // Process ID
|
||||
Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links
|
||||
Config config.ZurgConfig `json:"config"`
|
||||
ImmediateBin []string `json:"immediate_bin"`
|
||||
OnceDoneBin []string `json:"once_done_bin"`
|
||||
}
|
||||
|
||||
func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
@@ -50,21 +51,37 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
|
||||
allTorrents, _ := zr.torMgr.DirectoryMap.Get(config.ALL_TORRENTS)
|
||||
|
||||
repairQueueStr := ""
|
||||
if zr.torMgr.RepairQueue == nil {
|
||||
repairQueueStr = "repair is disabled"
|
||||
} else if zr.torMgr.RepairQueue.IsEmpty() {
|
||||
repairQueueStr = "empty"
|
||||
} else {
|
||||
for _, torrent := range zr.torMgr.RepairQueue.ToSlice() {
|
||||
if torrent == nil {
|
||||
repairQueueStr += " ⬅ 'all torrents'"
|
||||
} else {
|
||||
repairQueueStr += fmt.Sprintf(" ⬅ %s", zr.torMgr.GetKey(torrent))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response := RootResponse{
|
||||
Version: version.GetVersion(),
|
||||
BuiltAt: version.GetBuiltAt(),
|
||||
GitCommit: version.GetGitCommit(),
|
||||
Html: fmt.Sprintf("//%s/http/", req.Host),
|
||||
Dav: fmt.Sprintf("//%s/dav/", req.Host),
|
||||
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
|
||||
Logs: fmt.Sprintf("//%s/logs/", req.Host),
|
||||
UserInfo: userInfo,
|
||||
LibrarySize: allTorrents.Count(),
|
||||
MemAlloc: bToMb(mem.Alloc),
|
||||
TotalAlloc: bToMb(mem.TotalAlloc),
|
||||
Sys: bToMb(mem.Sys),
|
||||
NumGC: mem.NumGC,
|
||||
PID: os.Getpid(),
|
||||
Version: version.GetVersion(),
|
||||
BuiltAt: version.GetBuiltAt(),
|
||||
GitCommit: version.GetGitCommit(),
|
||||
Html: fmt.Sprintf("//%s/http/", req.Host),
|
||||
Dav: fmt.Sprintf("//%s/dav/", req.Host),
|
||||
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
|
||||
Logs: fmt.Sprintf("//%s/logs/", req.Host),
|
||||
UserInfo: userInfo,
|
||||
LibrarySize: allTorrents.Count(),
|
||||
RepairQueueStr: repairQueueStr,
|
||||
MemAlloc: bToMb(mem.Alloc),
|
||||
TotalAlloc: bToMb(mem.TotalAlloc),
|
||||
Sys: bToMb(mem.Sys),
|
||||
NumGC: mem.NumGC,
|
||||
PID: os.Getpid(),
|
||||
Sponsor: SponsorResponse{
|
||||
Patreon: "https://www.patreon.com/debridmediamanager",
|
||||
Github: "https://github.com/sponsors/debridmediamanager",
|
||||
@@ -111,6 +128,10 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
<td>Library Size</td>
|
||||
<td colspan="2">%d items</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Repair Queue</td>
|
||||
<td colspan="2">%s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Memory Allocation</td>
|
||||
<td colspan="2">%d MB</td>
|
||||
@@ -262,8 +283,21 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
<td>Utilities</td>
|
||||
<td colspan="2">
|
||||
<form method="get" action="/logs/upload">
|
||||
<input type="submit" value="Upload logs" />
|
||||
<input type="submit" value="Upload logs" /> Share the link to get help
|
||||
</form>
|
||||
<form method="post" action="/torrents/dump">
|
||||
<input type="submit" value="Dump torrents" /> Copy all your zurgtorrent files to your dump folder
|
||||
</form>
|
||||
<form method="post" action="/torrents/analyze">
|
||||
<input type="submit" value="Analyze torrents" /> Required to use media_info_* filters
|
||||
</form>
|
||||
<form method="post" action="/torrents/repair">
|
||||
<input type="submit" value="Repair torrents" /> Trigger repair of all torrents
|
||||
</form>
|
||||
</td>
|
||||
<tr>
|
||||
<td>Debug</td>
|
||||
<td colspan="2">
|
||||
<form method="post" action="/reboot-worker">
|
||||
<input type="submit" value="Reboot worker pool" />
|
||||
</form>
|
||||
@@ -276,15 +310,6 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
<form method="post" action="/downloads/remount">
|
||||
<input type="submit" value="Remount downloads" />
|
||||
</form>
|
||||
<form method="post" action="/torrents/dump">
|
||||
<input type="submit" value="Dump torrents" />
|
||||
</form>
|
||||
<form method="post" action="/torrents/analyze">
|
||||
<input type="submit" value="Analyze torrents" />
|
||||
</form>
|
||||
<form method="post" action="/torrents/repair">
|
||||
<input type="submit" value="Repair torrents" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -302,6 +327,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
response.Logs,
|
||||
response.Logs,
|
||||
response.LibrarySize,
|
||||
response.RepairQueueStr,
|
||||
response.MemAlloc,
|
||||
response.TotalAlloc,
|
||||
response.Sys,
|
||||
@@ -395,7 +421,7 @@ func (zr *Handlers) handleAnalyzeTorrents(resp http.ResponseWriter, req *http.Re
|
||||
|
||||
func (zr *Handlers) handleTriggerRepairAll(resp http.ResponseWriter, req *http.Request) {
|
||||
resp.Header().Set("Refresh", "2; url=/")
|
||||
zr.torMgr.RepairAllTrigger <- struct{}{}
|
||||
zr.torMgr.EnqueueForRepair(nil)
|
||||
zr.log.Infof("Triggered repair of all torrents")
|
||||
fmt.Fprint(resp, "Repairing all torrents...")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user