mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
feat(remote download): show download node in list page
This commit is contained in:
@@ -27,6 +27,13 @@ type DownloadListService struct {
|
||||
func (service *DownloadListService) Finished(c *gin.Context, user *model.User) serializer.Response {
|
||||
// 查找下载记录
|
||||
downloads := model.GetDownloadsByStatusAndUser(service.Page, user.ID, common.Error, common.Complete, common.Canceled, common.Unknown)
|
||||
for key, download := range downloads {
|
||||
node := cluster.Default.GetNodeByID(download.GetNodeID())
|
||||
if node != nil {
|
||||
downloads[key].NodeName = node.DBModel().Name
|
||||
}
|
||||
}
|
||||
|
||||
return serializer.BuildFinishedListResponse(downloads)
|
||||
}
|
||||
|
||||
@@ -35,12 +42,17 @@ func (service *DownloadListService) Downloading(c *gin.Context, user *model.User
|
||||
// 查找下载记录
|
||||
downloads := model.GetDownloadsByStatusAndUser(service.Page, user.ID, common.Downloading, common.Seeding, common.Paused, common.Ready)
|
||||
intervals := make(map[uint]int)
|
||||
for _, download := range downloads {
|
||||
for key, download := range downloads {
|
||||
if _, ok := intervals[download.ID]; !ok {
|
||||
if node := cluster.Default.GetNodeByID(download.GetNodeID()); node != nil {
|
||||
intervals[download.ID] = node.DBModel().Aria2OptionsSerialized.Interval
|
||||
}
|
||||
}
|
||||
|
||||
node := cluster.Default.GetNodeByID(download.GetNodeID())
|
||||
if node != nil {
|
||||
downloads[key].NodeName = node.DBModel().Name
|
||||
}
|
||||
}
|
||||
|
||||
return serializer.BuildDownloadingResponse(downloads, intervals)
|
||||
|
||||
Reference in New Issue
Block a user