Esempio n. 1
0
func (s *shard) PipelineFileGetAll(pipelineName string, fileName string, commit string, shard string) ([]File, error) {
	matches, err := btrfs.Glob(path.Join(s.pipelinePrefix, pipelineName, commit, fileName))
	if err != nil {
		return nil, err
	}
	var result []File
	for _, match := range matches {
		prefix := path.Join("/", s.pipelinePrefix, pipelineName, commit)
		if !strings.HasSuffix(prefix, "/") {
			prefix = prefix + "/"
		}
		name := strings.TrimPrefix(match, prefix)
		if shard != "" {
			ok, err := route.Match(name, shard)
			if err != nil {
				return nil, err
			}
			if !ok {
				continue
			}
		}
		file, err := s.PipelineFileGet(pipelineName, name, commit)
		if err == ErrIsDirectory {
			continue
		}
		if err != nil {
			return nil, err
		}
		result = append(result, file)
	}
	return result, nil
}
Esempio n. 2
0
func (s *shard) FileGetAll(name string, commit string) ([]File, error) {
	matches, err := btrfs.Glob(path.Join(s.dataRepo, commit, name))
	if err != nil {
		return nil, err
	}
	var result []File
	for _, match := range matches {
		name := strings.TrimPrefix(match, path.Join(s.dataRepo, commit))
		file, err := s.FileGet(name, commit)
		if err == ErrIsDirectory {
			continue
		}
		if err != nil {
			return nil, err
		}
		result = append(result, file)
	}
	return result, nil
}