Skip to content

Commit

Permalink
feat: support max running tasks config (GopeedLab#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie authored May 10, 2023
1 parent 1e08ecd commit d9c5ca3
Show file tree
Hide file tree
Showing 22 changed files with 268 additions and 128 deletions.
10 changes: 4 additions & 6 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
_ "embed"
"fmt"
"github.com/GopeedLab/gopeed/pkg/download"
"github.com/GopeedLab/gopeed/pkg/rest"
"github.com/GopeedLab/gopeed/pkg/rest/model"
"net/http"
Expand All @@ -20,18 +19,17 @@ func Start(cfg *model.StartConfig) {
if err != nil {
panic(err)
}
exist, _, err := rest.Downloader.GetConfig()
downloadCfg, err := rest.Downloader.GetConfig()
if err != nil {
panic(err)
}
if !exist {
if downloadCfg.FirstLoad {
// Set default download dir to user download dir
userDir, err := os.UserHomeDir()
if err == nil {
downloadDir := filepath.Join(userDir, "Downloads")
rest.Downloader.PutConfig(&download.DownloaderStoreConfig{
DownloadDir: downloadDir,
})
downloadCfg.DownloadDir = downloadDir
rest.Downloader.PutConfig(downloadCfg)
}

}
Expand Down
3 changes: 2 additions & 1 deletion pkg/base/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package base
type Status string

const (
DownloadStatusReady Status = "ready"
DownloadStatusReady Status = "ready" // task create but not start
DownloadStatusRunning Status = "running"
DownloadStatusPause Status = "pause"
DownloadStatusWait Status = "wait" // task is wait for running
DownloadStatusError Status = "error"
DownloadStatusDone Status = "done"
)
Expand Down
Loading

0 comments on commit d9c5ca3

Please sign in to comment.