prevent completed download restart

This commit is contained in:
2024-07-02 11:37:06 +02:00
parent 98f0ea3bd2
commit 3edebbdb6c
4 changed files with 34 additions and 20 deletions

View File

@@ -65,7 +65,9 @@ func (m *MessageQueue) downloadConsumer() {
slog.String("id", p.getShortId()),
)
p.Start()
if p.Progress.Status != StatusCompleted {
p.Start()
}
m.logger.Info("started process",
slog.String("bus", queueName),
@@ -92,6 +94,14 @@ func (m *MessageQueue) metadataSubscriber() {
slog.String("id", p.getShortId()),
)
if p.Progress.Status == StatusCompleted {
m.logger.Warn("proccess has an illegal state",
slog.String("id", p.getShortId()),
slog.Int("status", p.Progress.Status),
)
return
}
if err := p.SetMetadata(); err != nil {
m.logger.Error("failed to retrieve metadata",
slog.String("id", p.getShortId()),

View File

@@ -198,6 +198,9 @@ func (p *Process) Complete() {
// Kill a process and remove it from the memory
func (p *Process) Kill() error {
defer func() {
p.Progress.Status = StatusCompleted
}()
// yt-dlp uses multiple child process the parent process
// has been spawned with setPgid = true. To properly kill
// all subprocesses a SIGTERM need to be sent to the correct