예제 #1
0
파일: main.go 프로젝트: aiviru/bzwikipedia
//
// dosplit, docache := needUpdate()
// If dosplit is true, then call bzip2recover.
// If docache is true, then the title cache file needs to
// be regenerated.
//
func needUpdate(recent string) (bool, bool) {
	olddat, err := confparse.ParseFile(conf["dat_file"])
	version := 0

	if err == nil {
		version, err = strconv.Atoi(olddat["version"])

		if err != nil {
			fmt.Println("Dat file has invalid format.")
			return true, true
		}

		if basename(olddat["dbname"]) == basename(recent) {
			// The .bz2 records exist, but we may need to
			// regenerate the title cache file.
			if version < current_cache_version {
				fmt.Printf("Version of the title cache file is %d.\n", version)
				fmt.Printf("Wiping cache and replacing with version %d. This will take a while.\n", current_cache_version)
				time.Sleep(5000000000)
				return false, true
			}
			return false, false
		}
	} else {
		fmt.Printf("Unable to open %v: %v\n", conf["dat_file"], err)
	}
	return true, true
}
예제 #2
0
파일: main.go 프로젝트: aiviru/bzwikipedia
func parseNameSpaces(confname string) {
	fromfile, err := confparse.ParseFile(confname)
	if err != nil {
		fmt.Printf("Unable to read namespace file '%s'\n", confname)
		return
	}

	fmt.Printf("Read namespace file '%s'\n", confname)

	wiki2html.ConfigureNameSpaces(fromfile)
}
예제 #3
0
파일: main.go 프로젝트: aiviru/bzwikipedia
func parseConfig(confname string) {
	fromfile, err := confparse.ParseFile(confname)
	if err != nil {
		fmt.Printf("Unable to read config file '%s'\n", confname)
		return
	}

	fmt.Printf("Read config file '%s'\n", confname)

	for key, value := range fromfile {
		if _, ok := conf[key]; !ok {
			fmt.Printf("Unknown config key: '%v'\n", key)
		} else {
			conf[key] = value
		}
	}
}
예제 #4
0
파일: main.go 프로젝트: aiviru/bzwikipedia
func loadTitleFile() bool {
	var derr os.Error
	dat, derr = confparse.ParseFile(conf["dat_file"])
	if derr != nil {
		fmt.Println(derr)
		return false
	}

	curdbname = dat["dbname"]
	record_count, derr = strconv.Atoi(dat["rcount"])
	if derr != nil {
		fmt.Println(derr)
		return false
	}

	fmt.Printf("DB '%s': Contains %d records.\n", curdbname, record_count)

	var success bool

	success, title_size, title_blob = loadfile.ReadFile(conf["title_file"], conf["cache_type"] == "mmap")
	return success
}