예제 #1
0
파일: ref.go 프로젝트: olragon/dna
func SaveLastedChecktime(db *sqlpg.DB, filePath dna.String) error {
	cf, err := cfg.LoadConfigFile(filePath)
	if err != nil {
		return err
	}
	siteCts, err := GetLastedChecktime(db)
	if err != nil {
		return err
	}
	for site, checktime := range siteCts {
		var key dna.String
		var section dna.String
		switch {
		case site.Match("songs") == true:
			key = "songs"
			section = site.Replace("songs", "")
		case site.Match("albums") == true:
			key = "albums"
			section = site.Replace("albums", "")
		case site.Match("videos") == true:
			key = "videos"
			section = site.Replace("videos", "")
		default:
			panic("site is not valid")
		}
		cf.SetValue(section, key, dna.String(checktime.Format(utils.DefaultTimeLayout)))
	}
	return cfg.SaveConfigFile(cf, filePath)
}
예제 #2
0
파일: siteconfig.go 프로젝트: olragon/dna
// SaveSiteConfig saves site configuration to disk.
func SaveSiteConfig(sc *SiteConfig, filepath String) error {
	sc.src.SetValue(sc.siteCode, "nconcurrent", sc.NConcurrent.ToString())
	sc.src.SetValue(sc.siteCode, "ncsongfail", sc.NCSongFail.ToString())
	sc.src.SetValue(sc.siteCode, "ncalbumfail", sc.NCAlbumFail.ToString())
	sc.src.SetValue(sc.siteCode, "ncvideofail", sc.NCVideoFail.ToString())
	return cfg.SaveConfigFile(sc.src, filepath)
}