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) }
// 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) }