fix(uploads): refresh destination previews and improve queue layout
ci / api / api (push) Successful in 50s
ci / db / db (push) Successful in 56s
ci / module boundaries / boundaries (push) Successful in 8s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m2s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m15s
ci / ts / ts (packages + web) (push) Failing after 4m28s

This commit is contained in:
mrleo1nid committed 2026-10-29 11:10:54 +03:00
1 parent eb75437708
commit 30c3c85f89
18 files changed
+603 -402

No files matched your search

@@ -3,6 +3,8 @@ package uploads
import (
"context"
"errors"
"path/filepath"
"strings"
"github.com/google/uuid"
@@ -47,6 +49,41 @@ type placement struct {
root string
}
// previewPlacement uses the same current configuration as importFile. Finalized
// files keep their recorded destination; reading the queue never changes a decision.
func (s *PlacementPlanner) previewPlacement(ctx context.Context, f *File) {
f.TargetStoragePath = nil
if f.Meta != nil && (f.Status == StatusPendingReview || f.Status == StatusImportFailed || f.Status == StatusApproved) {
pl := s.plan(ctx, *f, *f.Meta, f.TargetSourceID)
f.TargetSourceID, f.TargetRelPath = pl.SourceID, pl.RelPath
f.TargetSourceName = nil
if pl.SourceID != nil {
f.TargetSourceName = &pl.src.Name
}
if f.Status == StatusPendingReview || pl.Reason != "" {
f.StatusReason = nullable(pl.Reason)
}
f.MatchedArtistID, f.MatchedAlbumID = pl.ArtistID, pl.AlbumID
}
if f.TargetSourceID == nil || f.TargetRelPath == nil {
return
}
src, err := s.lib.GetSource(ctx, *f.TargetSourceID)
if err != nil {
return
}
f.TargetSourceName = &src.Name
if src.Type == library.SourceNFS {
if src.NFSServer != nil && src.NFSExport != nil {
full := *src.NFSServer + ":" + strings.TrimRight(*src.NFSExport, "/") + "/" + *f.TargetRelPath
f.TargetStoragePath = &full
}
} else if root, err := s.roots.Root(src); err == nil {
full := filepath.Join(root, filepath.FromSlash(*f.TargetRelPath))
f.TargetStoragePath = &full
}
}
// pickSource — хранилище: выбранное админом → по умолчанию → единственное принимающее загрузки.
func (s *PlacementPlanner) pickSource(ctx context.Context, chosen *uuid.UUID) (library.Source, string) {
id := chosen