Ejemplo n.º 1
0
func writeCheckUpdate() error {
	p := config.GetUserConfigsPath()
	f, err := os.Create(filepath.Join(p, "update-check"))
	if err != nil {
		return fmt.Errorf("cannot create update check file: %s", err)
	}
	defer f.Close()

	if *config.Verbose {
		log.Printf("writing update-check file\n")
	}

	return nil
}
Ejemplo n.º 2
0
func checkShouldCheckUpdate() (bool, error) {
	p := config.GetUserConfigsPath()
	info, err := os.Stat(filepath.Join(p, "update-check"))
	if err != nil && !os.IsNotExist(err) {
		return false, fmt.Errorf("cannot stat update check file: %s", err)
	}

	if err == nil && time.Now().Sub(info.ModTime()) < 24*time.Hour {
		if *config.Verbose {
			log.Printf("ignoring update because it has been checked in the last 24 hours\n")
		}
		return false, nil
	}

	return true, nil
}