Beispiel #1
0
// Discards any errors that happen in sub-stores
func (store *Store) List() ([]*fedwiki.PageHeader, error) {
	matches, err := filepath.Glob(store.Glob)
	err = pagestore.ConvertOSError(err)
	if err != nil {
		return "", err
	}

	headers := []*fedwiki.PageHeader{}
	for _, filename := range matches {
		header, err := pagestore.LoadHeader(filename)
		err = pagestore.ConvertOSError(err)
		//TODO: maybe ignore this error?
		if err != nil {
			return nil, err
		}

		headers = append(headers, header)
	}
	return headers, nil
}
Beispiel #2
0
func (store *Store) path(slug fedwiki.Slug) (string, error) {
	// todo, cache matches
	matches, err := filepath.Glob(store.Glob)
	err = pagestore.ConvertOSError(err)
	if err != nil {
		return "", err
	}

	for _, filename := range matches {
		if filepath.Base(filename) == string(slug) {
			return filename
		}
	}

	return "", fedwiki.ErrNotExist
}