Assign links outside repair
This commit is contained in:
@@ -26,6 +26,7 @@ type RootResponse struct {
|
|||||||
Infuse string `json:"infuse"`
|
Infuse string `json:"infuse"`
|
||||||
Logs string `json:"logs"`
|
Logs string `json:"logs"`
|
||||||
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
|
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
|
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
|
||||||
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
|
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
|
||||||
Sys uint64 `json:"sys"` // System memory in MB
|
Sys uint64 `json:"sys"` // System memory in MB
|
||||||
@@ -47,20 +48,23 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
|||||||
var mem runtime.MemStats
|
var mem runtime.MemStats
|
||||||
runtime.ReadMemStats(&mem)
|
runtime.ReadMemStats(&mem)
|
||||||
|
|
||||||
|
allTorrents, _ := zr.torMgr.DirectoryMap.Get(config.ALL_TORRENTS)
|
||||||
|
|
||||||
response := RootResponse{
|
response := RootResponse{
|
||||||
Version: version.GetVersion(),
|
Version: version.GetVersion(),
|
||||||
BuiltAt: version.GetBuiltAt(),
|
BuiltAt: version.GetBuiltAt(),
|
||||||
GitCommit: version.GetGitCommit(),
|
GitCommit: version.GetGitCommit(),
|
||||||
Html: fmt.Sprintf("//%s/http/", req.Host),
|
Html: fmt.Sprintf("//%s/http/", req.Host),
|
||||||
Dav: fmt.Sprintf("//%s/dav/", req.Host),
|
Dav: fmt.Sprintf("//%s/dav/", req.Host),
|
||||||
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
|
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
|
||||||
Logs: fmt.Sprintf("//%s/logs/", req.Host),
|
Logs: fmt.Sprintf("//%s/logs/", req.Host),
|
||||||
UserInfo: userInfo,
|
UserInfo: userInfo,
|
||||||
MemAlloc: bToMb(mem.Alloc),
|
LibrarySize: allTorrents.Count(),
|
||||||
TotalAlloc: bToMb(mem.TotalAlloc),
|
MemAlloc: bToMb(mem.Alloc),
|
||||||
Sys: bToMb(mem.Sys),
|
TotalAlloc: bToMb(mem.TotalAlloc),
|
||||||
NumGC: mem.NumGC,
|
Sys: bToMb(mem.Sys),
|
||||||
PID: os.Getpid(),
|
NumGC: mem.NumGC,
|
||||||
|
PID: os.Getpid(),
|
||||||
Sponsor: SponsorResponse{
|
Sponsor: SponsorResponse{
|
||||||
Patreon: "https://www.patreon.com/debridmediamanager",
|
Patreon: "https://www.patreon.com/debridmediamanager",
|
||||||
Github: "https://github.com/sponsors/debridmediamanager",
|
Github: "https://github.com/sponsors/debridmediamanager",
|
||||||
@@ -103,6 +107,10 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
|||||||
<td>Logs</td>
|
<td>Logs</td>
|
||||||
<td colspan="2"><a href="%s">%s</a></td>
|
<td colspan="2"><a href="%s">%s</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Library Size</td>
|
||||||
|
<td colspan="2">%d items</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Memory Allocation</td>
|
<td>Memory Allocation</td>
|
||||||
<td colspan="2">%d MB</td>
|
<td colspan="2">%d MB</td>
|
||||||
@@ -162,7 +170,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
|||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="23">Config</td>
|
<td rowspan="22">Config</td>
|
||||||
<td>Version</td>
|
<td>Version</td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -298,6 +306,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
|||||||
response.Infuse,
|
response.Infuse,
|
||||||
response.Logs,
|
response.Logs,
|
||||||
response.Logs,
|
response.Logs,
|
||||||
|
response.LibrarySize,
|
||||||
response.MemAlloc,
|
response.MemAlloc,
|
||||||
response.TotalAlloc,
|
response.TotalAlloc,
|
||||||
response.Sys,
|
response.Sys,
|
||||||
|
|||||||
@@ -156,6 +156,14 @@ func (t *TorrentManager) refreshTorrents() []string {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.workerPool.Submit(func() {
|
||||||
|
allTorrents.IterCb(func(accessKey string, torrent *Torrent) {
|
||||||
|
if torrent.UnassignedLinks.Cardinality() > 0 {
|
||||||
|
t.assignLinks(torrent)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
return updatedPaths.ToSlice()
|
return updatedPaths.ToSlice()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,10 +164,6 @@ func (t *TorrentManager) Repair(torrent *Torrent, wg *sync.WaitGroup) {
|
|||||||
func (t *TorrentManager) repair(torrent *Torrent) {
|
func (t *TorrentManager) repair(torrent *Torrent) {
|
||||||
t.repairLog.Infof("Started repair process for torrent %s (ids=%v)", t.GetKey(torrent), torrent.DownloadedIDs.ToSlice())
|
t.repairLog.Infof("Started repair process for torrent %s (ids=%v)", t.GetKey(torrent), torrent.DownloadedIDs.ToSlice())
|
||||||
|
|
||||||
if torrent.UnassignedLinks.Cardinality() > 0 && !t.assignLinks(torrent) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for other broken files
|
// check for other broken files
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
if !file.State.Is("ok_file") {
|
if !file.State.Is("ok_file") {
|
||||||
|
|||||||
@@ -366,12 +366,12 @@ func (rd *RealDebrid) GetDownloads() []Download {
|
|||||||
// reset allDownloads
|
// reset allDownloads
|
||||||
allDownloads := []Download{}
|
allDownloads := []Download{}
|
||||||
page := 1
|
page := 1
|
||||||
limit := 100
|
limit := 250
|
||||||
|
|
||||||
// compute ceiling of totalCount / limit
|
// compute ceiling of totalCount / limit
|
||||||
maxPages := (totalCount + limit - 1) / limit
|
maxPages := (totalCount + limit - 1) / limit
|
||||||
rd.log.Debugf("Total downloads count is %d", totalCount)
|
rd.log.Debugf("Total downloads count is %d", totalCount)
|
||||||
maxParallelThreads := 8
|
maxParallelThreads := 4
|
||||||
if maxPages < maxParallelThreads {
|
if maxPages < maxParallelThreads {
|
||||||
maxParallelThreads = maxPages
|
maxParallelThreads = maxPages
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user