コード例 #1
0
ファイル: crawl.go プロジェクト: skelterjohn/gowalker
// crawlDoc fetchs package from VCS.
func crawlDoc(path string, etag string, views int64) (pdoc *Package, err error) {
	// I have no idea what the f**k does this mean.
	if i := strings.Index(path, "/libgo/go/"); i > 0 && utils.IsGoRepoPath(path[i+len("/libgo/go/"):]) {
		// Go Frontend source tree mirror.
		pdoc = nil
		err = errors.New("Go Frontend source tree mirror.")
	} else {
		var pdocNew *Package
		pdocNew, err = getRepo(httpClient, path, etag)

		// For timeout logic in client.go to work, we cannot leave connections idling. This is ugly.
		httpTransport.CloseIdleConnections()

		if err != errNotModified && pdocNew != nil {
			pdoc = pdocNew
			pdoc.Views = views
		}
	}

	switch {
	case err == nil:
		pdoc.Views = views
		if err = SaveProject(pdoc); err != nil {
			beego.Error("doc.SaveProject(", path, "):", err)
		}
	case isNotFound(err):
		// We do not need to delete standard library, so here is fine.
		if err = models.DeleteProject(path); err != nil {
			beego.Error("doc.DeleteProject(", path, "):", err)
		}
	}
	return pdoc, err
}
コード例 #2
0
ファイル: crawl.go プロジェクト: seacoastboy/gowalker
// crawlDoc fetchs package from VCS.
func crawlDoc(path, tag string, pinfo *models.PkgInfo) (pdoc *Package, err error) {
	var pdocNew *Package
	pdocNew, err = getRepo(httpClient, path, tag, pinfo.Etag)

	// For timeout logic in client.go to work, we cannot leave connections idling. This is ugly.
	httpTransport.CloseIdleConnections()

	if err != errNotModified && pdocNew != nil {
		pdoc = pdocNew
		pdoc.Views = pinfo.Views
		pdoc.Labels = pinfo.Labels
		pdoc.ImportedNum = pinfo.ImportedNum
		pdoc.ImportPid = pinfo.ImportPid
	}

	switch {
	case err == nil:
		if err = SaveProject(pdoc, pinfo); err != nil {
			beego.Error("doc.SaveProject(", path, ") ->", err)
		}
	case isNotFound(err):
		// We do not need to delete standard library, so here is fine.
		if err = models.DeleteProject(path); err != nil {
			beego.Error("doc.DeleteProject(", path, ") ->", err)
		}
	}
	return pdoc, err
}
コード例 #3
0
ファイル: crawl.go プロジェクト: juju2013/gowalker
// crawlDoc fetchs package from VCS and returns 'Package' by given import path and tag.
// It returns error when error occurs in the underlying functions.
func crawlDoc(path, tag string, pinfo *hv.PkgInfo) (pdoc *hv.Package, err error) {
	var pdocNew *hv.Package
	pdocNew, err = getRepo(HttpClient, path, tag, pinfo.Ptag)

	if err != errNotModified && pdocNew != nil {
		pdoc = pdocNew
		pdoc.Views = pinfo.Views
		pdoc.Labels = pinfo.Labels
		pdoc.RefNum = pinfo.RefNum
		pdoc.RefPids = pinfo.RefPids
		pdoc.Rank = pinfo.Rank
	}

	switch {
	case err == nil:
		// Let upper level to render doc. page.
		return pdoc, nil
	case err == errNoMatch:
		beego.Error("doc.crawlDoc ->", err)
		err = nil
		pdoc = nil
	case isNotFound(err):
		// Only delete when server cannot find master branch
		// because sub-package(s) may not exist in old tag(s).
		if len(tag) == 0 {
			models.DeleteProject(path)
		}
	}
	return pdoc, err
}
コード例 #4
0
ファイル: crawl.go プロジェクト: JoeyFan/gowalker
// crawlDoc fetchs package from VCS.
func crawlDoc(path, tag string, pinfo *models.PkgInfo) (pdoc *Package, err error) {
	var pdocNew *Package
	pdocNew, err = getRepo(httpClient, path, tag, pinfo.Etag)

	if err != errNotModified && pdocNew != nil {
		pdoc = pdocNew
		pdoc.Views = pinfo.Views
		pdoc.Labels = pinfo.Labels
		pdoc.ImportedNum = pinfo.ImportedNum
		pdoc.ImportPid = pinfo.ImportPid
		pdoc.Rank = pinfo.Rank
	}

	switch {
	case err == nil:
		pdoc.Id, err = SaveProject(pdoc, pinfo)
		if err != nil {
			beego.Error("doc.SaveProject(", path, ") ->", err)
		}
	case isNotFound(err):
		// We do not need to delete standard library, so here is fine.
		if err := models.DeleteProject(path); err != nil {
			beego.Error("doc.DeleteProject(", path, ") ->", err)
		}
	}
	return pdoc, err
}