diff --git a/core/maintenance.go b/core/maintenance.go index cbc6f73e5..3b36e9136 100644 --- a/core/maintenance.go +++ b/core/maintenance.go @@ -67,7 +67,7 @@ func (s *maintenanceService) RemapMissingFile(ctx context.Context, missingID, ta return fmt.Errorf("%w: %q", ErrNotMissing, missingID) } - target, err := s.ds.MediaFile(ctx).Get(targetID) + target, err := s.ds.MediaFile(ctx).GetWithParticipants(targetID) if err != nil { return fmt.Errorf("loading target file %q: %w", targetID, err) } diff --git a/core/maintenance_test.go b/core/maintenance_test.go index b2844f89d..24d423e4f 100644 --- a/core/maintenance_test.go +++ b/core/maintenance_test.go @@ -335,6 +335,25 @@ var _ = Describe("Maintenance", func() { Expect(service.RemapMissingFile(ctx, "m1", "t1")).To(MatchError(ContainSubstring("gc failed"))) }) + + It("preserves the target's participants on the remapped track", func() { + participant := model.Participant{ + Artist: model.Artist{ID: "a1", Name: "Artist", OrderArtistName: "artist", MbzArtistID: "mbz-artist"}, + } + mfRepo.SetData(model.MediaFiles{ + {ID: "m1", AlbumID: "album1", Missing: true}, + {ID: "t1", AlbumID: "album2", Missing: false, Participants: model.Participants{ + model.RoleArtist: model.ParticipantList{participant}, + }}, + }) + + Expect(service.RemapMissingFile(ctx, "m1", "t1")).To(Succeed()) + + // The surviving row is the missing file's ID, holding the target's data + got, err := mfRepo.GetWithParticipants("m1") + Expect(err).ToNot(HaveOccurred()) + Expect(got.Participants).To(HaveKeyWithValue(model.RoleArtist, model.ParticipantList{participant})) + }) }) })