Example #1
0
func (up *Uploader) saveHistory() {
	if _, e := os.Stat(filepath.Dir(up.historyFile)); e != nil {
		os.Mkdir(filepath.Dir(up.historyFile), os.ModePerm)
	}

	cfg := config.NewEmpty(up.Log, up.historyFile)
	defer cfg.Save()
	for _, hist := range up.ListHistory() {
		group := hist["link"]
		for key, link := range hist {
			cfg.Set(group, key, link)
		}
	}
}
Example #2
0
// loadHidden will try to load the hidden config data from the file.
//
func loadHidden(path string) *hiddenConfig {
	file := filepath.Join(path, cdglobal.FileHiddenConfig)
	hidden := &hiddenConfig{}

	// Load data from file.
	e := config.GetFromFile(log, file, func(cfg cdtype.ConfUpdater) {
		cfg.UnmarshalGroup(hidden, hiddenGroup, config.GetTag)
	})

	if e != nil { // File missing, create it.
		conf := config.NewEmpty(log, file)

		conf.MarshalGroup(hidden, hiddenGroup, config.GetTag)
		conf.Set("Gui", "mode", "0") // another section unused here.

		e = conf.Save()
		log.Err(e, "create hidden conf", file)
	}

	return hidden
}