Browse Source

Bug fixed

pull/103/head
Unknown 11 years ago
parent
commit
b08babcfec
  1. 4
      cmd/get.go
  2. 11
      doc/github.go
  3. 26
      doc/google.go
  4. 11
      doc/oschina.go

4
cmd/get.go

@ -17,6 +17,7 @@ package cmd
import ( import (
"errors" "errors"
"fmt" "fmt"
//"os"
"strings" "strings"
"github.com/Unknwon/com" "github.com/Unknwon/com"
@ -226,8 +227,9 @@ func downloadPackage(nod *doc.Node) (*doc.Node, []string) {
imports, err := doc.PureDownload(nod, installRepoPath, CmdGet.Flags) imports, err := doc.PureDownload(nod, installRepoPath, CmdGet.Flags)
if err != nil { if err != nil {
com.ColorLog("[ERRO] Download falied[ %s ]\n", err) com.ColorLog("[ERRO] Download falied( %s )[ %s ]\n", nod.ImportPath, err)
failConut++ failConut++
//os.RemoveAll(installRepoPath + "/" + doc.GetProjectPath(nod.ImportPath) + "/")
return nil, nil return nil, nil
} }
return nod, imports return nod, imports

11
doc/github.go

@ -107,21 +107,18 @@ func getGithubDoc(client *http.Client, match map[string]string, installRepoPath
} }
default: default:
// Get file from archive. // Get file from archive.
rc, err := f.Open() r, err := f.Open()
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Write data to file fbytes := make([]byte, f.FileInfo().Size())
fw, _ := os.Create(absPath) _, err = io.ReadFull(r, fbytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
_, err = io.Copy(fw, rc) _, err = com.SaveFile(absPath, fbytes)
// Close files.
rc.Close()
fw.Close()
if err != nil { if err != nil {
return nil, err return nil, err
} }

26
doc/google.go

@ -40,7 +40,7 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath
setupGoogleMatch(match) setupGoogleMatch(match)
// Check version control. // Check version control.
if err := getGoogleVCS(client, match); err != nil { if err := getGoogleVCS(client, match); err != nil {
return nil, err return nil, errors.New("fail to get vcs " + nod.ImportPath + " : " + err.Error())
} }
switch nod.Type { switch nod.Type {
@ -112,33 +112,37 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath
} }
// Get file from archive. // Get file from archive.
rc, err := f.Open() r, err := f.Open()
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Write data to file fbytes := make([]byte, f.FileInfo().Size())
fw, _ := os.Create(absPath) _, err = io.ReadFull(r, fbytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
_, err = io.Copy(fw, rc) _, err = com.SaveFile(absPath, fbytes)
// Close files.
rc.Close()
fw.Close()
if err != nil { if err != nil {
return nil, err return nil, err
} }
} }
var imports []string
// Check if need to check imports. // Check if need to check imports.
if nod.IsGetDeps { if nod.IsGetDeps {
imports := getImports(installPath+"/", match, cmdFlags, nod) for _, d := range dirs {
return imports, err importPkgs, err := CheckImports(d, match["importPath"], nod)
if err != nil {
return nil, err
}
imports = append(imports, importPkgs...)
}
} }
return nil, err return imports, err
} }
type rawFile struct { type rawFile struct {

11
doc/oschina.go

@ -93,21 +93,18 @@ func getOSCDoc(client *http.Client, match map[string]string, installRepoPath str
} }
// Get file from archive. // Get file from archive.
rc, err := f.Open() r, err := f.Open()
if err != nil { if err != nil {
return nil, errors.New("Fail to open OSChina repo -> " + err.Error()) return nil, errors.New("Fail to open OSChina repo -> " + err.Error())
} }
// Write data to file fbytes := make([]byte, f.FileInfo().Size())
fw, _ := os.Create(absPath) _, err = io.ReadFull(r, fbytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
_, err = io.Copy(fw, rc) _, err = com.SaveFile(absPath, fbytes)
// Close files.
rc.Close()
fw.Close()
if err != nil { if err != nil {
return nil, err return nil, err
} }

Loading…
Cancel
Save