Ejemplo n.º 1
0
func (this *DirHandler) deleteHandler(w http.ResponseWriter, src string) {
	glog.V(2).Infoln("search DELETE handler")
	path, file := common.GetSrcComponents(src)
	glog.V(2).Infof("Deleting path: %s, file:%s", path, file)
	if err := this.D.DeleteDir(path, file); err != nil {
		handlerutils.HttpError(w, fmt.Sprintf("An error occured deleting path: %s, file: %s", path, file),
			http.StatusInternalServerError)
		return
	}
}
Ejemplo n.º 2
0
func (c *CassandraDB) WriteDir(si db.SourceInfoUncomp, src string) (err error) {
	glog.V(3).Infoln("Start directory mutation for: " + src)
	path, file := common.GetSrcComponents(src)
	row := &gossie.Row{[]byte("/" + path), nil}

	row.Columns = append(row.Columns, &gossie.Column{
		Name:  []byte(file),
		Value: dbcommon.SerializeSourceInfoUncomp(si),
	})

	err = c.pool.Writer().Insert(dbcommon.CFChildren, row).Run()
	glog.V(3).Infoln("Done directory mutation.")
	return
}
Ejemplo n.º 3
0
func readDir(d db.DB, q url.Values, s string) (db.SourceInfoUncomp, error) {
	returnMetrics := q.Get("returnMetrics") == "1"
	returnUnits := q.Get("returnUnits") == "1"
	returnSelectForDefaults := q.Get("returnSelectForDefaults") == "1"
	defaultsOnly := q.Get("defaultsOnly") == "1"

	var prefixMatch bool
	if (len(s) > 0) && (s[len(s)-1:len(s)] == "*") {
		prefixMatch = true
		s = s[:len(s)-1]
	}

	dirSearchReq := db.DirectorySearchRequest{
		Prefix:                  s,
		FileRestrict:            "",
		ReturnMetrics:           returnMetrics,
		ReturnUnits:             returnUnits,
		ReturnSelectForDefaults: returnSelectForDefaults,
		DefaultsOnly:            defaultsOnly,
		DirPrefixMatch:          prefixMatch,
		FilePrefixMatch:         false}

	// Directory only search.
	sInfo, err := d.ReadDir(dirSearchReq)
	if err != nil {
		return db.SourceInfoUncomp{}, err
	}

	// File only search.
	if len(sInfo.Names) == 0 {
		path, file := common.GetSrcComponents(s)
		dirSearchReq.Prefix = path
		dirSearchReq.FileRestrict = file
		dirSearchReq.DirPrefixMatch = false
		dirSearchReq.FilePrefixMatch = prefixMatch
		sInfo, err = d.ReadDir(dirSearchReq)
		if err != nil {
			return db.SourceInfoUncomp{}, err
		}
	}

	return sInfo, nil
}