Skip to content

Commit

Permalink
Working on stuffs.
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlogic committed May 9, 2020
1 parent 92a7c20 commit c227bbf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.11
- 1.10

branches:
only:
Expand Down
7 changes: 4 additions & 3 deletions cdprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"time"

pbgd "github.com/brotherlogic/godiscogs"
"github.com/brotherlogic/goserver"
"golang.org/x/net/context"
"google.golang.org/grpc"
Expand Down Expand Up @@ -119,7 +120,7 @@ func (pr *prodRipper) ripToFlac(ctx context.Context, pathIn, pathOut string) {

type getter interface {
getRecord(ctx context.Context, id int32) ([]*pbrc.Record, error)
updateRecord(ctx context.Context, rec *pbrc.Record) error
updateRecord(ctx context.Context, id int32, cdpath, filepath string) error
}

type prodGetter struct {
Expand Down Expand Up @@ -161,15 +162,15 @@ func (rc *prodGetter) getRecord(ctx context.Context, id int32) ([]*pbrc.Record,
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Unable to locate record %v", id))
}

func (rc *prodGetter) updateRecord(ctx context.Context, rec *pbrc.Record) error {
func (rc *prodGetter) updateRecord(ctx context.Context, instanceID int32, cdpath, filepath string) error {
conn, err := rc.dial("recordcollection")
if err != nil {
return err
}
defer conn.Close()

client := pbrc.NewRecordCollectionServiceClient(conn)
_, err = client.UpdateRecord(ctx, &pbrc.UpdateRecordRequest{Update: rec})
_, err = client.UpdateRecord(ctx, &pbrc.UpdateRecordRequest{Reason: "cdprocessor update", Update: &pbrc.Record{Release: &pbgd.Release{InstanceId: instanceID}, Metadata: &pbrc.ReleaseMetadata{CdPath: cdpath, FilePath: filepath}}})
return err
}

Expand Down
6 changes: 2 additions & 4 deletions cdprocessorutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ func (s *Server) makeLinks(ctx context.Context, ID int32, force bool) error {

// We need to update *all* the associated records
for _, rec := range records {
rec.GetMetadata().CdPath = fmt.Sprintf("%v%v", s.mp3dir, record.GetRelease().Id)
err := s.getter.updateRecord(ctx, rec)
err := s.getter.updateRecord(ctx, rec.GetRelease().GetInstanceId(), fmt.Sprintf("%v%v", s.mp3dir, record.GetRelease().Id), "")
if err != nil {
return err
}
Expand Down Expand Up @@ -257,8 +256,7 @@ func (s *Server) adjustExisting(ctx context.Context) error {
}
for _, rec := range recs {
if rec.GetMetadata().FilePath == "" {
rec.GetMetadata().FilePath = r.Path
s.getter.updateRecord(ctx, rec)
s.getter.updateRecord(ctx, rec.GetRelease().GetInstanceId(), "", r.Path)
s.adjust++
break
}
Expand Down
7 changes: 4 additions & 3 deletions cdprocessorutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (t *testGetter) getRecord(ctx context.Context, id int32) ([]*pbrc.Record, e
if t.adjusted[id] {
filepath = fmt.Sprintf("%v", id)
}
return []*pbrc.Record{&pbrc.Record{Release: &pbgd.Release{Id: id,
return []*pbrc.Record{&pbrc.Record{Release: &pbgd.Release{Id: id, InstanceId: id,
FormatQuantity: 1, Artists: []*pbgd.Artist{&pbgd.Artist{Name: "Hello"}},
Formats: []*pbgd.Format{&pbgd.Format{Name: "CD", Qty: "2"}},
Tracklist: []*pbgd.Track{&pbgd.Track{TrackType: pbgd.Track_TRACK, Position: "1"},
Expand All @@ -61,15 +61,16 @@ func (t *testGetter) getRecord(ctx context.Context, id int32) ([]*pbrc.Record, e
}}, nil
}

func (t *testGetter) updateRecord(ctx context.Context, rec *pbrc.Record) error {
func (t *testGetter) updateRecord(ctx context.Context, id int32, cdpath, filepath string) error {
log.Printf("HERE %v", id)
if t.failUpdate {
return fmt.Errorf("Built to fail")
}
t.updates++
if t.adjusted == nil {
t.adjusted = make(map[int32]bool)
}
t.adjusted[rec.GetRelease().Id] = true
t.adjusted[id] = true
return nil
}

Expand Down
Binary file added cdtests/4192928.data
Binary file not shown.
4 changes: 2 additions & 2 deletions recordutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,14 +886,14 @@ func TestRunExtractBaird(t *testing.T) {

tracks := TrackExtract(record.GetRelease())

if len(tracks) != 12 || tracks[11].Position != "16" {
if len(tracks) != 18 || tracks[11].Position != "2" {
for i, tr := range tracks {
log.Printf("%v-%v. %v (%v-%v)", i, tr.Position, len(tr.tracks), tr.Format, tr.Disk)
for j, trs := range tr.tracks {
log.Printf(" %v. %v", j, trs.Title)
}
}
t.Errorf("Bad spec")
t.Errorf("Bad spec: %v -> %v", len(tracks), tracks[11].Position)
}

log.Printf("WHAT %+v", tracks[len(tracks)-1])
Expand Down

0 comments on commit c227bbf

Please sign in to comment.