예제 #1
0
// 初始化资源列表
func (v *Version) initFiles() {
	fp.Walk(v.Path, func(path string, f os.FileInfo, err error) error {
		if f.IsDir() || f.Name() == ".DS_Store" {
			return nil
		}
		name := strings.Replace(path, v.Path+"/", "", 1)
		md5, _ := util.GetFileMD5(path)
		v.items = append(v.items, Item{
			name: name,
			md5:  md5,
		})
		return nil
	})
}
예제 #2
0
// Publish 发布资源
func (c *Channel) Publish(host, engine string) {
	if len(c.versions) <= 1 {
		fmt.Println("没有要发布的资源")
		return
	}
	channelpath := c.pubpath + "/" + c.name
	util.CheckOrCreateDir(channelpath)

	// 设置源版本
	vsrc := c.versions[0]

	mf := manifest.NewManifest()
	// 基本设置
	mf.SetURL(host + "/" + c.name)
	mf.SetVersion(vsrc.Name)
	mf.SetEngineVersion(engine)

	// 变化从 1 索引开始,0 对比 1
	for i := 1; i < len(c.versions); i++ {
		// 目标版本
		vtar := c.versions[i]
		chg := NewChange(c.name, vsrc, vtar)
		zipfile := chg.ArchiveZip(c.pubpath)

		mf.AddGroupVersion(vtar.Name)
		md5, _ := util.GetFileMD5(channelpath + "/" + zipfile)
		mf.AddAsset(zipfile, md5)

		vsrc = vtar
	}

	path := c.pubpath + "/" + c.name + "/"
	con, _ := mf.MarshalMini()
	_ = ioutil.WriteFile(path+"version.manifest", con, 0644)
	// fmt.Println(string(con))
	con, _ = mf.Marshal()
	_ = ioutil.WriteFile(path+"project.manifest", con, 0644)
}