Import missing artist portraits from uploaded album folders
ci / module boundaries / boundaries (push) Successful in 6s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 2m1s
ci / ts / ts (packages + web) (push) Failing after 5m13s
ci / api / api (push) Successful in 41s
ci / db / db (push) Failing after 1m33s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 2m25s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 2m19s
ci / module boundaries / boundaries (push) Successful in 6s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 2m1s
ci / ts / ts (packages + web) (push) Failing after 5m13s
ci / api / api (push) Successful in 41s
ci / db / db (push) Failing after 1m33s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 2m25s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 2m19s
This commit is contained in:
1 parent
fd17c06397
commit
82bf015283
23 files changed
+829
-317
No files matched your search
@@ -45,8 +45,15 @@ type Service struct {
|
||||
catalogue ReleaseCatalogue
|
||||
identifier AudioIdentifier
|
||||
encodedFingerprint func(context.Context, string) (string, error)
|
||||
artistImages ArtistImages
|
||||
}
|
||||
|
||||
type ArtistImages interface {
|
||||
ApplyArtistImage(context.Context, uuid.UUID, []byte) error
|
||||
}
|
||||
|
||||
func (s *Service) SetArtistImages(images ArtistImages) { s.artistImages = images }
|
||||
|
||||
type ReleaseCatalogue interface {
|
||||
Search(context.Context, musicbrainz.Query) ([]musicbrainz.Release, error)
|
||||
Cover(context.Context, musicbrainz.Release) (musicbrainz.Cover, error)
|
||||
@@ -199,7 +206,7 @@ type CreateFile struct {
|
||||
}
|
||||
|
||||
// Create создаёт пачку и резервирует место; не поместившиеся и дубли отклоняются с кодом.
|
||||
func (s *Service) Create(ctx context.Context, comment *string, files []CreateFile, cover []byte) (uuid.UUID, []Reserved, error) {
|
||||
func (s *Service) Create(ctx context.Context, comment *string, files []CreateFile, cover []byte, artistImages ...[]byte) (uuid.UUID, []Reserved, error) {
|
||||
p, err := principal(ctx, auth.PermSuggestTracks)
|
||||
if err != nil {
|
||||
return uuid.Nil, nil, err
|
||||
@@ -235,12 +242,22 @@ func (s *Service) Create(ctx context.Context, comment *string, files []CreateFil
|
||||
return uuid.Nil, nil, err
|
||||
}
|
||||
keepCover := false
|
||||
var artistImagePath *string
|
||||
defer func() {
|
||||
if coverPath != nil && !keepCover {
|
||||
_ = os.Remove(s.stagingAbs(*coverPath))
|
||||
}
|
||||
if artistImagePath != nil && !keepCover {
|
||||
_ = os.Remove(s.stagingAbs(*artistImagePath))
|
||||
}
|
||||
}()
|
||||
batch, res, err := s.store.CreateBatch(ctx, p.UserID, comment, accepted, st, coverPath)
|
||||
if len(artistImages) > 0 {
|
||||
artistImagePath, err = s.createCover(artistImages[0])
|
||||
if err != nil {
|
||||
return uuid.Nil, nil, err
|
||||
}
|
||||
}
|
||||
batch, res, err := s.store.CreateBatch(ctx, p.UserID, comment, accepted, st, coverPath, artistImagePath)
|
||||
if err != nil {
|
||||
return uuid.Nil, nil, err
|
||||
}
|
||||
@@ -609,6 +626,9 @@ func (s *Service) removeStaging(ctx context.Context, f File) {
|
||||
if cover, err := s.store.UnusedBatchCover(ctx, f.BatchID); err == nil && cover != nil {
|
||||
_ = os.Remove(s.stagingAbs(*cover))
|
||||
}
|
||||
if image, err := s.store.UnusedArtistImage(ctx, f.BatchID); err == nil && image != nil {
|
||||
_ = os.Remove(s.stagingAbs(*image))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user