示例#1
0
文件: external.go 项目: sqp/godock
func listPackages() (list packages.AppletPackages, e error) {

	// List server only.
	if *listServer {
		return packages.ListDistant(logger, cdglobal.AppletsDirName+"/"+cdglobal.AppletsServerTag)
	}

	// Get applets dir.
	externalUserDir, e := packages.DirAppletsExternal(*listUserDir)
	if e != nil {
		return nil, e
	}

	// List local only.
	if *listLocal {
		return packages.ListFromDir(logger, externalUserDir, packages.TypeUser, packages.SourceApplet)
	}

	// List default (merged both).
	packs, e := packages.ListDownloadApplets(logger, externalUserDir)
	if e != nil {
		return nil, e
	}
	return packages.ListDownloadSort(packs), nil
}
示例#2
0
文件: confdata.go 项目: sqp/godock
// ListDownloadApplets builds the list of downloadable user applets (installed or not).
//
func (d Data) ListDownloadApplets() (map[string]datatype.Appleter, error) {
	externalUserDir := globals.DirDockData(cdglobal.AppletsDirName)
	packs, e := packages.ListDownloadApplets(d.Log, externalUserDir)
	if e != nil {
		return nil, e
	}

	applets := docklist.Module()
	list := make(map[string]datatype.Appleter)
	for k, v := range packs {
		list[k] = &AppletDownload{
			AppletPackage: *v,
			app:           applets[k],
		}
	}

	return list, nil
}