id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,700 | perkeep/perkeep | pkg/search/describe.go | noteResultFromRule | func (dr *DescribeRequest) noteResultFromRule(rule *DescribeRule, br blob.Ref) {
if dr.resFromRule == nil {
dr.resFromRule = make(map[*DescribeRule]map[blob.Ref]bool)
}
m, ok := dr.resFromRule[rule]
if !ok {
m = make(map[blob.Ref]bool)
dr.resFromRule[rule] = m
}
m[br] = true
} | go | func (dr *DescribeRequest) noteResultFromRule(rule *DescribeRule, br blob.Ref) {
if dr.resFromRule == nil {
dr.resFromRule = make(map[*DescribeRule]map[blob.Ref]bool)
}
m, ok := dr.resFromRule[rule]
if !ok {
m = make(map[blob.Ref]bool)
dr.resFromRule[rule] = m
}
m[br] = true
} | [
"func",
"(",
"dr",
"*",
"DescribeRequest",
")",
"noteResultFromRule",
"(",
"rule",
"*",
"DescribeRule",
",",
"br",
"blob",
".",
"Ref",
")",
"{",
"if",
"dr",
".",
"resFromRule",
"==",
"nil",
"{",
"dr",
".",
"resFromRule",
"=",
"make",
"(",
"map",
"[",
... | // dr.mu just be locked. | [
"dr",
".",
"mu",
"just",
"be",
"locked",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/describe.go#L675-L685 |
31,701 | perkeep/perkeep | clients/web/embed/closure/updatelibrary.go | fileList | func fileList() ([]string, error) {
camliRootPath, err := osutil.GoPackagePath("perkeep.org")
if err != nil {
log.Fatal("Package perkeep.org not found in $GOPATH (or $GOPATH not defined).")
}
uiDir := filepath.Join(camliRootPath, "server", "perkeepd", "ui")
closureDepsFile := filepath.Join(closureGitDir, "closur... | go | func fileList() ([]string, error) {
camliRootPath, err := osutil.GoPackagePath("perkeep.org")
if err != nil {
log.Fatal("Package perkeep.org not found in $GOPATH (or $GOPATH not defined).")
}
uiDir := filepath.Join(camliRootPath, "server", "perkeepd", "ui")
closureDepsFile := filepath.Join(closureGitDir, "closur... | [
"func",
"fileList",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"camliRootPath",
",",
"err",
":=",
"osutil",
".",
"GoPackagePath",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"\"",
"\"",
")"... | // fileList parses deps.js from the closure repo, as well as the similar
// dependencies generated for the UI js files, and compiles the list of
// js files from the closure lib required for the UI. | [
"fileList",
"parses",
"deps",
".",
"js",
"from",
"the",
"closure",
"repo",
"as",
"well",
"as",
"the",
"similar",
"dependencies",
"generated",
"for",
"the",
"UI",
"js",
"files",
"and",
"compiles",
"the",
"list",
"of",
"js",
"files",
"from",
"the",
"closure"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/clients/web/embed/closure/updatelibrary.go#L65-L126 |
31,702 | perkeep/perkeep | clients/web/embed/closure/updatelibrary.go | run | func (c *command) run() []byte {
cmd := exec.Command(c.program, c.args...)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
out := stdout.Bytes()
if err != nil {
log.Fatalf("Could not run %v: %v: %v: %v", c, err, string(out), stderr.String())
}
return out
} | go | func (c *command) run() []byte {
cmd := exec.Command(c.program, c.args...)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
out := stdout.Bytes()
if err != nil {
log.Fatalf("Could not run %v: %v: %v: %v", c, err, string(out), stderr.String())
}
return out
} | [
"func",
"(",
"c",
"*",
"command",
")",
"run",
"(",
")",
"[",
"]",
"byte",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"c",
".",
"program",
",",
"c",
".",
"args",
"...",
")",
"\n",
"var",
"stdout",
",",
"stderr",
"bytes",
".",
"Buffer",
"\n",... | // run runs the command and returns the output if it succeeds.
// On error, the process dies. | [
"run",
"runs",
"the",
"command",
"and",
"returns",
"the",
"output",
"if",
"it",
"succeeds",
".",
"On",
"error",
"the",
"process",
"dies",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/clients/web/embed/closure/updatelibrary.go#L143-L154 |
31,703 | perkeep/perkeep | pkg/sorted/mongo/mongokv.go | Delete | func (kv *keyValue) Delete(key string) error {
kv.mu.Lock()
defer kv.mu.Unlock()
err := kv.db.Remove(&bson.M{mgoKey: key})
if err == mgo.ErrNotFound {
return nil
}
return err
} | go | func (kv *keyValue) Delete(key string) error {
kv.mu.Lock()
defer kv.mu.Unlock()
err := kv.db.Remove(&bson.M{mgoKey: key})
if err == mgo.ErrNotFound {
return nil
}
return err
} | [
"func",
"(",
"kv",
"*",
"keyValue",
")",
"Delete",
"(",
"key",
"string",
")",
"error",
"{",
"kv",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"kv",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"err",
":=",
"kv",
".",
"db",
".",
"Remove",
"(... | // Delete removes the document with the matching key. | [
"Delete",
"removes",
"the",
"document",
"with",
"the",
"matching",
"key",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mongo/mongokv.go#L159-L167 |
31,704 | perkeep/perkeep | pkg/sorted/mongo/mongokv.go | Wipe | func (kv *keyValue) Wipe() error {
kv.mu.Lock()
defer kv.mu.Unlock()
_, err := kv.db.RemoveAll(nil)
return err
} | go | func (kv *keyValue) Wipe() error {
kv.mu.Lock()
defer kv.mu.Unlock()
_, err := kv.db.RemoveAll(nil)
return err
} | [
"func",
"(",
"kv",
"*",
"keyValue",
")",
"Wipe",
"(",
")",
"error",
"{",
"kv",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"kv",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"kv",
".",
"db",
".",
"RemoveAll",
"(",
"... | // Wipe removes all documents from the collection. | [
"Wipe",
"removes",
"all",
"documents",
"from",
"the",
"collection",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mongo/mongokv.go#L170-L175 |
31,705 | perkeep/perkeep | pkg/sorted/mongo/mongokv.go | Ping | func Ping(host string, timeout time.Duration) bool {
return (&instance{server: host}).ping(timeout)
} | go | func Ping(host string, timeout time.Duration) bool {
return (&instance{server: host}).ping(timeout)
} | [
"func",
"Ping",
"(",
"host",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"bool",
"{",
"return",
"(",
"&",
"instance",
"{",
"server",
":",
"host",
"}",
")",
".",
"ping",
"(",
"timeout",
")",
"\n",
"}"
] | // Ping tests if MongoDB on host can be dialed. | [
"Ping",
"tests",
"if",
"MongoDB",
"on",
"host",
"can",
"be",
"dialed",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mongo/mongokv.go#L217-L219 |
31,706 | perkeep/perkeep | pkg/search/handler.go | SendStatusUpdate | func (h *Handler) SendStatusUpdate(status json.RawMessage) {
h.wsHub.statusUpdate <- status
} | go | func (h *Handler) SendStatusUpdate(status json.RawMessage) {
h.wsHub.statusUpdate <- status
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"SendStatusUpdate",
"(",
"status",
"json",
".",
"RawMessage",
")",
"{",
"h",
".",
"wsHub",
".",
"statusUpdate",
"<-",
"status",
"\n",
"}"
] | // SendStatusUpdate sends a JSON status map to any connected WebSocket clients. | [
"SendStatusUpdate",
"sends",
"a",
"JSON",
"status",
"map",
"to",
"any",
"connected",
"WebSocket",
"clients",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L137-L139 |
31,707 | perkeep/perkeep | pkg/search/handler.go | HasLegacySHA1 | func (h *Handler) HasLegacySHA1() bool {
idx, ok := h.index.(*index.Index)
if !ok {
log.Printf("Cannot guess for legacy SHA1 because we don't have an *index.Index")
return false
}
ok, err := idx.HasLegacySHA1()
if err != nil {
log.Printf("Cannot guess for legacy SHA1: %v", err)
return false
}
return ok
} | go | func (h *Handler) HasLegacySHA1() bool {
idx, ok := h.index.(*index.Index)
if !ok {
log.Printf("Cannot guess for legacy SHA1 because we don't have an *index.Index")
return false
}
ok, err := idx.HasLegacySHA1()
if err != nil {
log.Printf("Cannot guess for legacy SHA1: %v", err)
return false
}
return ok
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"HasLegacySHA1",
"(",
")",
"bool",
"{",
"idx",
",",
"ok",
":=",
"h",
".",
"index",
".",
"(",
"*",
"index",
".",
"Index",
")",
"\n",
"if",
"!",
"ok",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",... | // HasLegacySHA1 reports whether the server has legacy SHA-1 blobs indexed. | [
"HasLegacySHA1",
"reports",
"whether",
"the",
"server",
"has",
"legacy",
"SHA",
"-",
"1",
"blobs",
"indexed",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L220-L232 |
31,708 | perkeep/perkeep | pkg/search/handler.go | GetRecentPermanodes | func (h *Handler) GetRecentPermanodes(ctx context.Context, req *RecentRequest) (*RecentResponse, error) {
h.index.RLock()
defer h.index.RUnlock()
ch := make(chan camtypes.RecentPermanode)
errch := make(chan error, 1)
before := time.Now()
if !req.Before.IsZero() {
before = req.Before
}
go func() {
// TODO(m... | go | func (h *Handler) GetRecentPermanodes(ctx context.Context, req *RecentRequest) (*RecentResponse, error) {
h.index.RLock()
defer h.index.RUnlock()
ch := make(chan camtypes.RecentPermanode)
errch := make(chan error, 1)
before := time.Now()
if !req.Before.IsZero() {
before = req.Before
}
go func() {
// TODO(m... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"GetRecentPermanodes",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"RecentRequest",
")",
"(",
"*",
"RecentResponse",
",",
"error",
")",
"{",
"h",
".",
"index",
".",
"RLock",
"(",
")",
"\n",
"defer",
... | // GetRecentPermanodes returns recently-modified permanodes. | [
"GetRecentPermanodes",
"returns",
"recently",
"-",
"modified",
"permanodes",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L514-L557 |
31,709 | perkeep/perkeep | pkg/search/handler.go | GetPermanodesWithAttr | func (h *Handler) GetPermanodesWithAttr(req *WithAttrRequest) (*WithAttrResponse, error) {
ctx := context.TODO()
h.index.RLock()
defer h.index.RUnlock()
ch := make(chan blob.Ref, buffered)
errch := make(chan error, 1)
go func() {
signer := req.Signer
if !signer.Valid() {
signer = h.owner.BlobRef()
}
... | go | func (h *Handler) GetPermanodesWithAttr(req *WithAttrRequest) (*WithAttrResponse, error) {
ctx := context.TODO()
h.index.RLock()
defer h.index.RUnlock()
ch := make(chan blob.Ref, buffered)
errch := make(chan error, 1)
go func() {
signer := req.Signer
if !signer.Valid() {
signer = h.owner.BlobRef()
}
... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"GetPermanodesWithAttr",
"(",
"req",
"*",
"WithAttrRequest",
")",
"(",
"*",
"WithAttrResponse",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n\n",
"h",
".",
"index",
".",
"RLock",
"(",
... | // GetPermanodesWithAttr returns permanodes with attribute req.Attr
// having the req.Value as a value.
// See WithAttrRequest for more details about the query. | [
"GetPermanodesWithAttr",
"returns",
"permanodes",
"with",
"attribute",
"req",
".",
"Attr",
"having",
"the",
"req",
".",
"Value",
"as",
"a",
"value",
".",
"See",
"WithAttrRequest",
"for",
"more",
"details",
"about",
"the",
"query",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L574-L622 |
31,710 | perkeep/perkeep | pkg/search/handler.go | GetClaims | func (h *Handler) GetClaims(req *ClaimsRequest) (*ClaimsResponse, error) {
if !req.Permanode.Valid() {
return nil, errors.New("error getting claims: nil permanode")
}
h.index.RLock()
defer h.index.RUnlock()
ctx := context.TODO()
var claims []camtypes.Claim
claims, err := h.index.AppendClaims(ctx, claims, req.... | go | func (h *Handler) GetClaims(req *ClaimsRequest) (*ClaimsResponse, error) {
if !req.Permanode.Valid() {
return nil, errors.New("error getting claims: nil permanode")
}
h.index.RLock()
defer h.index.RUnlock()
ctx := context.TODO()
var claims []camtypes.Claim
claims, err := h.index.AppendClaims(ctx, claims, req.... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"GetClaims",
"(",
"req",
"*",
"ClaimsRequest",
")",
"(",
"*",
"ClaimsResponse",
",",
"error",
")",
"{",
"if",
"!",
"req",
".",
"Permanode",
".",
"Valid",
"(",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"Ne... | // GetClaims returns the claims on req.Permanode signed by h.owner. | [
"GetClaims",
"returns",
"the",
"claims",
"on",
"req",
".",
"Permanode",
"signed",
"by",
"h",
".",
"owner",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L641-L673 |
31,711 | perkeep/perkeep | pkg/search/handler.go | EdgesTo | func (h *Handler) EdgesTo(req *EdgesRequest) (*EdgesResponse, error) {
ctx := context.TODO()
h.index.RLock()
defer h.index.RUnlock()
toRef := req.ToRef
toRefStr := toRef.String()
var edgeItems []*EdgeItem
edges, err := h.index.EdgesTo(toRef, nil)
if err != nil {
panic(err)
}
type edgeOrError struct {
e... | go | func (h *Handler) EdgesTo(req *EdgesRequest) (*EdgesResponse, error) {
ctx := context.TODO()
h.index.RLock()
defer h.index.RUnlock()
toRef := req.ToRef
toRefStr := toRef.String()
var edgeItems []*EdgeItem
edges, err := h.index.EdgesTo(toRef, nil)
if err != nil {
panic(err)
}
type edgeOrError struct {
e... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"EdgesTo",
"(",
"req",
"*",
"EdgesRequest",
")",
"(",
"*",
"EdgesResponse",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n",
"h",
".",
"index",
".",
"RLock",
"(",
")",
"\n",
"defe... | // EdgesTo returns edges that reference req.RefTo.
// It filters out since-deleted permanode edges. | [
"EdgesTo",
"returns",
"edges",
"that",
"reference",
"req",
".",
"RefTo",
".",
"It",
"filters",
"out",
"since",
"-",
"deleted",
"permanode",
"edges",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L770-L843 |
31,712 | perkeep/perkeep | pkg/search/handler.go | serveEdgesTo | func (h *Handler) serveEdgesTo(rw http.ResponseWriter, req *http.Request) {
defer httputil.RecoverJSON(rw, req)
var er EdgesRequest
er.fromHTTP(req)
res, err := h.EdgesTo(&er)
if err != nil {
httputil.ServeJSONError(rw, err)
return
}
httputil.ReturnJSON(rw, res)
} | go | func (h *Handler) serveEdgesTo(rw http.ResponseWriter, req *http.Request) {
defer httputil.RecoverJSON(rw, req)
var er EdgesRequest
er.fromHTTP(req)
res, err := h.EdgesTo(&er)
if err != nil {
httputil.ServeJSONError(rw, err)
return
}
httputil.ReturnJSON(rw, res)
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"serveEdgesTo",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"httputil",
".",
"RecoverJSON",
"(",
"rw",
",",
"req",
")",
"\n",
"var",
"er",
"EdgesRequest",
... | // Unlike the index interface's EdgesTo method, the "edgesto" Handler
// here additionally filters out since-deleted permanode edges. | [
"Unlike",
"the",
"index",
"interface",
"s",
"EdgesTo",
"method",
"the",
"edgesto",
"Handler",
"here",
"additionally",
"filters",
"out",
"since",
"-",
"deleted",
"permanode",
"edges",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L847-L857 |
31,713 | perkeep/perkeep | pkg/search/handler.go | GetSignerPaths | func (h *Handler) GetSignerPaths(req *SignerPathsRequest) (*SignerPathsResponse, error) {
ctx := context.TODO()
if !req.Signer.Valid() {
return nil, errors.New("error getting signer paths: nil signer")
}
if !req.Target.Valid() {
return nil, errors.New("error getting signer paths: nil target")
}
h.index.RLock(... | go | func (h *Handler) GetSignerPaths(req *SignerPathsRequest) (*SignerPathsResponse, error) {
ctx := context.TODO()
if !req.Signer.Valid() {
return nil, errors.New("error getting signer paths: nil signer")
}
if !req.Target.Valid() {
return nil, errors.New("error getting signer paths: nil target")
}
h.index.RLock(... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"GetSignerPaths",
"(",
"req",
"*",
"SignerPathsRequest",
")",
"(",
"*",
"SignerPathsResponse",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n",
"if",
"!",
"req",
".",
"Signer",
".",
"... | // GetSignerPaths returns paths with a target of req.Target. | [
"GetSignerPaths",
"returns",
"paths",
"with",
"a",
"target",
"of",
"req",
".",
"Target",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L878-L916 |
31,714 | perkeep/perkeep | pkg/search/handler.go | evalSearchInput | func evalSearchInput(in string) (*Constraint, error) {
if len(in) == 0 {
return nil, fmt.Errorf("empty expression")
}
if strings.HasPrefix(in, "{") && strings.HasSuffix(in, "}") {
cs := new(Constraint)
if err := json.NewDecoder(strings.NewReader(in)).Decode(&cs); err != nil {
return nil, err
}
return cs... | go | func evalSearchInput(in string) (*Constraint, error) {
if len(in) == 0 {
return nil, fmt.Errorf("empty expression")
}
if strings.HasPrefix(in, "{") && strings.HasSuffix(in, "}") {
cs := new(Constraint)
if err := json.NewDecoder(strings.NewReader(in)).Decode(&cs); err != nil {
return nil, err
}
return cs... | [
"func",
"evalSearchInput",
"(",
"in",
"string",
")",
"(",
"*",
"Constraint",
",",
"error",
")",
"{",
"if",
"len",
"(",
"in",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"strings",
... | // EvalSearchInput checks if its input is JSON. If so it returns a Constraint constructed from that JSON. Otherwise
// it assumes the input to be a search expression. It parses the expression and returns the parsed Constraint. | [
"EvalSearchInput",
"checks",
"if",
"its",
"input",
"is",
"JSON",
".",
"If",
"so",
"it",
"returns",
"a",
"Constraint",
"constructed",
"from",
"that",
"JSON",
".",
"Otherwise",
"it",
"assumes",
"the",
"input",
"to",
"be",
"a",
"search",
"expression",
".",
"I... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L933-L950 |
31,715 | perkeep/perkeep | pkg/search/handler.go | getNamed | func (sh *Handler) getNamed(ctx context.Context, name string) (string, error) {
if sh.fetcher == nil {
return "", fmt.Errorf("GetNamed functionality not available")
}
sr, err := sh.Query(ctx, NamedSearch(name))
if err != nil {
return "", err
}
if len(sr.Blobs) < 1 {
return "", fmt.Errorf("No named search f... | go | func (sh *Handler) getNamed(ctx context.Context, name string) (string, error) {
if sh.fetcher == nil {
return "", fmt.Errorf("GetNamed functionality not available")
}
sr, err := sh.Query(ctx, NamedSearch(name))
if err != nil {
return "", err
}
if len(sr.Blobs) < 1 {
return "", fmt.Errorf("No named search f... | [
"func",
"(",
"sh",
"*",
"Handler",
")",
"getNamed",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"sh",
".",
"fetcher",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Er... | // getNamed displays the search expression or constraint json for the requested alias. | [
"getNamed",
"displays",
"the",
"search",
"expression",
"or",
"constraint",
"json",
"for",
"the",
"requested",
"alias",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/handler.go#L953-L981 |
31,716 | perkeep/perkeep | app/scanningcabinet/tags.go | newSeparatedString | func newSeparatedString(commaSeparated string) separatedString {
if strings.TrimSpace(commaSeparated) == "" {
return nil
}
split := strings.Split(commaSeparated, ",")
var ss []string
for i, tag := range split {
split[i] = strings.TrimSpace(tag)
if split[i] != "" {
ss = append(ss, split[i])
}
}
if !sor... | go | func newSeparatedString(commaSeparated string) separatedString {
if strings.TrimSpace(commaSeparated) == "" {
return nil
}
split := strings.Split(commaSeparated, ",")
var ss []string
for i, tag := range split {
split[i] = strings.TrimSpace(tag)
if split[i] != "" {
ss = append(ss, split[i])
}
}
if !sor... | [
"func",
"newSeparatedString",
"(",
"commaSeparated",
"string",
")",
"separatedString",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"commaSeparated",
")",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"split",
":=",
"strings",
".",
"Split",
"(",
... | // newSeparatedString returns a newly created SeparatedString value from the string given.
// There is no error if the string does not include a comma. | [
"newSeparatedString",
"returns",
"a",
"newly",
"created",
"SeparatedString",
"value",
"from",
"the",
"string",
"given",
".",
"There",
"is",
"no",
"error",
"if",
"the",
"string",
"does",
"not",
"include",
"a",
"comma",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/tags.go#L28-L44 |
31,717 | perkeep/perkeep | app/scanningcabinet/tags.go | Minus | func (css separatedString) Minus(css2 separatedString) separatedString {
if !sort.StringsAreSorted(css) {
sort.Strings(css)
}
if !sort.StringsAreSorted(css2) {
sort.Strings(css2)
}
k := 0
kMax := len(css2)
keep := css[:0]
for _, s := range css {
for k < kMax && css2[k] < s {
k++
}
if k == kMax || c... | go | func (css separatedString) Minus(css2 separatedString) separatedString {
if !sort.StringsAreSorted(css) {
sort.Strings(css)
}
if !sort.StringsAreSorted(css2) {
sort.Strings(css2)
}
k := 0
kMax := len(css2)
keep := css[:0]
for _, s := range css {
for k < kMax && css2[k] < s {
k++
}
if k == kMax || c... | [
"func",
"(",
"css",
"separatedString",
")",
"Minus",
"(",
"css2",
"separatedString",
")",
"separatedString",
"{",
"if",
"!",
"sort",
".",
"StringsAreSorted",
"(",
"css",
")",
"{",
"sort",
".",
"Strings",
"(",
"css",
")",
"\n",
"}",
"\n",
"if",
"!",
"so... | // Minus returns a newly created SeparatedString containing all the elements from css that did
// not appear in css2 | [
"Minus",
"returns",
"a",
"newly",
"created",
"SeparatedString",
"containing",
"all",
"the",
"elements",
"from",
"css",
"that",
"did",
"not",
"appear",
"in",
"css2"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/tags.go#L63-L82 |
31,718 | perkeep/perkeep | app/scanningcabinet/tags.go | equal | func (css separatedString) equal(css2 separatedString) bool {
if len(css) != len(css2) {
return false
}
if !sort.StringsAreSorted(css) {
sort.Strings(css)
}
if !sort.StringsAreSorted(css2) {
sort.Strings(css2)
}
for k, s := range css {
if s != css2[k] {
return false
}
}
return true
} | go | func (css separatedString) equal(css2 separatedString) bool {
if len(css) != len(css2) {
return false
}
if !sort.StringsAreSorted(css) {
sort.Strings(css)
}
if !sort.StringsAreSorted(css2) {
sort.Strings(css2)
}
for k, s := range css {
if s != css2[k] {
return false
}
}
return true
} | [
"func",
"(",
"css",
"separatedString",
")",
"equal",
"(",
"css2",
"separatedString",
")",
"bool",
"{",
"if",
"len",
"(",
"css",
")",
"!=",
"len",
"(",
"css2",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!",
"sort",
".",
"StringsAreSorted",
"... | // equal compares css with css2. Both css and css2 are sorted in place before being compared. | [
"equal",
"compares",
"css",
"with",
"css2",
".",
"Both",
"css",
"and",
"css2",
"are",
"sorted",
"in",
"place",
"before",
"being",
"compared",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/tags.go#L85-L101 |
31,719 | perkeep/perkeep | pkg/fs/util.go | Unmount | func Unmount(point string) error {
var cmd *exec.Cmd
switch runtime.GOOS {
case "darwin":
cmd = exec.Command("/usr/sbin/diskutil", "umount", "force", point)
case "linux":
cmd = exec.Command("fusermount", "-u", point)
default:
return errors.New("unmount: unimplemented")
}
errc := make(chan error, 1)
go fu... | go | func Unmount(point string) error {
var cmd *exec.Cmd
switch runtime.GOOS {
case "darwin":
cmd = exec.Command("/usr/sbin/diskutil", "umount", "force", point)
case "linux":
cmd = exec.Command("fusermount", "-u", point)
default:
return errors.New("unmount: unimplemented")
}
errc := make(chan error, 1)
go fu... | [
"func",
"Unmount",
"(",
"point",
"string",
")",
"error",
"{",
"var",
"cmd",
"*",
"exec",
".",
"Cmd",
"\n",
"switch",
"runtime",
".",
"GOOS",
"{",
"case",
"\"",
"\"",
":",
"cmd",
"=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
... | // Unmount attempts to unmount the provided FUSE mount point, forcibly
// if necessary. | [
"Unmount",
"attempts",
"to",
"unmount",
"the",
"provided",
"FUSE",
"mount",
"point",
"forcibly",
"if",
"necessary",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/util.go#L28-L53 |
31,720 | perkeep/perkeep | pkg/blobserver/sftp/sftp.go | markConnDead | func (s *Storage) markConnDead() {
s.mu.Lock()
defer s.mu.Unlock()
s.markConnDeadLocked()
} | go | func (s *Storage) markConnDead() {
s.mu.Lock()
defer s.mu.Unlock()
s.markConnDeadLocked()
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"markConnDead",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"markConnDeadLocked",
"(",
")",
"\n",
"}"
] | // markConnDead clears the cached SFTP connection after the caller detects
// a connection failure. | [
"markConnDead",
"clears",
"the",
"cached",
"SFTP",
"connection",
"after",
"the",
"caller",
"detects",
"a",
"connection",
"failure",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/sftp/sftp.go#L194-L198 |
31,721 | perkeep/perkeep | make.go | fetchJS | func fetchJS(jsURL, jsOnDisk string) error {
var currentSum string
_, err := os.Stat(jsOnDisk)
if err != nil {
if !os.IsNotExist(err) {
return err
}
} else {
// If yes, compute its hash
h := sha256.New()
f, err := os.Open(jsOnDisk)
if err != nil {
return err
}
defer f.Close()
if _, err := io... | go | func fetchJS(jsURL, jsOnDisk string) error {
var currentSum string
_, err := os.Stat(jsOnDisk)
if err != nil {
if !os.IsNotExist(err) {
return err
}
} else {
// If yes, compute its hash
h := sha256.New()
f, err := os.Open(jsOnDisk)
if err != nil {
return err
}
defer f.Close()
if _, err := io... | [
"func",
"fetchJS",
"(",
"jsURL",
",",
"jsOnDisk",
"string",
")",
"error",
"{",
"var",
"currentSum",
"string",
"\n",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"jsOnDisk",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"!",
"os",
".",
"IsNotExi... | // fetchJS gets the javascript resource at jsURL and writes it to jsOnDisk.
// Since said resource can be quite large, it first fetches the hashsum contained
// in the file at jsURL+".sha256", and if we already have the file on disk, with a
// matching hashsum, it does not actually fetch jsURL. If it does, it checks th... | [
"fetchJS",
"gets",
"the",
"javascript",
"resource",
"at",
"jsURL",
"and",
"writes",
"it",
"to",
"jsOnDisk",
".",
"Since",
"said",
"resource",
"can",
"be",
"quite",
"large",
"it",
"first",
"fetches",
"the",
"hashsum",
"contained",
"in",
"the",
"file",
"at",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/make.go#L525-L589 |
31,722 | perkeep/perkeep | make.go | fullSrcPath | func fullSrcPath(fromSrc string) string {
return filepath.Join(pkRoot, filepath.FromSlash(fromSrc))
} | go | func fullSrcPath(fromSrc string) string {
return filepath.Join(pkRoot, filepath.FromSlash(fromSrc))
} | [
"func",
"fullSrcPath",
"(",
"fromSrc",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"pkRoot",
",",
"filepath",
".",
"FromSlash",
"(",
"fromSrc",
")",
")",
"\n",
"}"
] | // fullSrcPath returns the full path concatenation
// of pkRoot with fromSrc. | [
"fullSrcPath",
"returns",
"the",
"full",
"path",
"concatenation",
"of",
"pkRoot",
"with",
"fromSrc",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/make.go#L687-L689 |
31,723 | perkeep/perkeep | make.go | getVersion | func getVersion() string {
slurp, err := ioutil.ReadFile(filepath.Join(pkRoot, "VERSION"))
v := strings.TrimSpace(string(slurp))
if err != nil && !os.IsNotExist(err) {
log.Fatal(err)
}
if v == "" {
return "unknown"
}
return v
} | go | func getVersion() string {
slurp, err := ioutil.ReadFile(filepath.Join(pkRoot, "VERSION"))
v := strings.TrimSpace(string(slurp))
if err != nil && !os.IsNotExist(err) {
log.Fatal(err)
}
if v == "" {
return "unknown"
}
return v
} | [
"func",
"getVersion",
"(",
")",
"string",
"{",
"slurp",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Join",
"(",
"pkRoot",
",",
"\"",
"\"",
")",
")",
"\n",
"v",
":=",
"strings",
".",
"TrimSpace",
"(",
"string",
"(",
"slurp",
... | // getVersion returns the version of Perkeep found in a VERSION file at the root. | [
"getVersion",
"returns",
"the",
"version",
"of",
"Perkeep",
"found",
"in",
"a",
"VERSION",
"file",
"at",
"the",
"root",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/make.go#L765-L775 |
31,724 | perkeep/perkeep | make.go | getGitVersion | func getGitVersion() string {
if _, err := exec.LookPath("git"); err != nil {
return ""
}
if _, err := os.Stat(filepath.Join(pkRoot, ".git")); os.IsNotExist(err) {
return ""
}
cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'",
"--date=short", "--abbrev=10", "HEAD")
cmd.Dir =... | go | func getGitVersion() string {
if _, err := exec.LookPath("git"); err != nil {
return ""
}
if _, err := os.Stat(filepath.Join(pkRoot, ".git")); os.IsNotExist(err) {
return ""
}
cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'",
"--date=short", "--abbrev=10", "HEAD")
cmd.Dir =... | [
"func",
"getGitVersion",
"(",
")",
"string",
"{",
"if",
"_",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
... | // getGitVersion returns the git version of the git repo at pkRoot as a
// string of the form "yyyy-mm-dd-xxxxxxx", with an optional trailing
// '+' if there are any local uncommitted modifications to the tree. | [
"getGitVersion",
"returns",
"the",
"git",
"version",
"of",
"the",
"git",
"repo",
"at",
"pkRoot",
"as",
"a",
"string",
"of",
"the",
"form",
"yyyy",
"-",
"mm",
"-",
"dd",
"-",
"xxxxxxx",
"with",
"an",
"optional",
"trailing",
"+",
"if",
"there",
"are",
"a... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/make.go#L782-L808 |
31,725 | perkeep/perkeep | make.go | verifyPerkeepRoot | func verifyPerkeepRoot() {
var err error
pkRoot, err = os.Getwd()
if err != nil {
log.Fatalf("Failed to get current directory: %v", err)
}
testFile := filepath.Join(pkRoot, "pkg", "blob", "ref.go")
if _, err := os.Stat(testFile); err != nil {
log.Fatalf("make.go must be run from the Perkeep src root directory... | go | func verifyPerkeepRoot() {
var err error
pkRoot, err = os.Getwd()
if err != nil {
log.Fatalf("Failed to get current directory: %v", err)
}
testFile := filepath.Join(pkRoot, "pkg", "blob", "ref.go")
if _, err := os.Stat(testFile); err != nil {
log.Fatalf("make.go must be run from the Perkeep src root directory... | [
"func",
"verifyPerkeepRoot",
"(",
")",
"{",
"var",
"err",
"error",
"\n",
"pkRoot",
",",
"err",
"=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"tes... | // verifyPerkeepRoot sets pkRoot and crashes if dir isn't the Perkeep root directory. | [
"verifyPerkeepRoot",
"sets",
"pkRoot",
"and",
"crashes",
"if",
"dir",
"isn",
"t",
"the",
"Perkeep",
"root",
"directory",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/make.go#L811-L839 |
31,726 | perkeep/perkeep | make.go | verifyGoVersion | func verifyGoVersion() {
_, err := exec.LookPath("go")
if err != nil {
log.Fatalf("Go doesn't appear to be installed ('go' isn't in your PATH). Install Go 1.%d or newer.", goVersionMinor)
}
out, err := exec.Command("go", "version").Output()
if err != nil {
log.Fatalf("Error checking Go version with the 'go' co... | go | func verifyGoVersion() {
_, err := exec.LookPath("go")
if err != nil {
log.Fatalf("Go doesn't appear to be installed ('go' isn't in your PATH). Install Go 1.%d or newer.", goVersionMinor)
}
out, err := exec.Command("go", "version").Output()
if err != nil {
log.Fatalf("Error checking Go version with the 'go' co... | [
"func",
"verifyGoVersion",
"(",
")",
"{",
"_",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"goVersionMinor",
")",
"\n",
"}",
"\n",
"out",
",",
... | // verifyGoVersion runs "go version" and parses the output. If the version is
// acceptable a check for gopherjs versions are also done. If problems
// are found a message is logged and we abort. | [
"verifyGoVersion",
"runs",
"go",
"version",
"and",
"parses",
"the",
"output",
".",
"If",
"the",
"version",
"is",
"acceptable",
"a",
"check",
"for",
"gopherjs",
"versions",
"are",
"also",
"done",
".",
"If",
"problems",
"are",
"found",
"a",
"message",
"is",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/make.go#L888-L927 |
31,727 | perkeep/perkeep | make.go | quote | func quote(dest *bytes.Buffer, bs []byte) {
dest.WriteByte('"')
for _, b := range bs {
if b == '\n' {
dest.WriteString(`\n`)
continue
}
if b == '\\' {
dest.WriteString(`\\`)
continue
}
if b == '"' {
dest.WriteString(`\"`)
continue
}
if (b >= 32 && b <= 126) || b == '\t' {
dest.Write... | go | func quote(dest *bytes.Buffer, bs []byte) {
dest.WriteByte('"')
for _, b := range bs {
if b == '\n' {
dest.WriteString(`\n`)
continue
}
if b == '\\' {
dest.WriteString(`\\`)
continue
}
if b == '"' {
dest.WriteString(`\"`)
continue
}
if (b >= 32 && b <= 126) || b == '\t' {
dest.Write... | [
"func",
"quote",
"(",
"dest",
"*",
"bytes",
".",
"Buffer",
",",
"bs",
"[",
"]",
"byte",
")",
"{",
"dest",
".",
"WriteByte",
"(",
"'\"'",
")",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
"bs",
"{",
"if",
"b",
"==",
"'\\n'",
"{",
"dest",
".",
"W... | // quote escapes and quotes the bytes from bs and writes
// them to dest. | [
"quote",
"escapes",
"and",
"quotes",
"the",
"bytes",
"from",
"bs",
"and",
"writes",
"them",
"to",
"dest",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/make.go#L1155-L1177 |
31,728 | perkeep/perkeep | pkg/blobserver/union/union.go | ReceiveBlob | func (sto *unionStorage) ReceiveBlob(ctx context.Context, br blob.Ref, src io.Reader) (sb blob.SizedRef, err error) {
return blob.SizedRef{}, blobserver.ErrReadonly
} | go | func (sto *unionStorage) ReceiveBlob(ctx context.Context, br blob.Ref, src io.Reader) (sb blob.SizedRef, err error) {
return blob.SizedRef{}, blobserver.ErrReadonly
} | [
"func",
"(",
"sto",
"*",
"unionStorage",
")",
"ReceiveBlob",
"(",
"ctx",
"context",
".",
"Context",
",",
"br",
"blob",
".",
"Ref",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"sb",
"blob",
".",
"SizedRef",
",",
"err",
"error",
")",
"{",
"return",
"b... | // ReceiveBlob would receive the blobs, but now just returns ErrReadonly. | [
"ReceiveBlob",
"would",
"receive",
"the",
"blobs",
"but",
"now",
"just",
"returns",
"ErrReadonly",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/union/union.go#L56-L58 |
31,729 | perkeep/perkeep | pkg/blobserver/union/union.go | RemoveBlobs | func (sto *unionStorage) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error {
return blobserver.ErrReadonly
} | go | func (sto *unionStorage) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error {
return blobserver.ErrReadonly
} | [
"func",
"(",
"sto",
"*",
"unionStorage",
")",
"RemoveBlobs",
"(",
"ctx",
"context",
".",
"Context",
",",
"blobs",
"[",
"]",
"blob",
".",
"Ref",
")",
"error",
"{",
"return",
"blobserver",
".",
"ErrReadonly",
"\n",
"}"
] | // RemoveBlobs would remove the given blobs, but now just returns ErrReadonly. | [
"RemoveBlobs",
"would",
"remove",
"the",
"given",
"blobs",
"but",
"now",
"just",
"returns",
"ErrReadonly",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/union/union.go#L61-L63 |
31,730 | perkeep/perkeep | pkg/blobserver/union/union.go | Fetch | func (sto *unionStorage) Fetch(ctx context.Context, b blob.Ref) (file io.ReadCloser, size uint32, err error) {
type result struct {
file io.ReadCloser
size uint32
err error
}
results := make(chan result, len(sto.subsets))
var wg sync.WaitGroup
for _, bs := range sto.subsets {
bs := bs
wg.Add(1)
go fun... | go | func (sto *unionStorage) Fetch(ctx context.Context, b blob.Ref) (file io.ReadCloser, size uint32, err error) {
type result struct {
file io.ReadCloser
size uint32
err error
}
results := make(chan result, len(sto.subsets))
var wg sync.WaitGroup
for _, bs := range sto.subsets {
bs := bs
wg.Add(1)
go fun... | [
"func",
"(",
"sto",
"*",
"unionStorage",
")",
"Fetch",
"(",
"ctx",
"context",
".",
"Context",
",",
"b",
"blob",
".",
"Ref",
")",
"(",
"file",
"io",
".",
"ReadCloser",
",",
"size",
"uint32",
",",
"err",
"error",
")",
"{",
"type",
"result",
"struct",
... | // Fetch the blob by trying all configured read Storage concurrently,
// returning the first successful response, or the first error if there's no match. | [
"Fetch",
"the",
"blob",
"by",
"trying",
"all",
"configured",
"read",
"Storage",
"concurrently",
"returning",
"the",
"first",
"successful",
"response",
"or",
"the",
"first",
"error",
"if",
"there",
"s",
"no",
"match",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/union/union.go#L67-L111 |
31,731 | perkeep/perkeep | pkg/blobserver/union/union.go | EnumerateBlobs | func (sto *unionStorage) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error {
return blobserver.MergedEnumerateStorage(ctx, dest, sto.subsets, after, limit)
} | go | func (sto *unionStorage) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error {
return blobserver.MergedEnumerateStorage(ctx, dest, sto.subsets, after, limit)
} | [
"func",
"(",
"sto",
"*",
"unionStorage",
")",
"EnumerateBlobs",
"(",
"ctx",
"context",
".",
"Context",
",",
"dest",
"chan",
"<-",
"blob",
".",
"SizedRef",
",",
"after",
"string",
",",
"limit",
"int",
")",
"error",
"{",
"return",
"blobserver",
".",
"Merge... | // EnumerateBlobs concurrently on the readers, returning one of the errors. | [
"EnumerateBlobs",
"concurrently",
"on",
"the",
"readers",
"returning",
"one",
"of",
"the",
"errors",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/union/union.go#L171-L173 |
31,732 | perkeep/perkeep | server/camnetdns/camnetdns.go | Set | func (cs cachedStore) Set(key, value string) error {
// check if record already exists
ctx := context.Background()
dk := datastore.NewKey(ctx, "camnetdns", key, 0, nil)
var oldValue dsValue
if err := cs.dsClient.Get(ctx, dk, &oldValue); err != nil {
if err != datastore.ErrNoSuchEntity {
return fmt.Errorf("err... | go | func (cs cachedStore) Set(key, value string) error {
// check if record already exists
ctx := context.Background()
dk := datastore.NewKey(ctx, "camnetdns", key, 0, nil)
var oldValue dsValue
if err := cs.dsClient.Get(ctx, dk, &oldValue); err != nil {
if err != datastore.ErrNoSuchEntity {
return fmt.Errorf("err... | [
"func",
"(",
"cs",
"cachedStore",
")",
"Set",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"// check if record already exists",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"dk",
":=",
"datastore",
".",
"NewKey",
"(",
"ctx",
",",
... | // Set writes the key, value pair to cs. But it does not actually write if the
// value already exists, is up to date, and is more recent than 30 days. | [
"Set",
"writes",
"the",
"key",
"value",
"pair",
"to",
"cs",
".",
"But",
"it",
"does",
"not",
"actually",
"write",
"if",
"the",
"value",
"already",
"exists",
"is",
"up",
"to",
"date",
"and",
"is",
"more",
"recent",
"than",
"30",
"days",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/camnetdns/camnetdns.go#L159-L183 |
31,733 | perkeep/perkeep | pkg/blobserver/s3/s3.go | newFromConfigWithTransport | func newFromConfigWithTransport(_ blobserver.Loader, config jsonconfig.Obj, transport http.RoundTripper) (blobserver.Storage, error) {
hostname := config.OptionalString("hostname", "")
region := config.OptionalString("aws_region", "us-east-1")
cacheSize := config.OptionalInt64("cacheSize", 32<<20)
s3Cfg := aws.New... | go | func newFromConfigWithTransport(_ blobserver.Loader, config jsonconfig.Obj, transport http.RoundTripper) (blobserver.Storage, error) {
hostname := config.OptionalString("hostname", "")
region := config.OptionalString("aws_region", "us-east-1")
cacheSize := config.OptionalInt64("cacheSize", 32<<20)
s3Cfg := aws.New... | [
"func",
"newFromConfigWithTransport",
"(",
"_",
"blobserver",
".",
"Loader",
",",
"config",
"jsonconfig",
".",
"Obj",
",",
"transport",
"http",
".",
"RoundTripper",
")",
"(",
"blobserver",
".",
"Storage",
",",
"error",
")",
"{",
"hostname",
":=",
"config",
"... | // newFromConfigWithTransport constructs a s3 blobserver using the given
// transport for all s3 requests. The transport may be set to 'nil' to use a
// default transport.
// This is used for unit tests. | [
"newFromConfigWithTransport",
"constructs",
"a",
"s3",
"blobserver",
"using",
"the",
"given",
"transport",
"for",
"all",
"s3",
"requests",
".",
"The",
"transport",
"may",
"be",
"set",
"to",
"nil",
"to",
"use",
"a",
"default",
"transport",
".",
"This",
"is",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/s3/s3.go#L103-L169 |
31,734 | perkeep/perkeep | pkg/blobserver/s3/s3.go | isNotFound | func isNotFound(err error) bool {
if err == nil {
return false
}
if aerr, ok := err.(awserr.Error); ok {
return aerr.Code() == s3.ErrCodeNoSuchKey ||
// Check 'NotFound' as well because it's returned for some requests, even
// though the API model doesn't include it (hence why there isn't an
// 's3.ErrC... | go | func isNotFound(err error) bool {
if err == nil {
return false
}
if aerr, ok := err.(awserr.Error); ok {
return aerr.Code() == s3.ErrCodeNoSuchKey ||
// Check 'NotFound' as well because it's returned for some requests, even
// though the API model doesn't include it (hence why there isn't an
// 's3.ErrC... | [
"func",
"isNotFound",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"aerr",
",",
"ok",
":=",
"err",
".",
"(",
"awserr",
".",
"Error",
")",
";",
"ok",
"{",
"return",
"aerr",
".",
... | // isNotFound checks for s3 errors which indicate the object doesn't exist. | [
"isNotFound",
"checks",
"for",
"s3",
"errors",
"which",
"indicate",
"the",
"object",
"doesn",
"t",
"exist",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/s3/s3.go#L176-L188 |
31,735 | perkeep/perkeep | pkg/server/share.go | bytesHaveSchemaLink | func bytesHaveSchemaLink(br blob.Ref, bb []byte, target blob.Ref) bool {
// Fast path for no:
if !bytes.Contains(bb, []byte(target.String())) {
return false
}
b, err := schema.BlobFromReader(br, bytes.NewReader(bb))
if err != nil {
return false
}
typ := b.Type()
switch typ {
case "file", "bytes":
for _, ... | go | func bytesHaveSchemaLink(br blob.Ref, bb []byte, target blob.Ref) bool {
// Fast path for no:
if !bytes.Contains(bb, []byte(target.String())) {
return false
}
b, err := schema.BlobFromReader(br, bytes.NewReader(bb))
if err != nil {
return false
}
typ := b.Type()
switch typ {
case "file", "bytes":
for _, ... | [
"func",
"bytesHaveSchemaLink",
"(",
"br",
"blob",
".",
"Ref",
",",
"bb",
"[",
"]",
"byte",
",",
"target",
"blob",
".",
"Ref",
")",
"bool",
"{",
"// Fast path for no:",
"if",
"!",
"bytes",
".",
"Contains",
"(",
"bb",
",",
"[",
"]",
"byte",
"(",
"targe... | // bytesHaveSchemaLink reports whether bb is a valid Perkeep schema
// blob and has target somewhere in a schema field used to represent a
// Merkle-tree-ish file or directory. | [
"bytesHaveSchemaLink",
"reports",
"whether",
"bb",
"is",
"a",
"valid",
"Perkeep",
"schema",
"blob",
"and",
"has",
"target",
"somewhere",
"in",
"a",
"schema",
"field",
"used",
"to",
"represent",
"a",
"Merkle",
"-",
"tree",
"-",
"ish",
"file",
"or",
"directory... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/share.go#L316-L352 |
31,736 | perkeep/perkeep | pkg/blobserver/diskpacked/reindex.go | Reindex | func Reindex(root string, overwrite bool, indexConf jsonconfig.Obj) (err error) {
// there is newStorage, but that may open a file for writing
var s = &storage{root: root}
index, err := newIndex(root, indexConf)
if err != nil {
return err
}
defer func() {
closeErr := index.Close()
// just returning the firs... | go | func Reindex(root string, overwrite bool, indexConf jsonconfig.Obj) (err error) {
// there is newStorage, but that may open a file for writing
var s = &storage{root: root}
index, err := newIndex(root, indexConf)
if err != nil {
return err
}
defer func() {
closeErr := index.Close()
// just returning the firs... | [
"func",
"Reindex",
"(",
"root",
"string",
",",
"overwrite",
"bool",
",",
"indexConf",
"jsonconfig",
".",
"Obj",
")",
"(",
"err",
"error",
")",
"{",
"// there is newStorage, but that may open a file for writing",
"var",
"s",
"=",
"&",
"storage",
"{",
"root",
":",... | // Reindex rewrites the index files of the diskpacked .pack files | [
"Reindex",
"rewrites",
"the",
"index",
"files",
"of",
"the",
"diskpacked",
".",
"pack",
"files"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/diskpacked/reindex.go#L42-L75 |
31,737 | perkeep/perkeep | pkg/blobserver/diskpacked/reindex.go | Walk | func (s *storage) Walk(ctx context.Context,
walker func(packID int, ref blob.Ref, offset int64, size uint32) error) error {
// TODO(tgulacsi): proper verbose flag from context
verbose := env.IsDebug()
for i := 0; i >= 0; i++ {
fh, err := os.Open(s.filename(i))
if err != nil {
if os.IsNotExist(err) {
br... | go | func (s *storage) Walk(ctx context.Context,
walker func(packID int, ref blob.Ref, offset int64, size uint32) error) error {
// TODO(tgulacsi): proper verbose flag from context
verbose := env.IsDebug()
for i := 0; i >= 0; i++ {
fh, err := os.Open(s.filename(i))
if err != nil {
if os.IsNotExist(err) {
br... | [
"func",
"(",
"s",
"*",
"storage",
")",
"Walk",
"(",
"ctx",
"context",
".",
"Context",
",",
"walker",
"func",
"(",
"packID",
"int",
",",
"ref",
"blob",
".",
"Ref",
",",
"offset",
"int64",
",",
"size",
"uint32",
")",
"error",
")",
"error",
"{",
"// T... | // Walk walks the storage and calls the walker callback with each blobref
// stops if walker returns non-nil error, and returns that | [
"Walk",
"walks",
"the",
"storage",
"and",
"calls",
"the",
"walker",
"callback",
"with",
"each",
"blobref",
"stops",
"if",
"walker",
"returns",
"non",
"-",
"nil",
"error",
"and",
"returns",
"that"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/diskpacked/reindex.go#L143-L163 |
31,738 | perkeep/perkeep | pkg/blobserver/encrypt/meta.go | makeSingleMetaBlob | func (s *storage) makeSingleMetaBlob(plainBR, encBR blob.Ref, plainSize uint32) []byte {
plain := fmt.Sprintf("#camlistore/encmeta=2\n%s/%d/%s\n", plainBR, plainSize, encBR)
return s.encryptBlob(nil, []byte(plain))
} | go | func (s *storage) makeSingleMetaBlob(plainBR, encBR blob.Ref, plainSize uint32) []byte {
plain := fmt.Sprintf("#camlistore/encmeta=2\n%s/%d/%s\n", plainBR, plainSize, encBR)
return s.encryptBlob(nil, []byte(plain))
} | [
"func",
"(",
"s",
"*",
"storage",
")",
"makeSingleMetaBlob",
"(",
"plainBR",
",",
"encBR",
"blob",
".",
"Ref",
",",
"plainSize",
"uint32",
")",
"[",
"]",
"byte",
"{",
"plain",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"plainBR"... | // makeSingleMetaBlob makes and encrypts a metaBlob with one entry. | [
"makeSingleMetaBlob",
"makes",
"and",
"encrypts",
"a",
"metaBlob",
"with",
"one",
"entry",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/encrypt/meta.go#L148-L151 |
31,739 | perkeep/perkeep | pkg/blobserver/encrypt/meta.go | fetchMeta | func (s *storage) fetchMeta(ctx context.Context, b blob.Ref) (plainSize uint32, encBR blob.Ref, err error) {
v, err := s.index.Get(b.String())
if err == sorted.ErrNotFound {
err = os.ErrNotExist
}
if err != nil {
return 0, blob.Ref{}, err
}
return unpackIndexEntry(v)
} | go | func (s *storage) fetchMeta(ctx context.Context, b blob.Ref) (plainSize uint32, encBR blob.Ref, err error) {
v, err := s.index.Get(b.String())
if err == sorted.ErrNotFound {
err = os.ErrNotExist
}
if err != nil {
return 0, blob.Ref{}, err
}
return unpackIndexEntry(v)
} | [
"func",
"(",
"s",
"*",
"storage",
")",
"fetchMeta",
"(",
"ctx",
"context",
".",
"Context",
",",
"b",
"blob",
".",
"Ref",
")",
"(",
"plainSize",
"uint32",
",",
"encBR",
"blob",
".",
"Ref",
",",
"err",
"error",
")",
"{",
"v",
",",
"err",
":=",
"s",... | // fetchMeta returns os.ErrNotExist if the plaintext blob is not in the index. | [
"fetchMeta",
"returns",
"os",
".",
"ErrNotExist",
"if",
"the",
"plaintext",
"blob",
"is",
"not",
"in",
"the",
"index",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/encrypt/meta.go#L177-L186 |
31,740 | perkeep/perkeep | server/perkeepd/ui/goui/aboutdialog/gen_AboutMenuItem_reactGen.go | Props | func (a AboutMenuItemDef) Props() AboutMenuItemProps {
uprops := a.ComponentDef.Props()
return uprops.(AboutMenuItemProps)
} | go | func (a AboutMenuItemDef) Props() AboutMenuItemProps {
uprops := a.ComponentDef.Props()
return uprops.(AboutMenuItemProps)
} | [
"func",
"(",
"a",
"AboutMenuItemDef",
")",
"Props",
"(",
")",
"AboutMenuItemProps",
"{",
"uprops",
":=",
"a",
".",
"ComponentDef",
".",
"Props",
"(",
")",
"\n",
"return",
"uprops",
".",
"(",
"AboutMenuItemProps",
")",
"\n",
"}"
] | // Props is an auto-generated proxy to the current props of AboutMenuItem | [
"Props",
"is",
"an",
"auto",
"-",
"generated",
"proxy",
"to",
"the",
"current",
"props",
"of",
"AboutMenuItem"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/aboutdialog/gen_AboutMenuItem_reactGen.go#L30-L33 |
31,741 | perkeep/perkeep | internal/netutil/netutil.go | AwaitReachable | func AwaitReachable(addr string, maxWait time.Duration) error {
done := time.Now().Add(maxWait)
for time.Now().Before(done) {
c, err := net.Dial("tcp", addr)
if err == nil {
c.Close()
return nil
}
time.Sleep(100 * time.Millisecond)
}
return fmt.Errorf("%v unreachable for %v", addr, maxWait)
} | go | func AwaitReachable(addr string, maxWait time.Duration) error {
done := time.Now().Add(maxWait)
for time.Now().Before(done) {
c, err := net.Dial("tcp", addr)
if err == nil {
c.Close()
return nil
}
time.Sleep(100 * time.Millisecond)
}
return fmt.Errorf("%v unreachable for %v", addr, maxWait)
} | [
"func",
"AwaitReachable",
"(",
"addr",
"string",
",",
"maxWait",
"time",
".",
"Duration",
")",
"error",
"{",
"done",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"maxWait",
")",
"\n",
"for",
"time",
".",
"Now",
"(",
")",
".",
"Before",
"(",... | // AwaitReachable tries to make a TCP connection to addr regularly.
// It returns an error if it's unable to make a connection before maxWait. | [
"AwaitReachable",
"tries",
"to",
"make",
"a",
"TCP",
"connection",
"to",
"addr",
"regularly",
".",
"It",
"returns",
"an",
"error",
"if",
"it",
"s",
"unable",
"to",
"make",
"a",
"connection",
"before",
"maxWait",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/netutil.go#L30-L41 |
31,742 | perkeep/perkeep | internal/netutil/netutil.go | ListenOnLocalRandomPort | func ListenOnLocalRandomPort() (net.Listener, error) {
ip, err := Localhost()
if err != nil {
return nil, err
}
return net.ListenTCP("tcp", &net.TCPAddr{IP: ip, Port: 0})
} | go | func ListenOnLocalRandomPort() (net.Listener, error) {
ip, err := Localhost()
if err != nil {
return nil, err
}
return net.ListenTCP("tcp", &net.TCPAddr{IP: ip, Port: 0})
} | [
"func",
"ListenOnLocalRandomPort",
"(",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"ip",
",",
"err",
":=",
"Localhost",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"net",
"."... | // ListenOnLocalRandomPort returns a TCP listener on a random
// localhost port. | [
"ListenOnLocalRandomPort",
"returns",
"a",
"TCP",
"listener",
"on",
"a",
"random",
"localhost",
"port",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/netutil.go#L92-L98 |
31,743 | perkeep/perkeep | internal/netutil/netutil.go | Localhost | func Localhost() (net.IP, error) {
if ip := localhostLookup(); ip != nil {
return ip, nil
}
if ip := loopbackIP(); ip != nil {
return ip, nil
}
return nil, errors.New("no loopback ip found")
} | go | func Localhost() (net.IP, error) {
if ip := localhostLookup(); ip != nil {
return ip, nil
}
if ip := loopbackIP(); ip != nil {
return ip, nil
}
return nil, errors.New("no loopback ip found")
} | [
"func",
"Localhost",
"(",
")",
"(",
"net",
".",
"IP",
",",
"error",
")",
"{",
"if",
"ip",
":=",
"localhostLookup",
"(",
")",
";",
"ip",
"!=",
"nil",
"{",
"return",
"ip",
",",
"nil",
"\n",
"}",
"\n",
"if",
"ip",
":=",
"loopbackIP",
"(",
")",
";"... | // Localhost returns the first address found when
// doing a lookup of "localhost". If not successful,
// it looks for an ip on the loopback interfaces. | [
"Localhost",
"returns",
"the",
"first",
"address",
"found",
"when",
"doing",
"a",
"lookup",
"of",
"localhost",
".",
"If",
"not",
"successful",
"it",
"looks",
"for",
"an",
"ip",
"on",
"the",
"loopback",
"interfaces",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/netutil.go#L103-L111 |
31,744 | perkeep/perkeep | internal/netutil/netutil.go | localhostLookup | func localhostLookup() net.IP {
if ips, err := net.LookupIP("localhost"); err == nil && len(ips) > 0 {
return ips[0]
}
return nil
} | go | func localhostLookup() net.IP {
if ips, err := net.LookupIP("localhost"); err == nil && len(ips) > 0 {
return ips[0]
}
return nil
} | [
"func",
"localhostLookup",
"(",
")",
"net",
".",
"IP",
"{",
"if",
"ips",
",",
"err",
":=",
"net",
".",
"LookupIP",
"(",
"\"",
"\"",
")",
";",
"err",
"==",
"nil",
"&&",
"len",
"(",
"ips",
")",
">",
"0",
"{",
"return",
"ips",
"[",
"0",
"]",
"\n... | // localhostLookup looks for a loopback IP by resolving localhost. | [
"localhostLookup",
"looks",
"for",
"a",
"loopback",
"IP",
"by",
"resolving",
"localhost",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/netutil.go#L114-L119 |
31,745 | perkeep/perkeep | internal/netutil/netutil.go | loopbackIP | func loopbackIP() net.IP {
interfaces, err := net.Interfaces()
if err != nil {
return nil
}
for _, inf := range interfaces {
const flagUpLoopback = net.FlagUp | net.FlagLoopback
if inf.Flags&flagUpLoopback == flagUpLoopback {
addrs, _ := inf.Addrs()
for _, addr := range addrs {
ip, _, err := net.Par... | go | func loopbackIP() net.IP {
interfaces, err := net.Interfaces()
if err != nil {
return nil
}
for _, inf := range interfaces {
const flagUpLoopback = net.FlagUp | net.FlagLoopback
if inf.Flags&flagUpLoopback == flagUpLoopback {
addrs, _ := inf.Addrs()
for _, addr := range addrs {
ip, _, err := net.Par... | [
"func",
"loopbackIP",
"(",
")",
"net",
".",
"IP",
"{",
"interfaces",
",",
"err",
":=",
"net",
".",
"Interfaces",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"inf",
":=",
"range",
"interfaces",
... | // loopbackIP returns the first loopback IP address sniffing network
// interfaces or nil if none is found. | [
"loopbackIP",
"returns",
"the",
"first",
"loopback",
"IP",
"address",
"sniffing",
"network",
"interfaces",
"or",
"nil",
"if",
"none",
"is",
"found",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/netutil.go#L123-L141 |
31,746 | perkeep/perkeep | internal/netutil/netutil.go | RandPort | func RandPort() (int, error) {
var port int
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
if err != nil {
return port, err
}
listener, err := net.ListenTCP("tcp", addr)
if err != nil {
return port, fmt.Errorf("could not listen to find random port: %v", err)
}
randAddr := listener.Addr().(*net.TCPAdd... | go | func RandPort() (int, error) {
var port int
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
if err != nil {
return port, err
}
listener, err := net.ListenTCP("tcp", addr)
if err != nil {
return port, fmt.Errorf("could not listen to find random port: %v", err)
}
randAddr := listener.Addr().(*net.TCPAdd... | [
"func",
"RandPort",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"port",
"int",
"\n",
"addr",
",",
"err",
":=",
"net",
".",
"ResolveTCPAddr",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"port",
... | // RandPort returns a random port to listen on. | [
"RandPort",
"returns",
"a",
"random",
"port",
"to",
"listen",
"on",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/netutil.go#L144-L159 |
31,747 | perkeep/perkeep | internal/netutil/netutil.go | IsFQDN | func IsFQDN(domain string) bool {
// TODO(mpl): there's probably a regexp for all this...
if domain == "localhost" {
return false
}
if !strings.Contains(domain, ".") {
return false
}
if strings.Contains(domain, "/") {
return false
}
if net.ParseIP(domain) != nil {
return false
}
return true
} | go | func IsFQDN(domain string) bool {
// TODO(mpl): there's probably a regexp for all this...
if domain == "localhost" {
return false
}
if !strings.Contains(domain, ".") {
return false
}
if strings.Contains(domain, "/") {
return false
}
if net.ParseIP(domain) != nil {
return false
}
return true
} | [
"func",
"IsFQDN",
"(",
"domain",
"string",
")",
"bool",
"{",
"// TODO(mpl): there's probably a regexp for all this...",
"if",
"domain",
"==",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!",
"strings",
".",
"Contains",
"(",
"domain",
",",
"\"",
... | // IsFQDN reports whether domain looks like a fully qualified domain name. | [
"IsFQDN",
"reports",
"whether",
"domain",
"looks",
"like",
"a",
"fully",
"qualified",
"domain",
"name",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/netutil.go#L168-L183 |
31,748 | perkeep/perkeep | server/perkeepd/ui/goui/geo/geo.go | IsLocMapPredicate | func IsLocMapPredicate(predicate string) bool {
if _, err := rectangleFromPredicate(predicate, LocMapPredicatePrefix); err != nil {
return false
}
return true
} | go | func IsLocMapPredicate(predicate string) bool {
if _, err := rectangleFromPredicate(predicate, LocMapPredicatePrefix); err != nil {
return false
}
return true
} | [
"func",
"IsLocMapPredicate",
"(",
"predicate",
"string",
")",
"bool",
"{",
"if",
"_",
",",
"err",
":=",
"rectangleFromPredicate",
"(",
"predicate",
",",
"LocMapPredicatePrefix",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",... | // IsLocMapPredicate returns whether predicate is a map location predicate. | [
"IsLocMapPredicate",
"returns",
"whether",
"predicate",
"is",
"a",
"map",
"location",
"predicate",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/geo/geo.go#L36-L41 |
31,749 | perkeep/perkeep | server/perkeepd/ui/goui/geo/geo.go | rectangleFromPredicate | func rectangleFromPredicate(predicate, kind string) (*camtypes.LocationBounds, error) {
errNotARectangle := fmt.Errorf("not a valid %v predicate", kind)
if !strings.HasPrefix(predicate, kind+":") {
return nil, errNotARectangle
}
loc := strings.TrimPrefix(predicate, kind+":")
coords := strings.Split(loc, ",")
if... | go | func rectangleFromPredicate(predicate, kind string) (*camtypes.LocationBounds, error) {
errNotARectangle := fmt.Errorf("not a valid %v predicate", kind)
if !strings.HasPrefix(predicate, kind+":") {
return nil, errNotARectangle
}
loc := strings.TrimPrefix(predicate, kind+":")
coords := strings.Split(loc, ",")
if... | [
"func",
"rectangleFromPredicate",
"(",
"predicate",
",",
"kind",
"string",
")",
"(",
"*",
"camtypes",
".",
"LocationBounds",
",",
"error",
")",
"{",
"errNotARectangle",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"kind",
")",
"\n",
"if",
"!",
"stri... | // rectangleFromPredicate, if predicate is a valid location predicate of the given kind
// and returns the corresponding rectangular area. | [
"rectangleFromPredicate",
"if",
"predicate",
"is",
"a",
"valid",
"location",
"predicate",
"of",
"the",
"given",
"kind",
"and",
"returns",
"the",
"corresponding",
"rectangular",
"area",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/geo/geo.go#L45-L69 |
31,750 | perkeep/perkeep | internal/leak/leak.go | NewChecker | func NewChecker() *Checker {
pc := make([]uintptr, 50)
ch := &Checker{pc[:runtime.Callers(0, pc)]}
runtime.SetFinalizer(ch, (*Checker).finalize)
return ch
} | go | func NewChecker() *Checker {
pc := make([]uintptr, 50)
ch := &Checker{pc[:runtime.Callers(0, pc)]}
runtime.SetFinalizer(ch, (*Checker).finalize)
return ch
} | [
"func",
"NewChecker",
"(",
")",
"*",
"Checker",
"{",
"pc",
":=",
"make",
"(",
"[",
"]",
"uintptr",
",",
"50",
")",
"\n",
"ch",
":=",
"&",
"Checker",
"{",
"pc",
"[",
":",
"runtime",
".",
"Callers",
"(",
"0",
",",
"pc",
")",
"]",
"}",
"\n",
"ru... | // NewChecker returns a Checker, remembering the stack trace. | [
"NewChecker",
"returns",
"a",
"Checker",
"remembering",
"the",
"stack",
"trace",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/leak/leak.go#L32-L37 |
31,751 | perkeep/perkeep | pkg/importer/feed/feed.go | autoDiscover | func autoDiscover(body []byte) (feedURL string, err error) {
r := bytes.NewReader(body)
z := html.NewTokenizer(r)
for {
if z.Next() == html.ErrorToken {
break
}
t := z.Token()
switch t.DataAtom {
case atom.Link:
if t.Type == html.StartTagToken || t.Type == html.SelfClosingTagToken {
attrs := make... | go | func autoDiscover(body []byte) (feedURL string, err error) {
r := bytes.NewReader(body)
z := html.NewTokenizer(r)
for {
if z.Next() == html.ErrorToken {
break
}
t := z.Token()
switch t.DataAtom {
case atom.Link:
if t.Type == html.StartTagToken || t.Type == html.SelfClosingTagToken {
attrs := make... | [
"func",
"autoDiscover",
"(",
"body",
"[",
"]",
"byte",
")",
"(",
"feedURL",
"string",
",",
"err",
"error",
")",
"{",
"r",
":=",
"bytes",
".",
"NewReader",
"(",
"body",
")",
"\n",
"z",
":=",
"html",
".",
"NewTokenizer",
"(",
"r",
")",
"\n",
"for",
... | // autodiscover takes an HTML document and returns the autodiscovered feed
// URL. Returns an error if there is no such URL. | [
"autodiscover",
"takes",
"an",
"HTML",
"document",
"and",
"returns",
"the",
"autodiscovered",
"feed",
"URL",
".",
"Returns",
"an",
"error",
"if",
"there",
"is",
"no",
"such",
"URL",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/feed/feed.go#L191-L214 |
31,752 | perkeep/perkeep | pkg/importer/mastodon/mastodon.go | importStatuses | func (r *run) importStatuses(userID mastodon.ID) error {
statusesNode, err := r.RootNode().ChildPathObject(nodeStatuses)
if err != nil {
return err
}
nodeTitle := fmt.Sprintf("Mastodon statuses for %s", r.userAddress)
if err := statusesNode.SetAttr(nodeattr.Title, nodeTitle); err != nil {
return err
}
log.... | go | func (r *run) importStatuses(userID mastodon.ID) error {
statusesNode, err := r.RootNode().ChildPathObject(nodeStatuses)
if err != nil {
return err
}
nodeTitle := fmt.Sprintf("Mastodon statuses for %s", r.userAddress)
if err := statusesNode.SetAttr(nodeattr.Title, nodeTitle); err != nil {
return err
}
log.... | [
"func",
"(",
"r",
"*",
"run",
")",
"importStatuses",
"(",
"userID",
"mastodon",
".",
"ID",
")",
"error",
"{",
"statusesNode",
",",
"err",
":=",
"r",
".",
"RootNode",
"(",
")",
".",
"ChildPathObject",
"(",
"nodeStatuses",
")",
"\n",
"if",
"err",
"!=",
... | // importStatuses imports statuses for the given user into the store | [
"importStatuses",
"imports",
"statuses",
"for",
"the",
"given",
"user",
"into",
"the",
"store"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/mastodon/mastodon.go#L294-L385 |
31,753 | perkeep/perkeep | pkg/importer/mastodon/mastodon.go | importStatus | func (r *run) importStatus(listNode *importer.Object, st *mastodon.Status) (bool, error) {
select {
case <-r.Context().Done():
return false, r.Context().Err()
default:
}
// We store child nodes by their URI, since the URI is supposed to be an
// unchanging, globally unique identifier for the status
statusNode... | go | func (r *run) importStatus(listNode *importer.Object, st *mastodon.Status) (bool, error) {
select {
case <-r.Context().Done():
return false, r.Context().Err()
default:
}
// We store child nodes by their URI, since the URI is supposed to be an
// unchanging, globally unique identifier for the status
statusNode... | [
"func",
"(",
"r",
"*",
"run",
")",
"importStatus",
"(",
"listNode",
"*",
"importer",
".",
"Object",
",",
"st",
"*",
"mastodon",
".",
"Status",
")",
"(",
"bool",
",",
"error",
")",
"{",
"select",
"{",
"case",
"<-",
"r",
".",
"Context",
"(",
")",
"... | // importStatus imports a single status, also adding it to the statuses node.
// Returns true if we already had the status in the database. | [
"importStatus",
"imports",
"a",
"single",
"status",
"also",
"adding",
"it",
"to",
"the",
"statuses",
"node",
".",
"Returns",
"true",
"if",
"we",
"already",
"had",
"the",
"status",
"in",
"the",
"database",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/mastodon/mastodon.go#L389-L467 |
31,754 | perkeep/perkeep | pkg/importer/mastodon/mastodon.go | auth | func (im *imp) auth(ctx *importer.SetupContext) (*oauth2.Config, error) {
baseURL, err := url.Parse(ctx.AccountNode.Attr(acctAttrInstanceURL))
if err != nil {
return nil, err
}
tokenURL := *baseURL
tokenURL.Path = path.Join(tokenURL.Path, tokenPath)
authURL := *baseURL
authURL.Path = path.Join(authURL.Path, ... | go | func (im *imp) auth(ctx *importer.SetupContext) (*oauth2.Config, error) {
baseURL, err := url.Parse(ctx.AccountNode.Attr(acctAttrInstanceURL))
if err != nil {
return nil, err
}
tokenURL := *baseURL
tokenURL.Path = path.Join(tokenURL.Path, tokenPath)
authURL := *baseURL
authURL.Path = path.Join(authURL.Path, ... | [
"func",
"(",
"im",
"*",
"imp",
")",
"auth",
"(",
"ctx",
"*",
"importer",
".",
"SetupContext",
")",
"(",
"*",
"oauth2",
".",
"Config",
",",
"error",
")",
"{",
"baseURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"ctx",
".",
"AccountNode",
".",
"... | // auth returns the appropriate oauth2.Config for this account | [
"auth",
"returns",
"the",
"appropriate",
"oauth2",
".",
"Config",
"for",
"this",
"account"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/mastodon/mastodon.go#L470-L491 |
31,755 | perkeep/perkeep | pkg/importer/mastodon/mastodon.go | createMastodonClient | func createMastodonClient(ctx context.Context, acct *importer.Object) *mastodon.Client {
// Although the client can take client_id and client_secret, we won't need
// those for token auth
cl := mastodon.NewClient(&mastodon.Config{
Server: acct.Attr(acctAttrInstanceURL),
AccessToken: acct.Attr(importer.Acct... | go | func createMastodonClient(ctx context.Context, acct *importer.Object) *mastodon.Client {
// Although the client can take client_id and client_secret, we won't need
// those for token auth
cl := mastodon.NewClient(&mastodon.Config{
Server: acct.Attr(acctAttrInstanceURL),
AccessToken: acct.Attr(importer.Acct... | [
"func",
"createMastodonClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"acct",
"*",
"importer",
".",
"Object",
")",
"*",
"mastodon",
".",
"Client",
"{",
"// Although the client can take client_id and client_secret, we won't need",
"// those for token auth",
"cl",
":=... | // createMastodonClient returns a new Client configured for the provided
// account. It does not check if the account has the needed fields filled. | [
"createMastodonClient",
"returns",
"a",
"new",
"Client",
"configured",
"for",
"the",
"provided",
"account",
".",
"It",
"does",
"not",
"check",
"if",
"the",
"account",
"has",
"the",
"needed",
"fields",
"filled",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/mastodon/mastodon.go#L495-L506 |
31,756 | perkeep/perkeep | pkg/importer/mastodon/mastodon.go | getExpandedAddress | func getExpandedAddress(user, instanceURL string) (string, error) {
if user == "" || instanceURL == "" {
return "", errors.New("some required account data is missing")
}
parsedURL, err := url.Parse(instanceURL)
if err != nil {
return "", err
}
return fmt.Sprintf("@%s@%s", user, parsedURL.Host), nil
} | go | func getExpandedAddress(user, instanceURL string) (string, error) {
if user == "" || instanceURL == "" {
return "", errors.New("some required account data is missing")
}
parsedURL, err := url.Parse(instanceURL)
if err != nil {
return "", err
}
return fmt.Sprintf("@%s@%s", user, parsedURL.Host), nil
} | [
"func",
"getExpandedAddress",
"(",
"user",
",",
"instanceURL",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"user",
"==",
"\"",
"\"",
"||",
"instanceURL",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"... | // getExpandedAddress returns the address for the account in the @user@example.com form | [
"getExpandedAddress",
"returns",
"the",
"address",
"for",
"the",
"account",
"in",
"the"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/mastodon/mastodon.go#L509-L521 |
31,757 | perkeep/perkeep | pkg/index/sniff.go | Body | func (sn *BlobSniffer) Body() ([]byte, error) {
if sn.IsTruncated() {
return nil, errors.New("index.Body: was truncated")
}
return sn.contents, nil
} | go | func (sn *BlobSniffer) Body() ([]byte, error) {
if sn.IsTruncated() {
return nil, errors.New("index.Body: was truncated")
}
return sn.contents, nil
} | [
"func",
"(",
"sn",
"*",
"BlobSniffer",
")",
"Body",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"sn",
".",
"IsTruncated",
"(",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"re... | // Body returns the bytes written to the BlobSniffer. | [
"Body",
"returns",
"the",
"bytes",
"written",
"to",
"the",
"BlobSniffer",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/sniff.go#L78-L83 |
31,758 | perkeep/perkeep | pkg/server/image.go | cacheScaled | func (ih *ImageHandler) cacheScaled(ctx context.Context, thumbBytes []byte, name string) error {
br, err := writeToCache(ctx, ih.Cache, thumbBytes, name)
if err != nil {
return err
}
ih.ThumbMeta.Put(name, br)
return nil
} | go | func (ih *ImageHandler) cacheScaled(ctx context.Context, thumbBytes []byte, name string) error {
br, err := writeToCache(ctx, ih.Cache, thumbBytes, name)
if err != nil {
return err
}
ih.ThumbMeta.Put(name, br)
return nil
} | [
"func",
"(",
"ih",
"*",
"ImageHandler",
")",
"cacheScaled",
"(",
"ctx",
"context",
".",
"Context",
",",
"thumbBytes",
"[",
"]",
"byte",
",",
"name",
"string",
")",
"error",
"{",
"br",
",",
"err",
":=",
"writeToCache",
"(",
"ctx",
",",
"ih",
".",
"Cac... | // cacheScaled saves in the image handler's cache the scaled image bytes
// in thumbBytes, and puts its blobref in the scaledImage under the key name. | [
"cacheScaled",
"saves",
"in",
"the",
"image",
"handler",
"s",
"cache",
"the",
"scaled",
"image",
"bytes",
"in",
"thumbBytes",
"and",
"puts",
"its",
"blobref",
"in",
"the",
"scaledImage",
"under",
"the",
"key",
"name",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/image.go#L117-L124 |
31,759 | perkeep/perkeep | pkg/server/image.go | scaledCached | func (ih *ImageHandler) scaledCached(ctx context.Context, buf *bytes.Buffer, file blob.Ref) (format string) {
key := cacheKey(file.String(), ih.MaxWidth, ih.MaxHeight)
br, err := ih.ThumbMeta.Get(key)
if err == errCacheMiss {
return
}
if err != nil {
log.Printf("Warning: thumbnail cachekey(%q)->meta lookup err... | go | func (ih *ImageHandler) scaledCached(ctx context.Context, buf *bytes.Buffer, file blob.Ref) (format string) {
key := cacheKey(file.String(), ih.MaxWidth, ih.MaxHeight)
br, err := ih.ThumbMeta.Get(key)
if err == errCacheMiss {
return
}
if err != nil {
log.Printf("Warning: thumbnail cachekey(%q)->meta lookup err... | [
"func",
"(",
"ih",
"*",
"ImageHandler",
")",
"scaledCached",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"file",
"blob",
".",
"Ref",
")",
"(",
"format",
"string",
")",
"{",
"key",
":=",
"cacheKey",
"(",
"file"... | // ScaledCached reads the scaled version of the image in file,
// if it is in cache and writes it to buf.
//
// On successful read and population of buf, the returned format is non-empty.
// Almost all errors are not interesting. Real errors will be logged. | [
"ScaledCached",
"reads",
"the",
"scaled",
"version",
"of",
"the",
"image",
"in",
"file",
"if",
"it",
"is",
"in",
"cache",
"and",
"writes",
"it",
"to",
"buf",
".",
"On",
"successful",
"read",
"and",
"population",
"of",
"buf",
"the",
"returned",
"format",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/image.go#L181-L209 |
31,760 | perkeep/perkeep | pkg/blobserver/stats/statreceiver.go | Sizes | func (sr *Receiver) Sizes() []int {
sr.Lock()
defer sr.Unlock()
sizes := make([]int, 0, len(sr.Have))
for _, size := range sr.Have {
sizes = append(sizes, int(size))
}
sort.Ints(sizes)
return sizes
} | go | func (sr *Receiver) Sizes() []int {
sr.Lock()
defer sr.Unlock()
sizes := make([]int, 0, len(sr.Have))
for _, size := range sr.Have {
sizes = append(sizes, int(size))
}
sort.Ints(sizes)
return sizes
} | [
"func",
"(",
"sr",
"*",
"Receiver",
")",
"Sizes",
"(",
")",
"[",
"]",
"int",
"{",
"sr",
".",
"Lock",
"(",
")",
"\n",
"defer",
"sr",
".",
"Unlock",
"(",
")",
"\n",
"sizes",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"0",
",",
"len",
"(",
"sr",... | // Sizes returns the sorted blob sizes. | [
"Sizes",
"returns",
"the",
"sorted",
"blob",
"sizes",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/stats/statreceiver.go#L49-L58 |
31,761 | perkeep/perkeep | internal/images/resize/resize.go | resizeYCbCr | func resizeYCbCr(m *image.YCbCr, r image.Rectangle, w, h int) (image.Image, bool) {
dst := image.NewRGBA(image.Rect(0, 0, w, h))
xdraw.ApproxBiLinear.Scale(dst, dst.Bounds(), m, m.Bounds(), xdraw.Src, nil)
return dst, true
} | go | func resizeYCbCr(m *image.YCbCr, r image.Rectangle, w, h int) (image.Image, bool) {
dst := image.NewRGBA(image.Rect(0, 0, w, h))
xdraw.ApproxBiLinear.Scale(dst, dst.Bounds(), m, m.Bounds(), xdraw.Src, nil)
return dst, true
} | [
"func",
"resizeYCbCr",
"(",
"m",
"*",
"image",
".",
"YCbCr",
",",
"r",
"image",
".",
"Rectangle",
",",
"w",
",",
"h",
"int",
")",
"(",
"image",
".",
"Image",
",",
"bool",
")",
"{",
"dst",
":=",
"image",
".",
"NewRGBA",
"(",
"image",
".",
"Rect",
... | // resizeYCbCr returns a scaled copy of the YCbCr image slice r of m.
// The returned image has width w and height h. | [
"resizeYCbCr",
"returns",
"a",
"scaled",
"copy",
"of",
"the",
"YCbCr",
"image",
"slice",
"r",
"of",
"m",
".",
"The",
"returned",
"image",
"has",
"width",
"w",
"and",
"height",
"h",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/images/resize/resize.go#L121-L125 |
31,762 | perkeep/perkeep | internal/images/resize/resize.go | ResampleInplace | func ResampleInplace(m image.Image, r image.Rectangle, w, h int) image.Image {
// We don't support scaling up.
if r.Dx() < w || r.Dy() < h {
return m
}
switch m := m.(type) {
case *image.YCbCr:
xStep := float64(r.Dx()) / float64(w)
yStep := float64(r.Dy()) / float64(h)
for y := r.Min.Y; y < r.Min.Y+h; y++... | go | func ResampleInplace(m image.Image, r image.Rectangle, w, h int) image.Image {
// We don't support scaling up.
if r.Dx() < w || r.Dy() < h {
return m
}
switch m := m.(type) {
case *image.YCbCr:
xStep := float64(r.Dx()) / float64(w)
yStep := float64(r.Dy()) / float64(h)
for y := r.Min.Y; y < r.Min.Y+h; y++... | [
"func",
"ResampleInplace",
"(",
"m",
"image",
".",
"Image",
",",
"r",
"image",
".",
"Rectangle",
",",
"w",
",",
"h",
"int",
")",
"image",
".",
"Image",
"{",
"// We don't support scaling up.",
"if",
"r",
".",
"Dx",
"(",
")",
"<",
"w",
"||",
"r",
".",
... | // ResampleInplace will resample m inplace, overwritting existing pixel data,
// and return a subimage of m sized to w and h. | [
"ResampleInplace",
"will",
"resample",
"m",
"inplace",
"overwritting",
"existing",
"pixel",
"data",
"and",
"return",
"a",
"subimage",
"of",
"m",
"sized",
"to",
"w",
"and",
"h",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/images/resize/resize.go#L239-L283 |
31,763 | perkeep/perkeep | cmd/pk/dbinit.go | wipeMongo | func (c *dbinitCmd) wipeMongo() error {
if c.dbType != "mongo" {
return nil
}
session, err := c.mongoSession()
if err != nil {
return err
}
defer session.Close()
if _, err := session.DB(c.dbName).C(mongo.CollectionName).RemoveAll(nil); err != nil {
return err
}
return nil
} | go | func (c *dbinitCmd) wipeMongo() error {
if c.dbType != "mongo" {
return nil
}
session, err := c.mongoSession()
if err != nil {
return err
}
defer session.Close()
if _, err := session.DB(c.dbName).C(mongo.CollectionName).RemoveAll(nil); err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"dbinitCmd",
")",
"wipeMongo",
"(",
")",
"error",
"{",
"if",
"c",
".",
"dbType",
"!=",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"session",
",",
"err",
":=",
"c",
".",
"mongoSession",
"(",
")",
"\n",
"if",
"err",
... | // wipeMongo erases all documents from the mongo collection
// if c.dbType is "mongo". | [
"wipeMongo",
"erases",
"all",
"documents",
"from",
"the",
"mongo",
"collection",
"if",
"c",
".",
"dbType",
"is",
"mongo",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk/dbinit.go#L290-L303 |
31,764 | perkeep/perkeep | pkg/importer/oauth.go | RedirectURL | func (OAuth2) RedirectURL(imp Importer, ctx *SetupContext) string {
// We strip our callback URL of its query component, because the Redirect URI
// we send during authorization has to match exactly the registered redirect
// URI(s). This query component should be stored in the "state" paremeter instead.
// See htt... | go | func (OAuth2) RedirectURL(imp Importer, ctx *SetupContext) string {
// We strip our callback URL of its query component, because the Redirect URI
// we send during authorization has to match exactly the registered redirect
// URI(s). This query component should be stored in the "state" paremeter instead.
// See htt... | [
"func",
"(",
"OAuth2",
")",
"RedirectURL",
"(",
"imp",
"Importer",
",",
"ctx",
"*",
"SetupContext",
")",
"string",
"{",
"// We strip our callback URL of its query component, because the Redirect URI",
"// we send during authorization has to match exactly the registered redirect",
"... | // RedirectURL returns the redirect URI that imp should set in an oauth.Config
// for the authorization phase of OAuth2 authentication. | [
"RedirectURL",
"returns",
"the",
"redirect",
"URI",
"that",
"imp",
"should",
"set",
"in",
"an",
"oauth",
".",
"Config",
"for",
"the",
"authorization",
"phase",
"of",
"OAuth2",
"authentication",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/oauth.go#L87-L105 |
31,765 | perkeep/perkeep | pkg/importer/oauth.go | IsAccountReady | func (OAuth2) IsAccountReady(acctNode *Object) (ok bool, err error) {
if acctNode.Attr(AcctAttrUserID) != "" &&
acctNode.Attr(AcctAttrAccessToken) != "" {
return true, nil
}
return false, nil
} | go | func (OAuth2) IsAccountReady(acctNode *Object) (ok bool, err error) {
if acctNode.Attr(AcctAttrUserID) != "" &&
acctNode.Attr(AcctAttrAccessToken) != "" {
return true, nil
}
return false, nil
} | [
"func",
"(",
"OAuth2",
")",
"IsAccountReady",
"(",
"acctNode",
"*",
"Object",
")",
"(",
"ok",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"acctNode",
".",
"Attr",
"(",
"AcctAttrUserID",
")",
"!=",
"\"",
"\"",
"&&",
"acctNode",
".",
"Attr",
"(",
"Acc... | // IsAccountReady returns whether the account has been properly configured
// - whether the user ID and access token has been stored in the given account node. | [
"IsAccountReady",
"returns",
"whether",
"the",
"account",
"has",
"been",
"properly",
"configured",
"-",
"whether",
"the",
"user",
"ID",
"and",
"access",
"token",
"has",
"been",
"stored",
"in",
"the",
"given",
"account",
"node",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/oauth.go#L121-L127 |
31,766 | perkeep/perkeep | pkg/importer/oauth.go | do | func (octx OAuthContext) do(method string, url string, form url.Values) (*http.Response, error) {
if octx.Creds == nil {
return nil, errors.New("no OAuth credentials. Not logged in?")
}
if octx.Client == nil {
return nil, errors.New("no OAuth client")
}
var (
res *http.Response
err error
)
if method == h... | go | func (octx OAuthContext) do(method string, url string, form url.Values) (*http.Response, error) {
if octx.Creds == nil {
return nil, errors.New("no OAuth credentials. Not logged in?")
}
if octx.Client == nil {
return nil, errors.New("no OAuth client")
}
var (
res *http.Response
err error
)
if method == h... | [
"func",
"(",
"octx",
"OAuthContext",
")",
"do",
"(",
"method",
"string",
",",
"url",
"string",
",",
"form",
"url",
".",
"Values",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"octx",
".",
"Creds",
"==",
"nil",
"{",
"return"... | // Do sends through octx the request defined by url and the values in form. | [
"Do",
"sends",
"through",
"octx",
"the",
"request",
"defined",
"by",
"url",
"and",
"the",
"values",
"in",
"form",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/oauth.go#L159-L182 |
31,767 | perkeep/perkeep | pkg/importer/oauth.go | PopulateJSONFromURL | func (octx OAuthContext) PopulateJSONFromURL(result interface{}, method string, apiURL string, keyval ...string) error {
if method != http.MethodGet && method != http.MethodPost {
return fmt.Errorf("only HTTP Get or Post supported: found %v", method)
}
if len(keyval)%2 == 1 {
return errors.New("incorrect number ... | go | func (octx OAuthContext) PopulateJSONFromURL(result interface{}, method string, apiURL string, keyval ...string) error {
if method != http.MethodGet && method != http.MethodPost {
return fmt.Errorf("only HTTP Get or Post supported: found %v", method)
}
if len(keyval)%2 == 1 {
return errors.New("incorrect number ... | [
"func",
"(",
"octx",
"OAuthContext",
")",
"PopulateJSONFromURL",
"(",
"result",
"interface",
"{",
"}",
",",
"method",
"string",
",",
"apiURL",
"string",
",",
"keyval",
"...",
"string",
")",
"error",
"{",
"if",
"method",
"!=",
"http",
".",
"MethodGet",
"&&"... | // PopulateJSONFromURL makes a POST or GET call at apiURL, using keyval as parameters of
// the associated form. The JSON response is decoded into result. | [
"PopulateJSONFromURL",
"makes",
"a",
"POST",
"or",
"GET",
"call",
"at",
"apiURL",
"using",
"keyval",
"as",
"parameters",
"of",
"the",
"associated",
"form",
".",
"The",
"JSON",
"response",
"is",
"decoded",
"into",
"result",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/oauth.go#L194-L214 |
31,768 | perkeep/perkeep | pkg/importer/oauth.go | NewOAuthClient | func (ctx *SetupContext) NewOAuthClient(uris OAuthURIs) (*oauth.Client, error) {
clientID, secret, err := ctx.Credentials()
if err != nil {
return nil, err
}
return &oauth.Client{
TemporaryCredentialRequestURI: uris.TemporaryCredentialRequestURI,
ResourceOwnerAuthorizationURI: uris.ResourceOwnerAuthorizationU... | go | func (ctx *SetupContext) NewOAuthClient(uris OAuthURIs) (*oauth.Client, error) {
clientID, secret, err := ctx.Credentials()
if err != nil {
return nil, err
}
return &oauth.Client{
TemporaryCredentialRequestURI: uris.TemporaryCredentialRequestURI,
ResourceOwnerAuthorizationURI: uris.ResourceOwnerAuthorizationU... | [
"func",
"(",
"ctx",
"*",
"SetupContext",
")",
"NewOAuthClient",
"(",
"uris",
"OAuthURIs",
")",
"(",
"*",
"oauth",
".",
"Client",
",",
"error",
")",
"{",
"clientID",
",",
"secret",
",",
"err",
":=",
"ctx",
".",
"Credentials",
"(",
")",
"\n",
"if",
"er... | // NewOAuthClient returns an oauth Client configured with uris and the
// credentials obtained from ctx. | [
"NewOAuthClient",
"returns",
"an",
"oauth",
"Client",
"configured",
"with",
"uris",
"and",
"the",
"credentials",
"obtained",
"from",
"ctx",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/oauth.go#L225-L239 |
31,769 | perkeep/perkeep | pkg/blobserver/registry.go | RegisterHandlerConstructor | func RegisterHandlerConstructor(typ string, ctor HandlerConstructor) {
mapLock.Lock()
defer mapLock.Unlock()
if _, ok := handlerConstructors[typ]; ok {
panic("blobserver: HandlerConstrutor already registered for type: " + typ)
}
handlerConstructors[typ] = ctor
} | go | func RegisterHandlerConstructor(typ string, ctor HandlerConstructor) {
mapLock.Lock()
defer mapLock.Unlock()
if _, ok := handlerConstructors[typ]; ok {
panic("blobserver: HandlerConstrutor already registered for type: " + typ)
}
handlerConstructors[typ] = ctor
} | [
"func",
"RegisterHandlerConstructor",
"(",
"typ",
"string",
",",
"ctor",
"HandlerConstructor",
")",
"{",
"mapLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mapLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"handlerConstructors",
"[",
"typ... | // RegisterHandlerConstructor registers an http Handler constructor function
// for a given handler type.
//
// It is an error to register the same handler type twice. | [
"RegisterHandlerConstructor",
"registers",
"an",
"http",
"Handler",
"constructor",
"function",
"for",
"a",
"given",
"handler",
"type",
".",
"It",
"is",
"an",
"error",
"to",
"register",
"the",
"same",
"handler",
"type",
"twice",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/registry.go#L118-L125 |
31,770 | perkeep/perkeep | pkg/blobserver/registry.go | CreateHandler | func CreateHandler(typ string, loader Loader, config jsonconfig.Obj) (http.Handler, error) {
mapLock.Lock()
ctor, ok := handlerConstructors[typ]
mapLock.Unlock()
if !ok {
return nil, fmt.Errorf("blobserver: Handler type %q not known or loaded", typ)
}
return ctor(loader, config)
} | go | func CreateHandler(typ string, loader Loader, config jsonconfig.Obj) (http.Handler, error) {
mapLock.Lock()
ctor, ok := handlerConstructors[typ]
mapLock.Unlock()
if !ok {
return nil, fmt.Errorf("blobserver: Handler type %q not known or loaded", typ)
}
return ctor(loader, config)
} | [
"func",
"CreateHandler",
"(",
"typ",
"string",
",",
"loader",
"Loader",
",",
"config",
"jsonconfig",
".",
"Obj",
")",
"(",
"http",
".",
"Handler",
",",
"error",
")",
"{",
"mapLock",
".",
"Lock",
"(",
")",
"\n",
"ctor",
",",
"ok",
":=",
"handlerConstruc... | // CreateHandler instantiates an http Handler of type 'typ' from the
// provided JSON configuration, and finding peer handlers and
// configuration from the environment in 'loader'.
//
// The handler 'typ' must have been previously registered with
// RegisterHandlerConstructor. | [
"CreateHandler",
"instantiates",
"an",
"http",
"Handler",
"of",
"type",
"typ",
"from",
"the",
"provided",
"JSON",
"configuration",
"and",
"finding",
"peer",
"handlers",
"and",
"configuration",
"from",
"the",
"environment",
"in",
"loader",
".",
"The",
"handler",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/registry.go#L133-L141 |
31,771 | perkeep/perkeep | pkg/serverinit/genconfig.go | genLowLevelConfig | func genLowLevelConfig(conf *serverconfig.Config) (lowLevelConf *Config, err error) {
b := &lowBuilder{
high: conf,
low: jsonconfig.Obj{
"prefixes": make(map[string]interface{}),
},
}
return b.build()
} | go | func genLowLevelConfig(conf *serverconfig.Config) (lowLevelConf *Config, err error) {
b := &lowBuilder{
high: conf,
low: jsonconfig.Obj{
"prefixes": make(map[string]interface{}),
},
}
return b.build()
} | [
"func",
"genLowLevelConfig",
"(",
"conf",
"*",
"serverconfig",
".",
"Config",
")",
"(",
"lowLevelConf",
"*",
"Config",
",",
"err",
"error",
")",
"{",
"b",
":=",
"&",
"lowBuilder",
"{",
"high",
":",
"conf",
",",
"low",
":",
"jsonconfig",
".",
"Obj",
"{"... | // genLowLevelConfig returns a low-level config from a high-level config. | [
"genLowLevelConfig",
"returns",
"a",
"low",
"-",
"level",
"config",
"from",
"a",
"high",
"-",
"level",
"config",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L52-L60 |
31,772 | perkeep/perkeep | pkg/serverinit/genconfig.go | dbUnique | func (b *lowBuilder) dbUnique() string {
if b.high.DBUnique != "" {
return b.high.DBUnique
}
if b.high.Identity != "" {
return strings.ToLower(b.high.Identity)
}
return osutil.Username() // may be empty, if $USER unset
} | go | func (b *lowBuilder) dbUnique() string {
if b.high.DBUnique != "" {
return b.high.DBUnique
}
if b.high.Identity != "" {
return strings.ToLower(b.high.Identity)
}
return osutil.Username() // may be empty, if $USER unset
} | [
"func",
"(",
"b",
"*",
"lowBuilder",
")",
"dbUnique",
"(",
")",
"string",
"{",
"if",
"b",
".",
"high",
".",
"DBUnique",
"!=",
"\"",
"\"",
"{",
"return",
"b",
".",
"high",
".",
"DBUnique",
"\n",
"}",
"\n",
"if",
"b",
".",
"high",
".",
"Identity",
... | // dbUnique returns the uniqueness string that is used in databases names to
// differentiate them from databases used by other Perkeep instances on the same
// DBMS. | [
"dbUnique",
"returns",
"the",
"uniqueness",
"string",
"that",
"is",
"used",
"in",
"databases",
"names",
"to",
"differentiate",
"them",
"from",
"databases",
"used",
"by",
"other",
"Perkeep",
"instances",
"on",
"the",
"same",
"DBMS",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L105-L113 |
31,773 | perkeep/perkeep | pkg/serverinit/genconfig.go | oldDBNames | func (b *lowBuilder) oldDBNames(of dbname) string {
switch of {
case dbIndex:
return "camlistore_index"
case dbBlobpackedIndex:
return "blobpacked_index"
case "queue-sync-to-index":
return "sync_index_queue"
case dbUIThumbcache:
return "ui_thumbmeta_cache"
}
return ""
} | go | func (b *lowBuilder) oldDBNames(of dbname) string {
switch of {
case dbIndex:
return "camlistore_index"
case dbBlobpackedIndex:
return "blobpacked_index"
case "queue-sync-to-index":
return "sync_index_queue"
case dbUIThumbcache:
return "ui_thumbmeta_cache"
}
return ""
} | [
"func",
"(",
"b",
"*",
"lowBuilder",
")",
"oldDBNames",
"(",
"of",
"dbname",
")",
"string",
"{",
"switch",
"of",
"{",
"case",
"dbIndex",
":",
"return",
"\"",
"\"",
"\n",
"case",
"dbBlobpackedIndex",
":",
"return",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
... | // As of rev 7eda9fd5027fda88166d6c03b6490cffbf2de5fb, we changed how the
// databases names were defined. But we wanted the existing GCE instances to keep
// on working with the old names, so that nothing would break for existing users,
// without any intervention needed. Through the help of the perkeep-config-version... | [
"As",
"of",
"rev",
"7eda9fd5027fda88166d6c03b6490cffbf2de5fb",
"we",
"changed",
"how",
"the",
"databases",
"names",
"were",
"defined",
".",
"But",
"we",
"wanted",
"the",
"existing",
"GCE",
"instances",
"to",
"keep",
"on",
"working",
"with",
"the",
"old",
"names"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L162-L174 |
31,774 | perkeep/perkeep | pkg/serverinit/genconfig.go | searchOwner | func (b *lowBuilder) searchOwner() (owner *serverconfig.Owner, err error) {
if b.high.Identity == "" {
return nil, errNoOwner
}
if b.high.IdentitySecretRing == "" {
return nil, errNoOwner
}
return &serverconfig.Owner{
Identity: b.high.Identity,
SecringFile: b.high.IdentitySecretRing,
}, nil
} | go | func (b *lowBuilder) searchOwner() (owner *serverconfig.Owner, err error) {
if b.high.Identity == "" {
return nil, errNoOwner
}
if b.high.IdentitySecretRing == "" {
return nil, errNoOwner
}
return &serverconfig.Owner{
Identity: b.high.Identity,
SecringFile: b.high.IdentitySecretRing,
}, nil
} | [
"func",
"(",
"b",
"*",
"lowBuilder",
")",
"searchOwner",
"(",
")",
"(",
"owner",
"*",
"serverconfig",
".",
"Owner",
",",
"err",
"error",
")",
"{",
"if",
"b",
".",
"high",
".",
"Identity",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errNoOwner",
"... | // Error is errNoOwner if no identity configured | [
"Error",
"is",
"errNoOwner",
"if",
"no",
"identity",
"configured"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L179-L190 |
31,775 | perkeep/perkeep | pkg/serverinit/genconfig.go | kvFileType | func (b *lowBuilder) kvFileType() string {
switch {
case b.high.SQLite != "":
return "sqlite"
case b.high.KVFile != "":
return "kv"
case b.high.LevelDB != "":
return "leveldb"
default:
return sorted.DefaultKVFileType
}
} | go | func (b *lowBuilder) kvFileType() string {
switch {
case b.high.SQLite != "":
return "sqlite"
case b.high.KVFile != "":
return "kv"
case b.high.LevelDB != "":
return "leveldb"
default:
return sorted.DefaultKVFileType
}
} | [
"func",
"(",
"b",
"*",
"lowBuilder",
")",
"kvFileType",
"(",
")",
"string",
"{",
"switch",
"{",
"case",
"b",
".",
"high",
".",
"SQLite",
"!=",
"\"",
"\"",
":",
"return",
"\"",
"\"",
"\n",
"case",
"b",
".",
"high",
".",
"KVFile",
"!=",
"\"",
"\"",... | // kvFileType returns the file based sorted type defined for index storage, if
// any. It defaults to "leveldb" otherwise. | [
"kvFileType",
"returns",
"the",
"file",
"based",
"sorted",
"type",
"defined",
"for",
"index",
"storage",
"if",
"any",
".",
"It",
"defaults",
"to",
"leveldb",
"otherwise",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L355-L366 |
31,776 | perkeep/perkeep | pkg/serverinit/genconfig.go | sortedDBMS | func (b *lowBuilder) sortedDBMS(named dbname) (map[string]interface{}, error) {
if b.high.MySQL != "" {
return b.dbIndexStorage("mysql", b.high.MySQL, named)
}
if b.high.PostgreSQL != "" {
return b.dbIndexStorage("postgres", b.high.PostgreSQL, named)
}
if b.high.Mongo != "" {
return b.mongoIndexStorage(b.hig... | go | func (b *lowBuilder) sortedDBMS(named dbname) (map[string]interface{}, error) {
if b.high.MySQL != "" {
return b.dbIndexStorage("mysql", b.high.MySQL, named)
}
if b.high.PostgreSQL != "" {
return b.dbIndexStorage("postgres", b.high.PostgreSQL, named)
}
if b.high.Mongo != "" {
return b.mongoIndexStorage(b.hig... | [
"func",
"(",
"b",
"*",
"lowBuilder",
")",
"sortedDBMS",
"(",
"named",
"dbname",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"b",
".",
"high",
".",
"MySQL",
"!=",
"\"",
"\"",
"{",
"return",
"b",
".",
... | // sortedDBMS returns the configuration for a name database on one of the
// DBMS, if any was found in the configuration. It returns nil otherwise. | [
"sortedDBMS",
"returns",
"the",
"configuration",
"for",
"a",
"name",
"database",
"on",
"one",
"of",
"the",
"DBMS",
"if",
"any",
"was",
"found",
"in",
"the",
"configuration",
".",
"It",
"returns",
"nil",
"otherwise",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L467-L478 |
31,777 | perkeep/perkeep | pkg/serverinit/genconfig.go | sortedStorageAt | func (b *lowBuilder) sortedStorageAt(sortedType dbname, filePrefix string) (map[string]interface{}, error) {
dbms, err := b.sortedDBMS(sortedType)
if err != nil {
return nil, err
}
if dbms != nil {
return dbms, nil
}
if b.high.MemoryIndex {
return map[string]interface{}{
"type": "memory",
}, nil
}
if... | go | func (b *lowBuilder) sortedStorageAt(sortedType dbname, filePrefix string) (map[string]interface{}, error) {
dbms, err := b.sortedDBMS(sortedType)
if err != nil {
return nil, err
}
if dbms != nil {
return dbms, nil
}
if b.high.MemoryIndex {
return map[string]interface{}{
"type": "memory",
}, nil
}
if... | [
"func",
"(",
"b",
"*",
"lowBuilder",
")",
"sortedStorageAt",
"(",
"sortedType",
"dbname",
",",
"filePrefix",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"dbms",
",",
"err",
":=",
"b",
".",
"sortedDBMS",... | // filePrefix gives a file path of where to put the database. It can be omitted by
// some sorted implementations, but is required by others.
// The filePrefix should be to a file, not a directory, and should not end in a ".ext" extension.
// An extension like ".kv" or ".sqlite" will be added. | [
"filePrefix",
"gives",
"a",
"file",
"path",
"of",
"where",
"to",
"put",
"the",
"database",
".",
"It",
"can",
"be",
"omitted",
"by",
"some",
"sorted",
"implementations",
"but",
"is",
"required",
"by",
"others",
".",
"The",
"filePrefix",
"should",
"be",
"to"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L484-L526 |
31,778 | perkeep/perkeep | pkg/serverinit/genconfig.go | indexFileDir | func (b *lowBuilder) indexFileDir() string {
switch {
case b.high.SQLite != "":
return filepath.Dir(b.high.SQLite)
case b.high.KVFile != "":
return filepath.Dir(b.high.KVFile)
case b.high.LevelDB != "":
return filepath.Dir(b.high.LevelDB)
}
return ""
} | go | func (b *lowBuilder) indexFileDir() string {
switch {
case b.high.SQLite != "":
return filepath.Dir(b.high.SQLite)
case b.high.KVFile != "":
return filepath.Dir(b.high.KVFile)
case b.high.LevelDB != "":
return filepath.Dir(b.high.LevelDB)
}
return ""
} | [
"func",
"(",
"b",
"*",
"lowBuilder",
")",
"indexFileDir",
"(",
")",
"string",
"{",
"switch",
"{",
"case",
"b",
".",
"high",
".",
"SQLite",
"!=",
"\"",
"\"",
":",
"return",
"filepath",
".",
"Dir",
"(",
"b",
".",
"high",
".",
"SQLite",
")",
"\n",
"... | // indexFileDir returns the directory of the sqlite or kv file, or the
// empty string. | [
"indexFileDir",
"returns",
"the",
"directory",
"of",
"the",
"sqlite",
"or",
"kv",
"file",
"or",
"the",
"empty",
"string",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L827-L837 |
31,779 | perkeep/perkeep | pkg/serverinit/genconfig.go | WriteDefaultConfigFile | func WriteDefaultConfigFile(filePath string, useSQLite bool) error {
conf := defaultBaseConfig
blobDir, err := osutil.CamliBlobRoot()
if err != nil {
return err
}
varDir, err := osutil.CamliVarDir()
if err != nil {
return err
}
if err := wkfs.MkdirAll(blobDir, 0700); err != nil {
return fmt.Errorf("Could ... | go | func WriteDefaultConfigFile(filePath string, useSQLite bool) error {
conf := defaultBaseConfig
blobDir, err := osutil.CamliBlobRoot()
if err != nil {
return err
}
varDir, err := osutil.CamliVarDir()
if err != nil {
return err
}
if err := wkfs.MkdirAll(blobDir, 0700); err != nil {
return fmt.Errorf("Could ... | [
"func",
"WriteDefaultConfigFile",
"(",
"filePath",
"string",
",",
"useSQLite",
"bool",
")",
"error",
"{",
"conf",
":=",
"defaultBaseConfig",
"\n",
"blobDir",
",",
"err",
":=",
"osutil",
".",
"CamliBlobRoot",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // WriteDefaultConfigFile generates a new default high-level server configuration
// file at filePath. If useSQLite, the default indexer will use SQLite, otherwise
// leveldb. If filePath already exists, it is overwritten. | [
"WriteDefaultConfigFile",
"generates",
"a",
"new",
"default",
"high",
"-",
"level",
"server",
"configuration",
"file",
"at",
"filePath",
".",
"If",
"useSQLite",
"the",
"default",
"indexer",
"will",
"use",
"SQLite",
"otherwise",
"leveldb",
".",
"If",
"filePath",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/genconfig.go#L1246-L1285 |
31,780 | perkeep/perkeep | server/perkeepd/autodns.go | listenForCamliNet | func listenForCamliNet(ws *webserver.Server, config *serverinit.Config) (baseURL string, err error) {
camliNetIP := config.CamliNetIP()
if camliNetIP == "" {
return "", errors.New("no camliNetIP")
}
if ip := net.ParseIP(camliNetIP); ip == nil {
return "", fmt.Errorf("camliNetIP value %q is not a valid IP addres... | go | func listenForCamliNet(ws *webserver.Server, config *serverinit.Config) (baseURL string, err error) {
camliNetIP := config.CamliNetIP()
if camliNetIP == "" {
return "", errors.New("no camliNetIP")
}
if ip := net.ParseIP(camliNetIP); ip == nil {
return "", fmt.Errorf("camliNetIP value %q is not a valid IP addres... | [
"func",
"listenForCamliNet",
"(",
"ws",
"*",
"webserver",
".",
"Server",
",",
"config",
"*",
"serverinit",
".",
"Config",
")",
"(",
"baseURL",
"string",
",",
"err",
"error",
")",
"{",
"camliNetIP",
":=",
"config",
".",
"CamliNetIP",
"(",
")",
"\n",
"if",... | // listenForCamliNet prepares the TLS listener for both the GPG challenge, and
// for Let's Encrypt. It then starts listening and returns the baseURL derived from
// the hostname we should obtain from the GPG challenge. | [
"listenForCamliNet",
"prepares",
"the",
"TLS",
"listener",
"for",
"both",
"the",
"GPG",
"challenge",
"and",
"for",
"Let",
"s",
"Encrypt",
".",
"It",
"then",
"starts",
"listening",
"and",
"returns",
"the",
"baseURL",
"derived",
"from",
"the",
"hostname",
"we",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/autodns.go#L52-L105 |
31,781 | perkeep/perkeep | pkg/gc/gc.go | markItem | func (c *Collector) markItem(ctx context.Context, it Item, isRoot bool) error {
if !isRoot {
marked, err := c.Marker.IsMarked(it)
if err != nil {
return err
}
if marked {
return nil
}
}
if err := c.Marker.Mark(it); err != nil {
return err
}
// FIXME(tgulacsi): is it a problem that we cannot canc... | go | func (c *Collector) markItem(ctx context.Context, it Item, isRoot bool) error {
if !isRoot {
marked, err := c.Marker.IsMarked(it)
if err != nil {
return err
}
if marked {
return nil
}
}
if err := c.Marker.Mark(it); err != nil {
return err
}
// FIXME(tgulacsi): is it a problem that we cannot canc... | [
"func",
"(",
"c",
"*",
"Collector",
")",
"markItem",
"(",
"ctx",
"context",
".",
"Context",
",",
"it",
"Item",
",",
"isRoot",
"bool",
")",
"error",
"{",
"if",
"!",
"isRoot",
"{",
"marked",
",",
"err",
":=",
"c",
".",
"Marker",
".",
"IsMarked",
"(",... | // ctx will be canceled on failure | [
"ctx",
"will",
"be",
"canceled",
"on",
"failure"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/gc/gc.go#L88-L122 |
31,782 | perkeep/perkeep | pkg/gc/gc.go | Collect | func (c *Collector) Collect(ctx context.Context) (err error) {
if c.World == nil {
return errors.New("no World")
}
if c.Marker == nil {
return errors.New("no Marker")
}
if c.Roots == nil {
return errors.New("no Roots")
}
if c.Sweeper == nil {
return errors.New("no Sweeper")
}
if c.ItemEnumerator == nil... | go | func (c *Collector) Collect(ctx context.Context) (err error) {
if c.World == nil {
return errors.New("no World")
}
if c.Marker == nil {
return errors.New("no Marker")
}
if c.Roots == nil {
return errors.New("no Roots")
}
if c.Sweeper == nil {
return errors.New("no Sweeper")
}
if c.ItemEnumerator == nil... | [
"func",
"(",
"c",
"*",
"Collector",
")",
"Collect",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"if",
"c",
".",
"World",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if... | // Collect performs a garbage collection. | [
"Collect",
"performs",
"a",
"garbage",
"collection",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/gc/gc.go#L125-L200 |
31,783 | perkeep/perkeep | pkg/sorted/buffer/buffer.go | New | func New(buffer, backing sorted.KeyValue, maxBufferBytes int64) *KeyValue {
return &KeyValue{
buf: buffer,
back: backing,
maxBuffer: maxBufferBytes,
}
} | go | func New(buffer, backing sorted.KeyValue, maxBufferBytes int64) *KeyValue {
return &KeyValue{
buf: buffer,
back: backing,
maxBuffer: maxBufferBytes,
}
} | [
"func",
"New",
"(",
"buffer",
",",
"backing",
"sorted",
".",
"KeyValue",
",",
"maxBufferBytes",
"int64",
")",
"*",
"KeyValue",
"{",
"return",
"&",
"KeyValue",
"{",
"buf",
":",
"buffer",
",",
"back",
":",
"backing",
",",
"maxBuffer",
":",
"maxBufferBytes",
... | // New returnes a sorted.KeyValue implementation that adds a Flush
// method to flush the buffer to the backing storage. A flush will
// also be performed when maxBufferBytes are reached. If
// maxBufferBytes <= 0, no automatic flushing is performed. | [
"New",
"returnes",
"a",
"sorted",
".",
"KeyValue",
"implementation",
"that",
"adds",
"a",
"Flush",
"method",
"to",
"flush",
"the",
"buffer",
"to",
"the",
"backing",
"storage",
".",
"A",
"flush",
"will",
"also",
"be",
"performed",
"when",
"maxBufferBytes",
"a... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/buffer/buffer.go#L35-L41 |
31,784 | perkeep/perkeep | cmd/pk-put/kvcache.go | maybeRunCompaction | func maybeRunCompaction(dbname string, db *leveldb.DB) error {
val, err := db.GetProperty("leveldb.num-files-at-level0")
if err != nil {
return fmt.Errorf("could not get number of level-0 files of %v's LevelDB: %v", dbname, err)
}
nbFiles, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not c... | go | func maybeRunCompaction(dbname string, db *leveldb.DB) error {
val, err := db.GetProperty("leveldb.num-files-at-level0")
if err != nil {
return fmt.Errorf("could not get number of level-0 files of %v's LevelDB: %v", dbname, err)
}
nbFiles, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not c... | [
"func",
"maybeRunCompaction",
"(",
"dbname",
"string",
",",
"db",
"*",
"leveldb",
".",
"DB",
")",
"error",
"{",
"val",
",",
"err",
":=",
"db",
".",
"GetProperty",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Err... | // maybeRunCompaction forces compaction of db, if the number of
// tables in level 0 is >= 4. dbname should be provided for error messages. | [
"maybeRunCompaction",
"forces",
"compaction",
"of",
"db",
"if",
"the",
"number",
"of",
"tables",
"in",
"level",
"0",
"is",
">",
"=",
"4",
".",
"dbname",
"should",
"be",
"provided",
"for",
"error",
"messages",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk-put/kvcache.go#L76-L94 |
31,785 | perkeep/perkeep | cmd/pk-put/kvcache.go | marshalBinary | func (sk *statCacheKey) marshalBinary() ([]byte, error) {
if sk == nil {
return nil, errors.New("Can not marshal from a nil stat cache key")
}
data := make([]byte, 0, len(sk.Filepath)+3)
data = append(data, 1) // version number
data = append(data, sk.Filepath...)
data = append(data, '|')
if sk.Permanode {
da... | go | func (sk *statCacheKey) marshalBinary() ([]byte, error) {
if sk == nil {
return nil, errors.New("Can not marshal from a nil stat cache key")
}
data := make([]byte, 0, len(sk.Filepath)+3)
data = append(data, 1) // version number
data = append(data, sk.Filepath...)
data = append(data, '|')
if sk.Permanode {
da... | [
"func",
"(",
"sk",
"*",
"statCacheKey",
")",
"marshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"sk",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"data",
":="... | // marshalBinary returns a more compact binary
// representation of the contents of sk. | [
"marshalBinary",
"returns",
"a",
"more",
"compact",
"binary",
"representation",
"of",
"the",
"contents",
"of",
"sk",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk-put/kvcache.go#L234-L246 |
31,786 | perkeep/perkeep | cmd/pk-put/kvcache.go | marshalBinary | func (scv *statCacheValue) marshalBinary() ([]byte, error) {
if scv == nil {
return nil, errors.New("Can not marshal from a nil stat cache value")
}
binBr, _ := scv.Result.BlobRef.MarshalBinary()
// Blob size fits on 4 bytes when binary encoded
data := make([]byte, 0, len(scv.Fingerprint)+1+4+1+len(binBr))
buf ... | go | func (scv *statCacheValue) marshalBinary() ([]byte, error) {
if scv == nil {
return nil, errors.New("Can not marshal from a nil stat cache value")
}
binBr, _ := scv.Result.BlobRef.MarshalBinary()
// Blob size fits on 4 bytes when binary encoded
data := make([]byte, 0, len(scv.Fingerprint)+1+4+1+len(binBr))
buf ... | [
"func",
"(",
"scv",
"*",
"statCacheValue",
")",
"marshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"scv",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"binBr",
... | // marshalBinary returns a more compact binary
// representation of the contents of scv. | [
"marshalBinary",
"returns",
"a",
"more",
"compact",
"binary",
"representation",
"of",
"the",
"contents",
"of",
"scv",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk-put/kvcache.go#L257-L286 |
31,787 | perkeep/perkeep | internal/osutil/restart_unix.go | RestartProcess | func RestartProcess(arg ...string) error {
path, err := SelfPath()
if err != nil {
return fmt.Errorf("RestartProcess failed: %v", err)
}
var args []string
if len(arg) > 0 {
args = append(args, os.Args[0])
for _, v := range arg {
args = append(args, v)
}
} else {
args = os.Args
}
return syscall.Ex... | go | func RestartProcess(arg ...string) error {
path, err := SelfPath()
if err != nil {
return fmt.Errorf("RestartProcess failed: %v", err)
}
var args []string
if len(arg) > 0 {
args = append(args, os.Args[0])
for _, v := range arg {
args = append(args, v)
}
} else {
args = os.Args
}
return syscall.Ex... | [
"func",
"RestartProcess",
"(",
"arg",
"...",
"string",
")",
"error",
"{",
"path",
",",
"err",
":=",
"SelfPath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"v... | // RestartProcess restarts the process with the given arguments, if any,
// replacing the original process's arguments. It defaults to os.Args otherwise. It
// returns an error if things couldn't be restarted. On success, this function
// never returns because the process becomes the new process. | [
"RestartProcess",
"restarts",
"the",
"process",
"with",
"the",
"given",
"arguments",
"if",
"any",
"replacing",
"the",
"original",
"process",
"s",
"arguments",
".",
"It",
"defaults",
"to",
"os",
".",
"Args",
"otherwise",
".",
"It",
"returns",
"an",
"error",
"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/restart_unix.go#L63-L80 |
31,788 | perkeep/perkeep | misc/docker/dock.go | buildDockerImage | func buildDockerImage(imageDir, imageName string) {
if dockDir == "" {
panic("dockDir should be set before calling buildDockerImage")
}
cmd := exec.Command("docker", "build", "-t", imageName, ".")
cmd.Dir = filepath.Join(dockDir, imageDir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err ... | go | func buildDockerImage(imageDir, imageName string) {
if dockDir == "" {
panic("dockDir should be set before calling buildDockerImage")
}
cmd := exec.Command("docker", "build", "-t", imageName, ".")
cmd.Dir = filepath.Join(dockDir, imageDir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err ... | [
"func",
"buildDockerImage",
"(",
"imageDir",
",",
"imageName",
"string",
")",
"{",
"if",
"dockDir",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
... | // buildDockerImage builds a docker image from the Dockerfile located in
// imageDir, which is a path relative to dockDir. The image will be named after
// imageName. dockDir should have been set behorehand. | [
"buildDockerImage",
"builds",
"a",
"docker",
"image",
"from",
"the",
"Dockerfile",
"located",
"in",
"imageDir",
"which",
"is",
"a",
"path",
"relative",
"to",
"dockDir",
".",
"The",
"image",
"will",
"be",
"named",
"after",
"imageName",
".",
"dockDir",
"should",... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/docker/dock.go#L54-L65 |
31,789 | perkeep/perkeep | pkg/blobserver/mergedenum.go | MergedEnumerate | func MergedEnumerate(ctx context.Context, dest chan<- blob.SizedRef, sources []BlobEnumerator, after string, limit int) error {
return mergedEnumerate(ctx, dest, len(sources), func(i int) BlobEnumerator { return sources[i] }, after, limit)
} | go | func MergedEnumerate(ctx context.Context, dest chan<- blob.SizedRef, sources []BlobEnumerator, after string, limit int) error {
return mergedEnumerate(ctx, dest, len(sources), func(i int) BlobEnumerator { return sources[i] }, after, limit)
} | [
"func",
"MergedEnumerate",
"(",
"ctx",
"context",
".",
"Context",
",",
"dest",
"chan",
"<-",
"blob",
".",
"SizedRef",
",",
"sources",
"[",
"]",
"BlobEnumerator",
",",
"after",
"string",
",",
"limit",
"int",
")",
"error",
"{",
"return",
"mergedEnumerate",
"... | // MergedEnumerate implements the BlobEnumerator interface by
// merge-joining 0 or more sources. | [
"MergedEnumerate",
"implements",
"the",
"BlobEnumerator",
"interface",
"by",
"merge",
"-",
"joining",
"0",
"or",
"more",
"sources",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/mergedenum.go#L29-L31 |
31,790 | perkeep/perkeep | pkg/deploy/gce/deploy.go | NewOAuthConfig | func NewOAuthConfig(clientID, clientSecret string) *oauth2.Config {
return &oauth2.Config{
Scopes: []string{
logging.WriteScope,
compute.DevstorageFullControlScope,
compute.ComputeScope,
cloudresourcemanager.CloudPlatformScope,
servicemanagement.CloudPlatformScope,
"https://www.googleapis.com/auth/... | go | func NewOAuthConfig(clientID, clientSecret string) *oauth2.Config {
return &oauth2.Config{
Scopes: []string{
logging.WriteScope,
compute.DevstorageFullControlScope,
compute.ComputeScope,
cloudresourcemanager.CloudPlatformScope,
servicemanagement.CloudPlatformScope,
"https://www.googleapis.com/auth/... | [
"func",
"NewOAuthConfig",
"(",
"clientID",
",",
"clientSecret",
"string",
")",
"*",
"oauth2",
".",
"Config",
"{",
"return",
"&",
"oauth2",
".",
"Config",
"{",
"Scopes",
":",
"[",
"]",
"string",
"{",
"logging",
".",
"WriteScope",
",",
"compute",
".",
"Dev... | // NewOAuthConfig returns an OAuth configuration template. | [
"NewOAuthConfig",
"returns",
"an",
"OAuth",
"configuration",
"template",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/deploy.go#L83-L98 |
31,791 | perkeep/perkeep | pkg/deploy/gce/deploy.go | Get | func (d *Deployer) Get() (*compute.Instance, error) {
computeService, err := compute.New(d.Client)
if err != nil {
return nil, err
}
return computeService.Instances.Get(d.Conf.Project, d.Conf.Zone, d.Conf.Name).Do()
} | go | func (d *Deployer) Get() (*compute.Instance, error) {
computeService, err := compute.New(d.Client)
if err != nil {
return nil, err
}
return computeService.Instances.Get(d.Conf.Project, d.Conf.Zone, d.Conf.Name).Do()
} | [
"func",
"(",
"d",
"*",
"Deployer",
")",
"Get",
"(",
")",
"(",
"*",
"compute",
".",
"Instance",
",",
"error",
")",
"{",
"computeService",
",",
"err",
":=",
"compute",
".",
"New",
"(",
"d",
".",
"Client",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Get returns the Instance corresponding to the Project, Zone, and Name defined in the
// Deployer's Conf. | [
"Get",
"returns",
"the",
"Instance",
"corresponding",
"to",
"the",
"Project",
"Zone",
"and",
"Name",
"defined",
"in",
"the",
"Deployer",
"s",
"Conf",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/deploy.go#L138-L144 |
31,792 | perkeep/perkeep | pkg/deploy/gce/deploy.go | projectHasInstance | func (d *Deployer) projectHasInstance() (zone string, err error) {
s, err := compute.New(d.Client)
if err != nil {
return "", err
}
// TODO(mpl): make use of the handler's cached zones.
zl, err := compute.NewZonesService(s).List(d.Conf.Project).Do()
if err != nil {
return "", fmt.Errorf("could not get a list ... | go | func (d *Deployer) projectHasInstance() (zone string, err error) {
s, err := compute.New(d.Client)
if err != nil {
return "", err
}
// TODO(mpl): make use of the handler's cached zones.
zl, err := compute.NewZonesService(s).List(d.Conf.Project).Do()
if err != nil {
return "", fmt.Errorf("could not get a list ... | [
"func",
"(",
"d",
"*",
"Deployer",
")",
"projectHasInstance",
"(",
")",
"(",
"zone",
"string",
",",
"err",
"error",
")",
"{",
"s",
",",
"err",
":=",
"compute",
".",
"New",
"(",
"d",
".",
"Client",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // projectHasInstance checks for all the possible zones if there's already an instance for the project.
// It returns the name of the zone at the first instance it finds, if any. | [
"projectHasInstance",
"checks",
"for",
"all",
"the",
"possible",
"zones",
"if",
"there",
"s",
"already",
"an",
"instance",
"for",
"the",
"project",
".",
"It",
"returns",
"the",
"name",
"of",
"the",
"zone",
"at",
"the",
"first",
"instance",
"it",
"finds",
"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/deploy.go#L169-L216 |
31,793 | perkeep/perkeep | pkg/deploy/gce/deploy.go | getInstanceAttribute | func (d *Deployer) getInstanceAttribute(attr string) (string, error) {
s, err := compute.New(d.Client)
if err != nil {
return "", fmt.Errorf("error getting compute service: %v", err)
}
inst, err := compute.NewInstancesService(s).Get(d.Conf.Project, d.Conf.Zone, d.Conf.Name).Do()
if err != nil {
return "", fmt.... | go | func (d *Deployer) getInstanceAttribute(attr string) (string, error) {
s, err := compute.New(d.Client)
if err != nil {
return "", fmt.Errorf("error getting compute service: %v", err)
}
inst, err := compute.NewInstancesService(s).Get(d.Conf.Project, d.Conf.Zone, d.Conf.Name).Do()
if err != nil {
return "", fmt.... | [
"func",
"(",
"d",
"*",
"Deployer",
")",
"getInstanceAttribute",
"(",
"attr",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"compute",
".",
"New",
"(",
"d",
".",
"Client",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // getInstanceAttribute returns the value for attr in the custom metadata of the
// instance. It returns errAttrNotFound is such a metadata attributed does not
// exist. | [
"getInstanceAttribute",
"returns",
"the",
"value",
"for",
"attr",
"in",
"the",
"custom",
"metadata",
"of",
"the",
"instance",
".",
"It",
"returns",
"errAttrNotFound",
"is",
"such",
"a",
"metadata",
"attributed",
"does",
"not",
"exist",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/deploy.go#L455-L470 |
31,794 | perkeep/perkeep | pkg/deploy/gce/deploy.go | Create | func (d *Deployer) Create(ctx context.Context) (*compute.Instance, error) {
if err := d.enableAPIs(); err != nil {
return nil, projectIDError{
id: d.Conf.Project,
cause: err,
}
}
if err := d.checkProjectID(); err != nil {
return nil, err
}
computeService, _ := compute.New(d.Client)
storageService,... | go | func (d *Deployer) Create(ctx context.Context) (*compute.Instance, error) {
if err := d.enableAPIs(); err != nil {
return nil, projectIDError{
id: d.Conf.Project,
cause: err,
}
}
if err := d.checkProjectID(); err != nil {
return nil, err
}
computeService, _ := compute.New(d.Client)
storageService,... | [
"func",
"(",
"d",
"*",
"Deployer",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"compute",
".",
"Instance",
",",
"error",
")",
"{",
"if",
"err",
":=",
"d",
".",
"enableAPIs",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return... | // Create sets up and starts a Google Compute Engine instance as defined in d.Conf. It
// creates the necessary Google Storage buckets beforehand. | [
"Create",
"sets",
"up",
"and",
"starts",
"a",
"Google",
"Compute",
"Engine",
"instance",
"as",
"defined",
"in",
"d",
".",
"Conf",
".",
"It",
"creates",
"the",
"necessary",
"Google",
"Storage",
"buckets",
"beforehand",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/deploy.go#L474-L529 |
31,795 | perkeep/perkeep | pkg/deploy/gce/deploy.go | setBuckets | func (d *Deployer) setBuckets(ctx context.Context, storageService *storage.Service) error {
projBucket := d.Conf.Project + "-camlistore"
needBucket := map[string]bool{
projBucket: true,
}
buckets, err := storageService.Buckets.List(d.Conf.Project).Do()
if err != nil {
return fmt.Errorf("error listing buckets... | go | func (d *Deployer) setBuckets(ctx context.Context, storageService *storage.Service) error {
projBucket := d.Conf.Project + "-camlistore"
needBucket := map[string]bool{
projBucket: true,
}
buckets, err := storageService.Buckets.List(d.Conf.Project).Do()
if err != nil {
return fmt.Errorf("error listing buckets... | [
"func",
"(",
"d",
"*",
"Deployer",
")",
"setBuckets",
"(",
"ctx",
"context",
".",
"Context",
",",
"storageService",
"*",
"storage",
".",
"Service",
")",
"error",
"{",
"projBucket",
":=",
"d",
".",
"Conf",
".",
"Project",
"+",
"\"",
"\"",
"\n\n",
"needB... | // setBuckets defines the buckets needed by the instance and creates them. | [
"setBuckets",
"defines",
"the",
"buckets",
"needed",
"by",
"the",
"instance",
"and",
"creates",
"them",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/deploy.go#L708-L763 |
31,796 | perkeep/perkeep | pkg/deploy/gce/deploy.go | setFirewall | func (d *Deployer) setFirewall(ctx context.Context, computeService *compute.Service) error {
defaultNet, err := computeService.Networks.Get(d.Conf.Project, "default").Do()
if err != nil {
return fmt.Errorf("error getting default network: %v", err)
}
needRules := map[string]compute.Firewall{
"default-allow-http... | go | func (d *Deployer) setFirewall(ctx context.Context, computeService *compute.Service) error {
defaultNet, err := computeService.Networks.Get(d.Conf.Project, "default").Do()
if err != nil {
return fmt.Errorf("error getting default network: %v", err)
}
needRules := map[string]compute.Firewall{
"default-allow-http... | [
"func",
"(",
"d",
"*",
"Deployer",
")",
"setFirewall",
"(",
"ctx",
"context",
".",
"Context",
",",
"computeService",
"*",
"compute",
".",
"Service",
")",
"error",
"{",
"defaultNet",
",",
"err",
":=",
"computeService",
".",
"Networks",
".",
"Get",
"(",
"d... | // setFirewall adds the firewall rules needed for ports 80 & 433 to the default network. | [
"setFirewall",
"adds",
"the",
"firewall",
"rules",
"needed",
"for",
"ports",
"80",
"&",
"433",
"to",
"the",
"default",
"network",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/deploy.go#L766-L826 |
31,797 | perkeep/perkeep | pkg/webserver/webserver.go | loadX509KeyPair | func loadX509KeyPair(certFile, keyFile string) (cert tls.Certificate, err error) {
certPEMBlock, err := wkfs.ReadFile(certFile)
if err != nil {
return
}
keyPEMBlock, err := wkfs.ReadFile(keyFile)
if err != nil {
return
}
return tls.X509KeyPair(certPEMBlock, keyPEMBlock)
} | go | func loadX509KeyPair(certFile, keyFile string) (cert tls.Certificate, err error) {
certPEMBlock, err := wkfs.ReadFile(certFile)
if err != nil {
return
}
keyPEMBlock, err := wkfs.ReadFile(keyFile)
if err != nil {
return
}
return tls.X509KeyPair(certPEMBlock, keyPEMBlock)
} | [
"func",
"loadX509KeyPair",
"(",
"certFile",
",",
"keyFile",
"string",
")",
"(",
"cert",
"tls",
".",
"Certificate",
",",
"err",
"error",
")",
"{",
"certPEMBlock",
",",
"err",
":=",
"wkfs",
".",
"ReadFile",
"(",
"certFile",
")",
"\n",
"if",
"err",
"!=",
... | // loadX509KeyPair is a copy of tls.LoadX509KeyPair but using wkfs. | [
"loadX509KeyPair",
"is",
"a",
"copy",
"of",
"tls",
".",
"LoadX509KeyPair",
"but",
"using",
"wkfs",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/webserver/webserver.go#L277-L287 |
31,798 | perkeep/perkeep | internal/httputil/httputil.go | RequestTargetPort | func RequestTargetPort(req *http.Request) int {
_, portStr, err := net.SplitHostPort(req.Host)
if err == nil && portStr != "" {
port, err := strconv.ParseInt(portStr, 0, 64)
if err == nil {
return int(port)
}
}
if req.TLS != nil {
return 443
}
return 80
} | go | func RequestTargetPort(req *http.Request) int {
_, portStr, err := net.SplitHostPort(req.Host)
if err == nil && portStr != "" {
port, err := strconv.ParseInt(portStr, 0, 64)
if err == nil {
return int(port)
}
}
if req.TLS != nil {
return 443
}
return 80
} | [
"func",
"RequestTargetPort",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"int",
"{",
"_",
",",
"portStr",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"req",
".",
"Host",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"portStr",
"!=",
"\"",
"\... | // RequestTargetPort returns the port targeted by the client
// in req. If not present, it returns 80, or 443 if TLS is used. | [
"RequestTargetPort",
"returns",
"the",
"port",
"targeted",
"by",
"the",
"client",
"in",
"req",
".",
"If",
"not",
"present",
"it",
"returns",
"80",
"or",
"443",
"if",
"TLS",
"is",
"used",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/httputil.go#L153-L165 |
31,799 | perkeep/perkeep | internal/httputil/httputil.go | RecoverJSON | func RecoverJSON(rw http.ResponseWriter, req *http.Request) {
e := recover()
if e == nil {
return
}
ServeJSONError(rw, e)
} | go | func RecoverJSON(rw http.ResponseWriter, req *http.Request) {
e := recover()
if e == nil {
return
}
ServeJSONError(rw, e)
} | [
"func",
"RecoverJSON",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"e",
":=",
"recover",
"(",
")",
"\n",
"if",
"e",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"ServeJSONError",
"(",
"rw",
",",
"e",... | // RecoverJSON is like Recover but returns with a JSON response. | [
"RecoverJSON",
"is",
"like",
"Recover",
"but",
"returns",
"with",
"a",
"JSON",
"response",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/httputil.go#L182-L188 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.