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

11
doc/github.go

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

26
doc/google.go

@ -40,7 +40,7 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath
setupGoogleMatch(match)
// Check version control.
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 {
@ -112,33 +112,37 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath
}
// Get file from archive.
rc, err := f.Open()
r, err := f.Open()
if err != nil {
return nil, err
}
// Write data to file
fw, _ := os.Create(absPath)
fbytes := make([]byte, f.FileInfo().Size())
_, err = io.ReadFull(r, fbytes)
if err != nil {
return nil, err
}
_, err = io.Copy(fw, rc)
// Close files.
rc.Close()
fw.Close()
_, err = com.SaveFile(absPath, fbytes)
if err != nil {
return nil, err
}
}
var imports []string
// Check if need to check imports.
if nod.IsGetDeps {
imports := getImports(installPath+"/", match, cmdFlags, nod)
return imports, err
for _, d := range dirs {
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 {

11
doc/oschina.go

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

Loading…
Cancel
Save