Skip to content

Commit

Permalink
Illegal filenames created on OSX while download. Fixes eclipse-vorto#50
Browse files Browse the repository at this point in the history
Signed-off-by: Nagavijay Sivakumar <[email protected]>
  • Loading branch information
Nagavijay Sivakumar committed Jul 18, 2016
1 parent 7e08240 commit b848d4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea/
*.exe
*.exe/work/
14 changes: 9 additions & 5 deletions cli/command/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"os"
"strings"
"path"

"github.com/eclipse/vorto/client/cli/config"
"github.com/eclipse/vorto/client/cli/errorMessages"
Expand Down Expand Up @@ -88,16 +89,19 @@ func (this *DownloadCommand) Execute() error {

contentDisposition := resp.Header.Get("content-disposition")
var filename string
var absPathFileName string
fmt.Sscanf(contentDisposition, "attachment; filename = %s", &filename)

// check directory spelling
if !strings.HasSuffix(this.OutputPath, "\\") {
this.OutputPath = this.OutputPath + "\\"
if this.OutputPath != "" {
this.OutputPath = path.Clean(this.OutputPath)
absPathFileName = (this.OutputPath + string(os.PathSeparator) + filename)
}else {
absPathFileName = filename
}

exists(this.OutputPath)

file, err := os.Create(this.OutputPath + filename)
file, err := os.Create(absPathFileName)
if err != nil {
return err
}
Expand All @@ -109,7 +113,7 @@ func (this *DownloadCommand) Execute() error {
return err
}

fmt.Printf("\nMessage: Download successful, %s with %v bytes\n", this.OutputPath + filename, size)
fmt.Printf("\nMessage: Download successful, %s with %v bytes\n", absPathFileName, size)
}

return nil
Expand Down
1 change: 0 additions & 1 deletion cli/config/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func NewClient(conf *Configuration) *Client {

myClient := http.Client{}

// proxyUrl http://cache.innovations.de:3128
if conf.Proxy != "" {
proxyUrl, err := url.Parse(conf.Proxy)
if err != nil {
Expand Down

0 comments on commit b848d4f

Please sign in to comment.