Skip to content

Commit

Permalink
Merge 1c51a2a into 676a2ec
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlogic committed Mar 3, 2019
2 parents 676a2ec + 1c51a2a commit a8e87b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cdprocessorutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ func (s *Server) verify(ctx context.Context, ID int32) error {
return nil
}

func expand(v string) string {
if len(v) == 1 {
return "0" + v
}
return v
}

func (s *Server) makeLinks(ctx context.Context, ID int32) error {
record, err := s.getter.getRecord(ctx, ID)
if err != nil {
Expand All @@ -40,11 +47,11 @@ func (s *Server) makeLinks(ctx context.Context, ID int32) error {

for _, track := range record.GetRelease().Tracklist {
if track.TrackType == pbgd.Track_TRACK {
s.ripper.runCommand(ctx, []string{"ln", "-s", fmt.Sprintf("%v%v/track%v.cdda.mp3", s.dir, record.GetRelease().Id, track.Position), fmt.Sprintf("%v%v", s.mp3dir, record.GetRelease().Id)})
s.ripper.runCommand(ctx, []string{"ln", "-s", fmt.Sprintf("%v%v/track%v.cdda.mp3", s.dir, record.GetRelease().Id, expand(track.Position)), fmt.Sprintf("%v%v", s.mp3dir, record.GetRelease().Id)})
}
for _, subtrack := range track.SubTracks {
if subtrack.TrackType == pbgd.Track_TRACK {
s.ripper.runCommand(ctx, []string{"ln", "-s", fmt.Sprintf("%v%v/track%v.cdda.mp3", s.dir, record.GetRelease().Id, subtrack.Position), fmt.Sprintf("%v%v", s.mp3dir, record.GetRelease().Id)})
s.ripper.runCommand(ctx, []string{"ln", "-s", fmt.Sprintf("%v%v/track%v.cdda.mp3", s.dir, record.GetRelease().Id, expand(subtrack.Position)), fmt.Sprintf("%v%v", s.mp3dir, record.GetRelease().Id)})
}

}
Expand Down
7 changes: 7 additions & 0 deletions cdprocessorutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,10 @@ func TestLink(t *testing.T) {
}

}

func TestExpand(t *testing.T) {
s := expand("11")
if s != "11" {
t.Errorf("Poor expansion: %v", s)
}
}

0 comments on commit a8e87b3

Please sign in to comment.