MVP done
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-06-23 13:02:10 +03:00
parent 610fb3da11
commit 587676be58
6 changed files with 231 additions and 45 deletions

View File

@@ -6,8 +6,6 @@ import (
"io"
"net/http"
"os"
"path/filepath"
"strings"
)
// HTTPDownloader реализует интерфейс interfaces.FileDownloader.
@@ -40,8 +38,8 @@ func (d *HTTPDownloader) Download(ctx context.Context, url string) (string, erro
return "", fmt.Errorf("bad status code on download: %s", resp.Status)
}
// Создаем временный файл с правильным расширением
tmpFile, err := os.CreateTemp("", "track-*.tmp")
// Создаем временный файл с правильным расширением .mp3
tmpFile, err := os.CreateTemp("", "track-*.mp3")
if err != nil {
return "", fmt.Errorf("failed to create temp file: %w", err)
}
@@ -54,11 +52,5 @@ func (d *HTTPDownloader) Download(ctx context.Context, url string) (string, erro
return "", fmt.Errorf("failed to write to temp file: %w", err)
}
// Переименовываем файл, чтобы убрать .tmp расширение (не обязательно, но красиво)
finalPath := strings.TrimSuffix(tmpFile.Name(), filepath.Ext(tmpFile.Name()))
if err := os.Rename(tmpFile.Name(), finalPath); err != nil {
return "", fmt.Errorf("failed to rename temp file: %w", err)
}
return finalPath, nil
return tmpFile.Name(), nil
}