示例#1
0
文件: manifest.go 项目: groob/ape
// SaveManifest saves a manifest to the datastore
func (r *SimpleRepo) SaveManifest(manifest *models.Manifest) error {
	if manifest.Filename == "" {
		return errors.New("filename key must be set")
	}
	manifestPath := fmt.Sprintf("%v/manifests/%v", r.Path, manifest.Filename)
	file, err := os.OpenFile(manifestPath, os.O_WRONLY, 0755)
	if err != nil {
		return err
	}
	defer file.Close()
	if err := plist.NewEncoder(file).Encode(manifest); err != nil {
		return err
	}
	return nil
}
示例#2
0
文件: pkgsinfo.go 项目: groob/ape
// SavePkgsinfo saves a pkgsinfo file to the datastore
func (r *SimpleRepo) SavePkgsinfo(pkgsinfo *models.PkgsInfo) error {
	if pkgsinfo.Filename == "" {
		return errors.New("filename key must be set")
	}
	pkgsinfoPath := fmt.Sprintf("%v/pkgsinfo/%v", r.Path, pkgsinfo.Filename)
	file, err := os.OpenFile(pkgsinfoPath, os.O_WRONLY, 0755)
	if err != nil {
		return err
	}
	defer file.Close()
	if err := plist.NewEncoder(file).Encode(pkgsinfo); err != nil {
		return err
	}
	go func() {
		makecatalogs <- true
	}()
	return nil
}
示例#3
0
文件: catalogs.go 项目: groob/ape
func (r *SimpleRepo) saveCatalog(name string, catalogs *models.Catalogs) error {
	catalogsPath := fmt.Sprintf("%v/catalogs/%v", r.Path, name)
	var file *os.File
	var err error
	if _, err := os.Stat(catalogsPath); err != nil {
		file, err = os.Create(catalogsPath)
	} else {
		file, err = os.OpenFile(catalogsPath, os.O_TRUNC|os.O_WRONLY, 0755)
	}
	if err != nil {
		return err
	}
	defer file.Close()
	enc := plist.NewEncoder(file)
	enc.Indent("  ")
	return enc.Encode(catalogs)

}