load balancer implementation, code refactoring

This commit is contained in:
2024-05-20 08:48:01 +02:00
parent fee7f86182
commit 472db89ea3
9 changed files with 122 additions and 29 deletions

View File

@@ -125,6 +125,8 @@ func (p *Process) Start() {
p.proc = cmd.Process
go p.SetMetadata()
// --------------- progress block --------------- //
var (
sourceChan = make(chan []byte)
@@ -139,7 +141,9 @@ func (p *Process) Start() {
defer func() {
r.Close()
p.Complete()
doneChan <- struct{}{}
close(sourceChan)
close(doneChan)
}()
@@ -215,6 +219,7 @@ func (p *Process) Kill() error {
}
// Returns the available format for this URL
// TODO: Move out from process.go
func (p *Process) GetFormatsSync() (DownloadFormats, error) {
cmd := exec.Command(config.Instance().DownloaderPath, p.Url, "-J")
@@ -356,9 +361,7 @@ func (p *Process) SetMetadata() error {
return nil
}
func (p *Process) getShortId() string {
return strings.Split(p.Id, "-")[0]
}
func (p *Process) getShortId() string { return strings.Split(p.Id, "-")[0] }
func buildFilename(o *DownloadOutput) {
if o.Filename != "" && strings.Contains(o.Filename, ".%(ext)s") {