Ejemplo n.º 1
0
func indexTag(inTag objects.Tag) {
	indexBlob(inTag.Bytes())
	hashHex := inTag.Hash().Hex()
	blobIndex[hashHex] = blobIndex[hashHex].insertType("Tag")
	blobIndex[inTag.Hkid.Hex()] =
		blobIndex[inTag.Hkid.Hex()].insertType("Domain")
	blobIndex[hashHex] =
		blobIndex[hashHex].insertCollection(inTag.Hkid.Hex())
	indexNameSegment(
		inTag.TypeString,
		inTag.HashBytes.Hex(),
		inTag.Hash().Hex(),
		inTag.NameSegment,
	)

	if tagIndex == nil {
		tagIndex = make(map[string]tagIndexEntry)
	}
	if _, present := tagIndex[inTag.Hkid.Hex()]; !present {
		tagIndex[inTag.Hkid.Hex()] = tagIndexEntry{}
	}
	tagIndex[inTag.Hkid.Hex()] = tagIndex[inTag.Hkid.Hex()].insertVersion(
		inTag.Version,
		inTag.NameSegment,
		inTag.Hash(),
	)
	insertDescendantS(inTag.Parents, inTag.Hash(), inTag.Version)
}
Ejemplo n.º 2
0
func (d dir) Publish(h objects.HCID, name string, typeString string) (err error) {
	switch d.contentType {

	default:
		log.Printf("unknown type: %s", d.contentType)
		return fmt.Errorf("unknown type: %s", d.contentType)
	case "commit":
		c, CommitErr := services.GetCommit(d.leaf.(objects.HKID))
		if CommitErr != nil {
			return CommitErr
		}
		l, listErr := services.GetList(c.ListHash)
		if listErr != nil {
			return listErr
		}
		newList := l.Add(name, h, typeString)

		newCommit := c.Update(newList.Hash())
		//=========================================================================
		//if verbosity == 1 {
		log.Printf(
			"Posting list %s\n-----BEGIN LIST-------\n%s\n-------END LIST-------",
			newList.Hash(),
			newList,
		)
		//}
		//=========================================================================
		el := services.PostList(newList)
		if el != nil {
			return listErr
		}
		//=========================================================================
		//if verbosity == 1 {
		log.Printf(
			"Posting commit %s\n-----BEGIN COMMIT-----\n%s\n-------END COMMIT-----",
			newCommit.Hash(),
			newCommit,
		)
		//}
		//=========================================================================
		ec := services.PostCommit(newCommit)
		if ec != nil {
			return listErr
		}
		return nil
	case "tag":
		t, tagErr := services.GetTag(d.leaf.(objects.HKID), name)
		var newTag objects.Tag
		if tagErr == nil {
			newTag = t.Update(h, typeString)
		} else {
			log.Printf("Tag %s\\%s Not Found", d.leaf, name)
			newTag = objects.NewTag(h, typeString, name, nil, d.leaf.(objects.HKID))
		}
		//=========================================================================
		if verbosity == 1 {
			log.Printf(
				"Posting tag %s\n-----BEGIN TAG--------\n%s\n-------END TAG--------",
				newTag.Hash(),
				newTag,
			)
		}
		//=========================================================================
		et := services.PostTag(newTag)
		if et != nil {
			return tagErr
		}
		return nil
	case "list":
		l, listErr := services.GetList(d.leaf.(objects.HCID))
		if listErr != nil {
			return listErr
		}
		newList := l.Add(name, h, typeString)
		//=========================================================================
		if verbosity == 1 {
			log.Printf(
				"Posting list %s\n-----BEGIN LIST-------\n%s\n-------END LIST-------",
				newList.Hash(),
				newList,
			)
		}
		//=========================================================================
		el := services.PostList(newList)
		if el != nil {
			return listErr
		}
		d.parent.Publish(newList.Hash(), d.name, "list")
		return nil
	}
}
Ejemplo n.º 3
0
func (d dir) Rename(
	r *fuse.RenameRequest,
	newDir fs.Node,
	intr fs.Intr,
) fuse.Error {
	log.Printf("request: %+v\nobject: %+v", r, d)
	select {
	case <-intr:
		return fuse.EINTR
	default:
	}
	//find content_type
	if r.OldName != r.NewName {
		d.name = r.NewName
	}
	d.name = r.OldName

	switch d.contentType {

	case "list":
		l, listErr := services.GetList(d.leaf.(objects.HCID))
		if listErr != nil {
			return listErr
		}
		newList := l.Add(r.NewName, l[r.OldName].Hash, l[r.OldName].TypeString)
		newList = l.Remove(r.OldName)
		//=========================================================================
		if verbosity == 1 {
			log.Printf(
				"Posting list %s\n-----BEGIN LIST-------\n%s\n-------END LIST-------",
				newList.Hash(),
				newList,
			)
		}
		//=========================================================================
		el := services.PostList(newList)
		if el != nil {
			return listErr
		}
		d.Publish(d.leaf.(objects.HCID), d.name, d.contentType)

	case "commit":
		c, CommitErr := services.GetCommit(d.leaf.(objects.HKID))
		if CommitErr != nil {
			return CommitErr
		}
		l, ListErr := services.GetList(c.ListHash)
		if ListErr != nil {
			return ListErr
		}
		newList := l.Add(r.NewName, l[r.OldName].Hash, l[r.OldName].TypeString)
		newList = l.Remove(r.OldName)

		newCommit := c.Update(newList.Hash())
		//=========================================================================
		if verbosity == 1 {
			log.Printf(
				"Posting list %s\n-----BEGIN LIST-------\n%s\n-------END LIST-------",
				newList.Hash(),
				newList,
			)
		}
		//=========================================================================
		el := services.PostList(newList)
		if el != nil {
			return ListErr
		}
		//=========================================================================
		if verbosity == 1 {
			log.Printf(
				"Posting commit %s\n-----BEGIN COMMIT-----\n%s\n-------END COMMIT-----",
				newCommit.Hash(),
				newCommit,
			)
		}
		//=========================================================================
		ec := services.PostCommit(newCommit)
		if ec != nil {
			return ListErr
		}

	case "tag":

		oldTag, tagErr := services.GetTag(d.leaf.(objects.HKID), r.OldName)
		var newTag objects.Tag
		if tagErr == nil {
			newTag = objects.NewTag(
				oldTag.HashBytes,
				oldTag.TypeString,
				r.NewName,
				[]objects.HCID{oldTag.Hash()},
				d.leaf.(objects.HKID),
			)
		} else {
			log.Printf("Tag %s\\%s Not Found", d.leaf, d.name)
			return fuse.ENOENT
		}
		//=========================================================================
		if verbosity == 1 {
			log.Printf(
				"Posting tag %s\n-----BEGIN TAG--------\n%s\n-------END TAG--------",
				newTag.Hash(),
				newTag,
			)
		}
		//=========================================================================
		et := services.PostTag(newTag)
		if et != nil {
			return tagErr
		}
	} //end switch

	return nil
}