Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ func Download(ctx *cli.Context) {
}

for name, contents := range submission.ProblemFiles {
if err := ioutil.WriteFile(fmt.Sprintf("%s/%s", path, name), []byte(contents), 0755); err != nil {
if err := ioutil.WriteFile(fmt.Sprintf("%s/%s", path, name), []byte(contents), 0644); err != nil {
log.Fatalf("Unable to write file %s: %s", name, err)
}
}

for name, contents := range submission.SolutionFiles {
filename := strings.TrimPrefix(name, strings.ToLower("/"+submission.TrackID+"/"+submission.Slug+"/"))
if err := ioutil.WriteFile(fmt.Sprintf("%s/%s", path, filename), []byte(contents), 0755); err != nil {
dir := filepath.Dir(filename)
if err := os.MkdirAll(fmt.Sprintf("%s/%s", path, dir), 0755); err != nil {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about how similar this code is starting to get with https://github.com/exercism/cli/blob/master/user/item.go#L51 - maybe could use some unification? I'm unsure of where I'd put the code though, so I'd take suggestions on that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just leave it for now. We can do some refactoring in a second step.

log.Fatal(err)
}
if err := ioutil.WriteFile(fmt.Sprintf("%s/%s", path, filename), []byte(contents), 0644); err != nil {
log.Fatalf("Unable to write file %s: %s", name, err)
}
}
Expand Down