Exemple #1
0
func crawlTag(targHash objects.HKID) (err error) {
	tags, tagErr := services.GetTags(targHash)
	if tagErr != nil {
		return tagErr
	}
	for _, tag := range tags {
		handleTag(tag)
	}
	return nil
}
Exemple #2
0
func (d dir) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) {
	//log.Printf("ReadDir requested:\n\tName:%s", d.name)
	select {
	case <-intr:
		return nil, fuse.EINTR
	default:
	}
	var l objects.List
	var listErr error
	var dirDirs = []fuse.Dirent{}
	switch d.contentType {
	case "tag":
		//if d.content_type == "tag" {
		tags, tagErr := services.GetTags(d.leaf.(objects.HKID))
		if tagErr != nil {
			log.Printf("tag %s:", tagErr)
			return nil, fuse.ENOENT
		}
		for _, tag := range tags {
			name := tag.NameSegment
			enttype := fuse.DT_Dir
			switch tag.TypeString {
			case "blob":
				enttype = fuse.DT_File
				fallthrough

			case "list", "commit", "tag":
				dirDirs = append(dirDirs, fuse.Dirent{
					Inode: fs.GenerateDynamicInode(uint64(d.inode), name),
					Name:  name,
					Type:  enttype,
				})
			default:
			}
		}
		return dirDirs, nil
	case "commit":
		//} else if d.content_type == "commit" {
		c, CommitErr := services.GetCommit(d.leaf.(objects.HKID))
		if CommitErr != nil {
			log.Printf("commit %s:", CommitErr)
			return nil, fuse.ENOENT
		}
		l, listErr = services.GetList(c.ListHash)
		if listErr != nil {
			log.Printf("commit list %s:", listErr)
			return nil, fuse.ENOENT
		}
	case "list":
		l, listErr = services.GetList(d.leaf.(objects.HCID))
		if listErr != nil {
			log.Printf("list %s:", listErr)
			return nil, fuse.ENOENT
		}
	default:
		return nil, fuse.ENOENT
	}

	for name, entry := range l {
		if entry.TypeString == "blob" {
			appendToList := fuse.Dirent{
				Inode: fs.GenerateDynamicInode(uint64(d.inode), name),
				Name:  name,
				Type:  fuse.DT_File,
			}
			dirDirs = append(dirDirs, appendToList)
		} else {
			appendToList := fuse.Dirent{
				Inode: fs.GenerateDynamicInode(uint64(d.inode), name),
				Name:  name,
				Type:  fuse.DT_Dir}
			dirDirs = append(dirDirs, appendToList)
		}
	}

	//loop through openHandles
	for openHandle := range d.openHandles {
		inList := false
		for _, dirEntry := range dirDirs {
			if openHandle == dirEntry.Name {
				inList = true
				break
			}
		}
		if !inList {
			dirDirs = append(
				dirDirs,
				fuse.Dirent{
					Inode: fs.GenerateDynamicInode(uint64(d.inode), openHandle),
					Name:  openHandle,
					Type:  fuse.DT_Dir,
				})
		}
	}
	return dirDirs, nil
}