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,500 | perkeep/perkeep | internal/osutil/paths.go | HomeDir | func HomeDir() string {
failInTests()
if runtime.GOOS == "windows" {
return os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
}
return os.Getenv("HOME")
} | go | func HomeDir() string {
failInTests()
if runtime.GOOS == "windows" {
return os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
}
return os.Getenv("HOME")
} | [
"func",
"HomeDir",
"(",
")",
"string",
"{",
"failInTests",
"(",
")",
"\n",
"if",
"runtime",
".",
"GOOS",
"==",
"\"",
"\"",
"{",
"return",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"+",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n"... | // HomeDir returns the path to the user's home directory.
// It returns the empty string if the value isn't known. | [
"HomeDir",
"returns",
"the",
"path",
"to",
"the",
"user",
"s",
"home",
"directory",
".",
"It",
"returns",
"the",
"empty",
"string",
"if",
"the",
"value",
"isn",
"t",
"known",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/paths.go#L37-L43 |
31,501 | perkeep/perkeep | internal/osutil/paths.go | NewJSONConfigParser | func NewJSONConfigParser() *jsonconfig.ConfigParser {
var cp jsonconfig.ConfigParser
dir, err := PerkeepConfigDir()
if err != nil {
log.Fatalf("NewJSONConfigParser error: %v", err)
}
cp.IncludeDirs = append([]string{dir}, filepath.SplitList(os.Getenv("CAMLI_INCLUDE_PATH"))...)
return &cp
} | go | func NewJSONConfigParser() *jsonconfig.ConfigParser {
var cp jsonconfig.ConfigParser
dir, err := PerkeepConfigDir()
if err != nil {
log.Fatalf("NewJSONConfigParser error: %v", err)
}
cp.IncludeDirs = append([]string{dir}, filepath.SplitList(os.Getenv("CAMLI_INCLUDE_PATH"))...)
return &cp
} | [
"func",
"NewJSONConfigParser",
"(",
")",
"*",
"jsonconfig",
".",
"ConfigParser",
"{",
"var",
"cp",
"jsonconfig",
".",
"ConfigParser",
"\n",
"dir",
",",
"err",
":=",
"PerkeepConfigDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
... | // NewJSONConfigParser returns a jsonconfig.ConfigParser with its IncludeDirs
// set with PerkeepConfigDir and the contents of CAMLI_INCLUDE_PATH. | [
"NewJSONConfigParser",
"returns",
"a",
"jsonconfig",
".",
"ConfigParser",
"with",
"its",
"IncludeDirs",
"set",
"with",
"PerkeepConfigDir",
"and",
"the",
"contents",
"of",
"CAMLI_INCLUDE_PATH",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/paths.go#L332-L340 |
31,502 | perkeep/perkeep | pkg/sorted/mem.go | NewMemoryKeyValue | func NewMemoryKeyValue() KeyValue {
db := memdb.New(comparer.DefaultComparer, 128)
return &memKeys{db: db}
} | go | func NewMemoryKeyValue() KeyValue {
db := memdb.New(comparer.DefaultComparer, 128)
return &memKeys{db: db}
} | [
"func",
"NewMemoryKeyValue",
"(",
")",
"KeyValue",
"{",
"db",
":=",
"memdb",
".",
"New",
"(",
"comparer",
".",
"DefaultComparer",
",",
"128",
")",
"\n",
"return",
"&",
"memKeys",
"{",
"db",
":",
"db",
"}",
"\n",
"}"
] | // NewMemoryKeyValue returns a KeyValue implementation that's backed only
// by memory. It's mostly useful for tests and development. | [
"NewMemoryKeyValue",
"returns",
"a",
"KeyValue",
"implementation",
"that",
"s",
"backed",
"only",
"by",
"memory",
".",
"It",
"s",
"mostly",
"useful",
"for",
"tests",
"and",
"development",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mem.go#L33-L36 |
31,503 | perkeep/perkeep | app/publisher/zip.go | blobsFromDir | func (zh *zipHandler) blobsFromDir(dirPath string, dirBlob blob.Ref) ([]*blobFile, error) {
var list []*blobFile
dr, err := schema.NewDirReader(context.TODO(), zh.fetcher, dirBlob)
if err != nil {
return nil, fmt.Errorf("Could not read dir blob %v: %v", dirBlob, err)
}
ent, err := dr.Readdir(context.TODO(), -1)
... | go | func (zh *zipHandler) blobsFromDir(dirPath string, dirBlob blob.Ref) ([]*blobFile, error) {
var list []*blobFile
dr, err := schema.NewDirReader(context.TODO(), zh.fetcher, dirBlob)
if err != nil {
return nil, fmt.Errorf("Could not read dir blob %v: %v", dirBlob, err)
}
ent, err := dr.Readdir(context.TODO(), -1)
... | [
"func",
"(",
"zh",
"*",
"zipHandler",
")",
"blobsFromDir",
"(",
"dirPath",
"string",
",",
"dirBlob",
"blob",
".",
"Ref",
")",
"(",
"[",
"]",
"*",
"blobFile",
",",
"error",
")",
"{",
"var",
"list",
"[",
"]",
"*",
"blobFile",
"\n",
"dr",
",",
"err",
... | // blobsFromDir returns the list of file blobs in directory dirBlob.
// It only traverses permanode directories. | [
"blobsFromDir",
"returns",
"the",
"list",
"of",
"file",
"blobs",
"in",
"directory",
"dirBlob",
".",
"It",
"only",
"traverses",
"permanode",
"directories",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/zip.go#L159-L183 |
31,504 | perkeep/perkeep | app/publisher/zip.go | renameDuplicates | func renameDuplicates(bf []*blobFile) sortedFiles {
noDup := make(map[string]blob.Ref)
// use a map to detect duplicates and rename them
for _, file := range bf {
if _, ok := noDup[file.path]; ok {
// path already exists, so rename
suffix := 0
var newname string
for {
suffix++
ext := path.Ext(f... | go | func renameDuplicates(bf []*blobFile) sortedFiles {
noDup := make(map[string]blob.Ref)
// use a map to detect duplicates and rename them
for _, file := range bf {
if _, ok := noDup[file.path]; ok {
// path already exists, so rename
suffix := 0
var newname string
for {
suffix++
ext := path.Ext(f... | [
"func",
"renameDuplicates",
"(",
"bf",
"[",
"]",
"*",
"blobFile",
")",
"sortedFiles",
"{",
"noDup",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"blob",
".",
"Ref",
")",
"\n",
"// use a map to detect duplicates and rename them",
"for",
"_",
",",
"file",
":=... | // renameDuplicates goes through bf to check for duplicate filepaths.
// It renames duplicate filepaths and returns a new slice, sorted by
// file path. | [
"renameDuplicates",
"goes",
"through",
"bf",
"to",
"check",
"for",
"duplicate",
"filepaths",
".",
"It",
"renames",
"duplicate",
"filepaths",
"and",
"returns",
"a",
"new",
"slice",
"sorted",
"by",
"file",
"path",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/zip.go#L188-L218 |
31,505 | perkeep/perkeep | app/publisher/zip.go | ServeHTTP | func (zh *zipHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// TODO: use http.ServeContent, so Range requests work and downloads can be resumed.
// Will require calculating the zip length once first (ideally as cheaply as possible,
// with dummy counting writer and dummy all-zero-byte-files of a fix... | go | func (zh *zipHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// TODO: use http.ServeContent, so Range requests work and downloads can be resumed.
// Will require calculating the zip length once first (ideally as cheaply as possible,
// with dummy counting writer and dummy all-zero-byte-files of a fix... | [
"func",
"(",
"zh",
"*",
"zipHandler",
")",
"ServeHTTP",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"// TODO: use http.ServeContent, so Range requests work and downloads can be resumed.",
"// Will require calculating the zip ... | // ServeHTTP streams a zip archive of all the files "under"
// zh.root. That is, all the files pointed by file permanodes,
// which are directly members of zh.root or recursively down
// directory permanodes and permanodes members.
// To build the fullpath of a file in a collection, it uses
// the collection title if p... | [
"ServeHTTP",
"streams",
"a",
"zip",
"archive",
"of",
"all",
"the",
"files",
"under",
"zh",
".",
"root",
".",
"That",
"is",
"all",
"the",
"files",
"pointed",
"by",
"file",
"permanodes",
"which",
"are",
"directly",
"members",
"of",
"zh",
".",
"root",
"or",... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/zip.go#L227-L292 |
31,506 | perkeep/perkeep | server/perkeepd/ui/goui/sharebutton/gen_ShareItemsBtn_reactGen.go | Props | func (s ShareItemsBtnDef) Props() ShareItemsBtnProps {
uprops := s.ComponentDef.Props()
return uprops.(ShareItemsBtnProps)
} | go | func (s ShareItemsBtnDef) Props() ShareItemsBtnProps {
uprops := s.ComponentDef.Props()
return uprops.(ShareItemsBtnProps)
} | [
"func",
"(",
"s",
"ShareItemsBtnDef",
")",
"Props",
"(",
")",
"ShareItemsBtnProps",
"{",
"uprops",
":=",
"s",
".",
"ComponentDef",
".",
"Props",
"(",
")",
"\n",
"return",
"uprops",
".",
"(",
"ShareItemsBtnProps",
")",
"\n",
"}"
] | // Props is an auto-generated proxy to the current props of ShareItemsBtn | [
"Props",
"is",
"an",
"auto",
"-",
"generated",
"proxy",
"to",
"the",
"current",
"props",
"of",
"ShareItemsBtn"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/sharebutton/gen_ShareItemsBtn_reactGen.go#L30-L33 |
31,507 | perkeep/perkeep | app/publisher/main.go | appConfig | func appConfig() (*config, error) {
configURL := os.Getenv("CAMLI_APP_CONFIG_URL")
if configURL == "" {
return nil, fmt.Errorf("Publisher application needs a CAMLI_APP_CONFIG_URL env var")
}
cl, err := app.Client()
if err != nil {
return nil, fmt.Errorf("could not get a client to fetch extra config: %v", err)
... | go | func appConfig() (*config, error) {
configURL := os.Getenv("CAMLI_APP_CONFIG_URL")
if configURL == "" {
return nil, fmt.Errorf("Publisher application needs a CAMLI_APP_CONFIG_URL env var")
}
cl, err := app.Client()
if err != nil {
return nil, fmt.Errorf("could not get a client to fetch extra config: %v", err)
... | [
"func",
"appConfig",
"(",
")",
"(",
"*",
"config",
",",
"error",
")",
"{",
"configURL",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"configURL",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
... | // appConfig keeps on trying to fetch the extra config from the app handler. If
// it doesn't succed after an hour has passed, the program exits. | [
"appConfig",
"keeps",
"on",
"trying",
"to",
"fetch",
"the",
"extra",
"config",
"from",
"the",
"app",
"handler",
".",
"If",
"it",
"doesn",
"t",
"succed",
"after",
"an",
"hour",
"has",
"passed",
"the",
"program",
"exits",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L93-L118 |
31,508 | perkeep/perkeep | app/publisher/main.go | setMasterQuery | func (ph *publishHandler) setMasterQuery(topNode blob.Ref) error {
query := &search.SearchQuery{
Sort: search.CreatedDesc,
Limit: -1,
Constraint: &search.Constraint{
Permanode: &search.PermanodeConstraint{
Relation: &search.RelationConstraint{
Relation: "parent",
Any: &search.Constraint{
... | go | func (ph *publishHandler) setMasterQuery(topNode blob.Ref) error {
query := &search.SearchQuery{
Sort: search.CreatedDesc,
Limit: -1,
Constraint: &search.Constraint{
Permanode: &search.PermanodeConstraint{
Relation: &search.RelationConstraint{
Relation: "parent",
Any: &search.Constraint{
... | [
"func",
"(",
"ph",
"*",
"publishHandler",
")",
"setMasterQuery",
"(",
"topNode",
"blob",
".",
"Ref",
")",
"error",
"{",
"query",
":=",
"&",
"search",
".",
"SearchQuery",
"{",
"Sort",
":",
"search",
".",
"CreatedDesc",
",",
"Limit",
":",
"-",
"1",
",",
... | // setMasterQuery registers with the app handler a master query that includes
// topNode and all its descendants as the search response. | [
"setMasterQuery",
"registers",
"with",
"the",
"app",
"handler",
"a",
"master",
"query",
"that",
"includes",
"topNode",
"and",
"all",
"its",
"descendants",
"as",
"the",
"search",
"response",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L122-L169 |
31,509 | perkeep/perkeep | app/publisher/main.go | resolvePrefixHop | func (ph *publishHandler) resolvePrefixHop(parent blob.Ref, prefix string) (child blob.Ref, err error) {
// TODO: this is a linear scan right now. this should be
// optimized to use a new database table of members so this is
// a quick lookup. in the meantime it should be in memcached
// at least.
if len(prefix) ... | go | func (ph *publishHandler) resolvePrefixHop(parent blob.Ref, prefix string) (child blob.Ref, err error) {
// TODO: this is a linear scan right now. this should be
// optimized to use a new database table of members so this is
// a quick lookup. in the meantime it should be in memcached
// at least.
if len(prefix) ... | [
"func",
"(",
"ph",
"*",
"publishHandler",
")",
"resolvePrefixHop",
"(",
"parent",
"blob",
".",
"Ref",
",",
"prefix",
"string",
")",
"(",
"child",
"blob",
".",
"Ref",
",",
"err",
"error",
")",
"{",
"// TODO: this is a linear scan right now. this should be",
"// o... | // Given a blobref and a few hex characters of the digest of the next hop, return the complete
// blobref of the prefix, if that's a valid next hop. | [
"Given",
"a",
"blobref",
"and",
"a",
"few",
"hex",
"characters",
"of",
"the",
"digest",
"of",
"the",
"next",
"hop",
"return",
"the",
"complete",
"blobref",
"of",
"the",
"prefix",
"if",
"that",
"s",
"a",
"valid",
"next",
"hop",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L565-L602 |
31,510 | perkeep/perkeep | app/publisher/main.go | serveSubjectTemplate | func (pr *publishRequest) serveSubjectTemplate() {
res, err := pr.ph.deepDescribe(pr.subject)
if err != nil {
httputil.ServeError(pr.rw, pr.req, err)
return
}
pr.ph.cacheDescribed(res.Meta)
subdes := res.Meta[pr.subject.String()]
if subdes.CamliType == "file" {
pr.serveFileDownload(subdes)
return
}
he... | go | func (pr *publishRequest) serveSubjectTemplate() {
res, err := pr.ph.deepDescribe(pr.subject)
if err != nil {
httputil.ServeError(pr.rw, pr.req, err)
return
}
pr.ph.cacheDescribed(res.Meta)
subdes := res.Meta[pr.subject.String()]
if subdes.CamliType == "file" {
pr.serveFileDownload(subdes)
return
}
he... | [
"func",
"(",
"pr",
"*",
"publishRequest",
")",
"serveSubjectTemplate",
"(",
")",
"{",
"res",
",",
"err",
":=",
"pr",
".",
"ph",
".",
"deepDescribe",
"(",
"pr",
".",
"subject",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"httputil",
".",
"ServeError",
"... | // serveSubjectTemplate creates the funcs to generate the PageHeader, PageFile,
// and pageMembers that can be used by the subject template, and serves the template. | [
"serveSubjectTemplate",
"creates",
"the",
"funcs",
"to",
"generate",
"the",
"PageHeader",
"PageFile",
"and",
"pageMembers",
"that",
"can",
"be",
"used",
"by",
"the",
"subject",
"template",
"and",
"serves",
"the",
"template",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L863-L908 |
31,511 | perkeep/perkeep | app/publisher/main.go | subjectHeader | func (pr *publishRequest) subjectHeader(described map[string]*search.DescribedBlob) *publish.PageHeader {
subdes := described[pr.subject.String()]
header := &publish.PageHeader{
Title: html.EscapeString(getTitle(subdes.BlobRef, described)),
CSSFiles: pr.cssFiles(),
JSDeps: pr.jsDeps(),... | go | func (pr *publishRequest) subjectHeader(described map[string]*search.DescribedBlob) *publish.PageHeader {
subdes := described[pr.subject.String()]
header := &publish.PageHeader{
Title: html.EscapeString(getTitle(subdes.BlobRef, described)),
CSSFiles: pr.cssFiles(),
JSDeps: pr.jsDeps(),... | [
"func",
"(",
"pr",
"*",
"publishRequest",
")",
"subjectHeader",
"(",
"described",
"map",
"[",
"string",
"]",
"*",
"search",
".",
"DescribedBlob",
")",
"*",
"publish",
".",
"PageHeader",
"{",
"subdes",
":=",
"described",
"[",
"pr",
".",
"subject",
".",
"S... | // subjectHeader returns the PageHeader corresponding to the described subject. | [
"subjectHeader",
"returns",
"the",
"PageHeader",
"corresponding",
"to",
"the",
"described",
"subject",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L977-L990 |
31,512 | perkeep/perkeep | app/publisher/main.go | subjectFile | func (pr *publishRequest) subjectFile(described map[string]*search.DescribedBlob) (*publish.PageFile, error) {
subdes := described[pr.subject.String()]
contentRef, ok := subdes.ContentRef()
if !ok {
return nil, nil
}
fileDes, err := pr.ph.describe(contentRef)
if err != nil {
return nil, err
}
if fileDes.Fil... | go | func (pr *publishRequest) subjectFile(described map[string]*search.DescribedBlob) (*publish.PageFile, error) {
subdes := described[pr.subject.String()]
contentRef, ok := subdes.ContentRef()
if !ok {
return nil, nil
}
fileDes, err := pr.ph.describe(contentRef)
if err != nil {
return nil, err
}
if fileDes.Fil... | [
"func",
"(",
"pr",
"*",
"publishRequest",
")",
"subjectFile",
"(",
"described",
"map",
"[",
"string",
"]",
"*",
"search",
".",
"DescribedBlob",
")",
"(",
"*",
"publish",
".",
"PageFile",
",",
"error",
")",
"{",
"subdes",
":=",
"described",
"[",
"pr",
"... | // subjectFile returns the relevant PageFile if the described subject is a file permanode. | [
"subjectFile",
"returns",
"the",
"relevant",
"PageFile",
"if",
"the",
"described",
"subject",
"is",
"a",
"file",
"permanode",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L1037-L1071 |
31,513 | perkeep/perkeep | app/publisher/main.go | subjectMembers | func (pr *publishRequest) subjectMembers(resMap map[string]*search.DescribedBlob) (*publish.PageMembers, error) {
subdes := resMap[pr.subject.String()]
res, err := pr.ph.describeMembers(pr.subject)
if err != nil {
return nil, err
}
members := []*search.DescribedBlob{}
for _, v := range res.Blobs {
members = a... | go | func (pr *publishRequest) subjectMembers(resMap map[string]*search.DescribedBlob) (*publish.PageMembers, error) {
subdes := resMap[pr.subject.String()]
res, err := pr.ph.describeMembers(pr.subject)
if err != nil {
return nil, err
}
members := []*search.DescribedBlob{}
for _, v := range res.Blobs {
members = a... | [
"func",
"(",
"pr",
"*",
"publishRequest",
")",
"subjectMembers",
"(",
"resMap",
"map",
"[",
"string",
"]",
"*",
"search",
".",
"DescribedBlob",
")",
"(",
"*",
"publish",
".",
"PageMembers",
",",
"error",
")",
"{",
"subdes",
":=",
"resMap",
"[",
"pr",
"... | // subjectMembers returns the relevant PageMembers if the described subject is a permanode with members. | [
"subjectMembers",
"returns",
"the",
"relevant",
"PageMembers",
"if",
"the",
"described",
"subject",
"is",
"a",
"permanode",
"with",
"members",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L1102-L1166 |
31,514 | perkeep/perkeep | app/publisher/main.go | serveZip | func (pr *publishRequest) serveZip() {
filename := ""
if len(pr.subres) > len("/=z/") {
filename = pr.subres[4:]
}
zh := &zipHandler{
fetcher: pr.ph.cl,
cl: pr.ph.cl,
root: pr.subject,
filename: filename,
}
zh.ServeHTTP(pr.rw, pr.req)
} | go | func (pr *publishRequest) serveZip() {
filename := ""
if len(pr.subres) > len("/=z/") {
filename = pr.subres[4:]
}
zh := &zipHandler{
fetcher: pr.ph.cl,
cl: pr.ph.cl,
root: pr.subject,
filename: filename,
}
zh.ServeHTTP(pr.rw, pr.req)
} | [
"func",
"(",
"pr",
"*",
"publishRequest",
")",
"serveZip",
"(",
")",
"{",
"filename",
":=",
"\"",
"\"",
"\n",
"if",
"len",
"(",
"pr",
".",
"subres",
")",
">",
"len",
"(",
"\"",
"\"",
")",
"{",
"filename",
"=",
"pr",
".",
"subres",
"[",
"4",
":"... | // serveZip streams a zip archive of all the files "under"
// pr.subject. That is, all the files pointed by file permanodes,
// which are directly members of pr.subject or recursively down
// directory permanodes and permanodes members. | [
"serveZip",
"streams",
"a",
"zip",
"archive",
"of",
"all",
"the",
"files",
"under",
"pr",
".",
"subject",
".",
"That",
"is",
"all",
"the",
"files",
"pointed",
"by",
"file",
"permanodes",
"which",
"are",
"directly",
"members",
"of",
"pr",
".",
"subject",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L1244-L1256 |
31,515 | perkeep/perkeep | pkg/blobserver/blobpacked/subfetch.go | SubFetch | func (s *storage) SubFetch(ctx context.Context, ref blob.Ref, offset, length int64) (io.ReadCloser, error) {
// TODO: pass ctx to more calls within this method.
m, err := s.getMetaRow(ref)
if err != nil {
return nil, err
}
if m.isPacked() {
length, err = capOffsetLength(m.size, offset, length)
if err != nil ... | go | func (s *storage) SubFetch(ctx context.Context, ref blob.Ref, offset, length int64) (io.ReadCloser, error) {
// TODO: pass ctx to more calls within this method.
m, err := s.getMetaRow(ref)
if err != nil {
return nil, err
}
if m.isPacked() {
length, err = capOffsetLength(m.size, offset, length)
if err != nil ... | [
"func",
"(",
"s",
"*",
"storage",
")",
"SubFetch",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"blob",
".",
"Ref",
",",
"offset",
",",
"length",
"int64",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"// TODO: pass ctx to more calls w... | // SubFetch returns part of a blob.
// The caller must close the returned io.ReadCloser.
// The Reader may return fewer than 'length' bytes. Callers should
// check. The returned error should be os.ErrNotExist if the blob
// doesn't exist. | [
"SubFetch",
"returns",
"part",
"of",
"a",
"blob",
".",
"The",
"caller",
"must",
"close",
"the",
"returned",
"io",
".",
"ReadCloser",
".",
"The",
"Reader",
"may",
"return",
"fewer",
"than",
"length",
"bytes",
".",
"Callers",
"should",
"check",
".",
"The",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobpacked/subfetch.go#L35-L74 |
31,516 | perkeep/perkeep | pkg/deploy/gce/handler.go | NewDeployHandlerFromConfig | func NewDeployHandlerFromConfig(host, prefix string, cfg *Config) (*DeployHandler, error) {
if cfg == nil {
panic("NewDeployHandlerFromConfig: nil config")
}
if cfg.ClientID == "" {
return nil, errors.New("oauth2 clientID required in config")
}
if cfg.ClientSecret == "" {
return nil, errors.New("oauth2 clien... | go | func NewDeployHandlerFromConfig(host, prefix string, cfg *Config) (*DeployHandler, error) {
if cfg == nil {
panic("NewDeployHandlerFromConfig: nil config")
}
if cfg.ClientID == "" {
return nil, errors.New("oauth2 clientID required in config")
}
if cfg.ClientSecret == "" {
return nil, errors.New("oauth2 clien... | [
"func",
"NewDeployHandlerFromConfig",
"(",
"host",
",",
"prefix",
"string",
",",
"cfg",
"*",
"Config",
")",
"(",
"*",
"DeployHandler",
",",
"error",
")",
"{",
"if",
"cfg",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"cfg",... | // NewDeployHandlerFromConfig initializes a DeployHandler from cfg.
// Host and prefix have the same meaning as for NewDeployHandler. cfg should not be nil. | [
"NewDeployHandlerFromConfig",
"initializes",
"a",
"DeployHandler",
"from",
"cfg",
".",
"Host",
"and",
"prefix",
"have",
"the",
"same",
"meaning",
"as",
"for",
"NewDeployHandler",
".",
"cfg",
"should",
"not",
"be",
"nil",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L128-L144 |
31,517 | perkeep/perkeep | pkg/deploy/gce/handler.go | serveRoot | func (h *DeployHandler) serveRoot(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
h.serveSetup(w, r)
return
}
_, err := r.Cookie("user")
if err != nil {
http.SetCookie(w, newCookie())
}
camliRev := h.camliRev()
if r.FormValue("WIP") == "1" {
camliRev = "WORKINPROGRESS"
}
h.tplMu.RLoc... | go | func (h *DeployHandler) serveRoot(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
h.serveSetup(w, r)
return
}
_, err := r.Cookie("user")
if err != nil {
http.SetCookie(w, newCookie())
}
camliRev := h.camliRev()
if r.FormValue("WIP") == "1" {
camliRev = "WORKINPROGRESS"
}
h.tplMu.RLoc... | [
"func",
"(",
"h",
"*",
"DeployHandler",
")",
"serveRoot",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Method",
"==",
"\"",
"\"",
"{",
"h",
".",
"serveSetup",
"(",
"w",
",",
"r",
")",
... | // if there's project as a query parameter, it means we've just created a
// project for them and we're redirecting them to the form, but with the projectID
// field pre-filled for them this time. | [
"if",
"there",
"s",
"project",
"as",
"a",
"query",
"parameter",
"it",
"means",
"we",
"ve",
"just",
"created",
"a",
"project",
"for",
"them",
"and",
"we",
"re",
"redirecting",
"them",
"to",
"the",
"form",
"but",
"with",
"the",
"projectID",
"field",
"pre",... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L351-L377 |
31,518 | perkeep/perkeep | pkg/deploy/gce/handler.go | serveOldInstance | func (h *DeployHandler) serveOldInstance(w http.ResponseWriter, br blob.Ref, depl *Deployer) (found bool) {
inst, err := depl.Get()
if err != nil {
// TODO(mpl,bradfitz): log or do something more
// drastic if the error is something other than
// instance not found.
return false
}
h.logger.Printf("Reusing e... | go | func (h *DeployHandler) serveOldInstance(w http.ResponseWriter, br blob.Ref, depl *Deployer) (found bool) {
inst, err := depl.Get()
if err != nil {
// TODO(mpl,bradfitz): log or do something more
// drastic if the error is something other than
// instance not found.
return false
}
h.logger.Printf("Reusing e... | [
"func",
"(",
"h",
"*",
"DeployHandler",
")",
"serveOldInstance",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"br",
"blob",
".",
"Ref",
",",
"depl",
"*",
"Deployer",
")",
"(",
"found",
"bool",
")",
"{",
"inst",
",",
"err",
":=",
"depl",
".",
"Get",
... | // serveOldInstance looks on GCE for an instance such as defined in depl.Conf, and if
// found, serves the appropriate page depending on whether the instance is usable. It does
// not serve anything if the instance is not found. | [
"serveOldInstance",
"looks",
"on",
"GCE",
"for",
"an",
"instance",
"such",
"as",
"defined",
"in",
"depl",
".",
"Conf",
"and",
"if",
"found",
"serves",
"the",
"appropriate",
"page",
"depending",
"on",
"whether",
"the",
"instance",
"is",
"usable",
".",
"It",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L564-L585 |
31,519 | perkeep/perkeep | pkg/deploy/gce/handler.go | serveInstanceState | func (h *DeployHandler) serveInstanceState(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
if r.Method != "GET" {
h.serveError(w, r, fmt.Errorf("Wrong method: %v", r.Method))
return
}
br := r.URL.Query().Get("instancekey")
stateValue, err := h.instState.Get(br)
if err != nil {
http.Error(w, "un... | go | func (h *DeployHandler) serveInstanceState(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
if r.Method != "GET" {
h.serveError(w, r, fmt.Errorf("Wrong method: %v", r.Method))
return
}
br := r.URL.Query().Get("instancekey")
stateValue, err := h.instState.Get(br)
if err != nil {
http.Error(w, "un... | [
"func",
"(",
"h",
"*",
"DeployHandler",
")",
"serveInstanceState",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"ctx",
":=",
"r",
".",
"Context",
"(",
")",
"\n",
"if",
"r",
".",
"Method",
"!=",
"\"",
"\"... | // serveInstanceState serves the state of the requested Google Cloud Engine VM creation
// process. If the operation was successful, it serves a success page. If it failed, it
// serves an error page. If it isn't finished yet, it replies with "running". | [
"serveInstanceState",
"serves",
"the",
"state",
"of",
"the",
"requested",
"Google",
"Cloud",
"Engine",
"VM",
"creation",
"process",
".",
"If",
"the",
"operation",
"was",
"successful",
"it",
"serves",
"a",
"success",
"page",
".",
"If",
"it",
"failed",
"it",
"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L612-L661 |
31,520 | perkeep/perkeep | pkg/deploy/gce/handler.go | serveProgress | func (h *DeployHandler) serveProgress(w http.ResponseWriter, instanceKey blob.Ref) {
h.tplMu.RLock()
defer h.tplMu.RUnlock()
if err := h.tpl.ExecuteTemplate(w, "withform", &TemplateData{
Prefix: h.prefix,
InstanceKey: instanceKey.String(),
PiggyGIF: h.piggyGIF,
}); err != nil {
h.logger.Printf("Coul... | go | func (h *DeployHandler) serveProgress(w http.ResponseWriter, instanceKey blob.Ref) {
h.tplMu.RLock()
defer h.tplMu.RUnlock()
if err := h.tpl.ExecuteTemplate(w, "withform", &TemplateData{
Prefix: h.prefix,
InstanceKey: instanceKey.String(),
PiggyGIF: h.piggyGIF,
}); err != nil {
h.logger.Printf("Coul... | [
"func",
"(",
"h",
"*",
"DeployHandler",
")",
"serveProgress",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"instanceKey",
"blob",
".",
"Ref",
")",
"{",
"h",
".",
"tplMu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"tplMu",
".",
"RUnlock",
"(",... | // serveProgress serves a page with some javascript code that regularly queries
// the server about the progress of the requested Google Cloud Engine VM creation.
// The server replies through serveInstanceState. | [
"serveProgress",
"serves",
"a",
"page",
"with",
"some",
"javascript",
"code",
"that",
"regularly",
"queries",
"the",
"server",
"about",
"the",
"progress",
"of",
"the",
"requested",
"Google",
"Cloud",
"Engine",
"VM",
"creation",
".",
"The",
"server",
"replies",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L666-L676 |
31,521 | perkeep/perkeep | pkg/deploy/gce/handler.go | randomZone | func (h *DeployHandler) randomZone(region string) string {
h.zonesMu.RLock()
defer h.zonesMu.RUnlock()
zones, ok := h.zones[region]
if !ok {
return fallbackZone
}
return region + zones[rand.Intn(len(zones))]
} | go | func (h *DeployHandler) randomZone(region string) string {
h.zonesMu.RLock()
defer h.zonesMu.RUnlock()
zones, ok := h.zones[region]
if !ok {
return fallbackZone
}
return region + zones[rand.Intn(len(zones))]
} | [
"func",
"(",
"h",
"*",
"DeployHandler",
")",
"randomZone",
"(",
"region",
"string",
")",
"string",
"{",
"h",
".",
"zonesMu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"zonesMu",
".",
"RUnlock",
"(",
")",
"\n",
"zones",
",",
"ok",
":=",
"h",
... | // randomZone picks one of the zone suffixes for region and returns it
// appended to region, as a fully-qualified zone name.
// If the given region is invalid, the default Zone is returned instead. | [
"randomZone",
"picks",
"one",
"of",
"the",
"zone",
"suffixes",
"for",
"region",
"and",
"returns",
"it",
"appended",
"to",
"region",
"as",
"a",
"fully",
"-",
"qualified",
"zone",
"name",
".",
"If",
"the",
"given",
"region",
"is",
"invalid",
"the",
"default"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L770-L778 |
31,522 | perkeep/perkeep | pkg/deploy/gce/handler.go | fromState | func fromState(r *http.Request) (br blob.Ref, xsrfToken string, err error) {
params := strings.Split(r.FormValue("state"), ":")
if len(params) != 2 {
return br, "", fmt.Errorf("Invalid format for state parameter: %q, wanted blobRef:xsrfToken", r.FormValue("state"))
}
br, ok := blob.Parse(params[0])
if !ok {
re... | go | func fromState(r *http.Request) (br blob.Ref, xsrfToken string, err error) {
params := strings.Split(r.FormValue("state"), ":")
if len(params) != 2 {
return br, "", fmt.Errorf("Invalid format for state parameter: %q, wanted blobRef:xsrfToken", r.FormValue("state"))
}
br, ok := blob.Parse(params[0])
if !ok {
re... | [
"func",
"fromState",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"br",
"blob",
".",
"Ref",
",",
"xsrfToken",
"string",
",",
"err",
"error",
")",
"{",
"params",
":=",
"strings",
".",
"Split",
"(",
"r",
".",
"FormValue",
"(",
"\"",
"\"",
")",
... | // fromState parses the oauth state parameter from r to extract the blobRef of the
// instance configuration and the xsrftoken that were stored during serveSetup. | [
"fromState",
"parses",
"the",
"oauth",
"state",
"parameter",
"from",
"r",
"to",
"extract",
"the",
"blobRef",
"of",
"the",
"instance",
"configuration",
"and",
"the",
"xsrftoken",
"that",
"were",
"stored",
"during",
"serveSetup",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L799-L813 |
31,523 | perkeep/perkeep | pkg/deploy/gce/handler.go | dataStores | func dataStores() (blobserver.Storage, sorted.KeyValue, error) {
dataDir := os.Getenv("CAMLI_GCE_DATA")
if dataDir == "" {
var err error
dataDir, err = ioutil.TempDir("", "camli-gcedeployer-data")
if err != nil {
return nil, nil, err
}
log.Printf("data dir not provided as env var CAMLI_GCE_DATA, so defau... | go | func dataStores() (blobserver.Storage, sorted.KeyValue, error) {
dataDir := os.Getenv("CAMLI_GCE_DATA")
if dataDir == "" {
var err error
dataDir, err = ioutil.TempDir("", "camli-gcedeployer-data")
if err != nil {
return nil, nil, err
}
log.Printf("data dir not provided as env var CAMLI_GCE_DATA, so defau... | [
"func",
"dataStores",
"(",
")",
"(",
"blobserver",
".",
"Storage",
",",
"sorted",
".",
"KeyValue",
",",
"error",
")",
"{",
"dataDir",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"dataDir",
"==",
"\"",
"\"",
"{",
"var",
"err",
"erro... | // dataStores returns the blobserver that stores the instances configurations, and the kv
// store for the instances states. | [
"dataStores",
"returns",
"the",
"blobserver",
"that",
"stores",
"the",
"instances",
"configurations",
"and",
"the",
"kv",
"store",
"for",
"the",
"instances",
"states",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L886-L909 |
31,524 | perkeep/perkeep | pkg/server/app/app.go | handleMasterQuery | func (a *Handler) handleMasterQuery(w http.ResponseWriter, r *http.Request) {
if !(a.auth.AllowedAccess(r)&auth.OpAll == auth.OpAll) {
auth.SendUnauthorized(w, r)
return
}
if r.Method != http.MethodPost {
http.Error(w, "not a POST", http.StatusMethodNotAllowed)
return
}
if a.sh == nil {
http.Error(w, "ap... | go | func (a *Handler) handleMasterQuery(w http.ResponseWriter, r *http.Request) {
if !(a.auth.AllowedAccess(r)&auth.OpAll == auth.OpAll) {
auth.SendUnauthorized(w, r)
return
}
if r.Method != http.MethodPost {
http.Error(w, "not a POST", http.StatusMethodNotAllowed)
return
}
if a.sh == nil {
http.Error(w, "ap... | [
"func",
"(",
"a",
"*",
"Handler",
")",
"handleMasterQuery",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"!",
"(",
"a",
".",
"auth",
".",
"AllowedAccess",
"(",
"r",
")",
"&",
"auth",
".",
"OpAll",
... | // handleMasterQuery allows an app to register the master query that defines the
// domain limiting all subsequent search queries. | [
"handleMasterQuery",
"allows",
"an",
"app",
"to",
"register",
"the",
"master",
"query",
"that",
"defines",
"the",
"domain",
"limiting",
"all",
"subsequent",
"search",
"queries",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L111-L158 |
31,525 | perkeep/perkeep | pkg/server/app/app.go | handleSearch | func (a *Handler) handleSearch(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
camhttputil.BadRequestError(w, camhttputil.InvalidMethodError{}.Error())
return
}
if a.sh == nil {
http.Error(w, "app proxy has no search handler", 500)
return
}
a.masterQueryMu.RLock()
if a.masterQue... | go | func (a *Handler) handleSearch(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
camhttputil.BadRequestError(w, camhttputil.InvalidMethodError{}.Error())
return
}
if a.sh == nil {
http.Error(w, "app proxy has no search handler", 500)
return
}
a.masterQueryMu.RLock()
if a.masterQue... | [
"func",
"(",
"a",
"*",
"Handler",
")",
"handleSearch",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Method",
"!=",
"http",
".",
"MethodPost",
"{",
"camhttputil",
".",
"BadRequestError",
"(",... | // handleSearch runs the requested search query against the search handler, and
// if the results are within the domain allowed by the master query, forwards them
// back to the client. | [
"handleSearch",
"runs",
"the",
"requested",
"search",
"query",
"against",
"the",
"search",
"handler",
"and",
"if",
"the",
"results",
"are",
"within",
"the",
"domain",
"allowed",
"by",
"the",
"master",
"query",
"forwards",
"them",
"back",
"to",
"the",
"client",... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L190-L230 |
31,526 | perkeep/perkeep | pkg/server/app/app.go | allowProxySearchResponse | func (a *Handler) allowProxySearchResponse(sr *search.SearchResult) bool {
a.masterQueryMu.RLock()
defer a.masterQueryMu.RUnlock()
for _, v := range sr.Blobs {
if _, ok := a.domainBlobs[v.Blob]; !ok {
return false
}
}
return true
} | go | func (a *Handler) allowProxySearchResponse(sr *search.SearchResult) bool {
a.masterQueryMu.RLock()
defer a.masterQueryMu.RUnlock()
for _, v := range sr.Blobs {
if _, ok := a.domainBlobs[v.Blob]; !ok {
return false
}
}
return true
} | [
"func",
"(",
"a",
"*",
"Handler",
")",
"allowProxySearchResponse",
"(",
"sr",
"*",
"search",
".",
"SearchResult",
")",
"bool",
"{",
"a",
".",
"masterQueryMu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"a",
".",
"masterQueryMu",
".",
"RUnlock",
"(",
")",
"... | // allowProxySearchResponse checks whether the blobs in sr are within the domain
// defined by the masterQuery, and hence if the client is allowed to get that
// response. | [
"allowProxySearchResponse",
"checks",
"whether",
"the",
"blobs",
"in",
"sr",
"are",
"within",
"the",
"domain",
"defined",
"by",
"the",
"masterQuery",
"and",
"hence",
"if",
"the",
"client",
"is",
"allowed",
"to",
"get",
"that",
"response",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L235-L244 |
31,527 | perkeep/perkeep | pkg/server/app/app.go | randListenFn | func randListenFn(listenAddr string, randPortFn func() (int, error)) (string, error) {
portIdx := strings.LastIndex(listenAddr, ":") + 1
if portIdx <= 0 || portIdx >= len(listenAddr) {
return "", errors.New("invalid listen addr, no port found")
}
port, err := randPortFn()
if err != nil {
return "", err
}
ret... | go | func randListenFn(listenAddr string, randPortFn func() (int, error)) (string, error) {
portIdx := strings.LastIndex(listenAddr, ":") + 1
if portIdx <= 0 || portIdx >= len(listenAddr) {
return "", errors.New("invalid listen addr, no port found")
}
port, err := randPortFn()
if err != nil {
return "", err
}
ret... | [
"func",
"randListenFn",
"(",
"listenAddr",
"string",
",",
"randPortFn",
"func",
"(",
")",
"(",
"int",
",",
"error",
")",
")",
"(",
"string",
",",
"error",
")",
"{",
"portIdx",
":=",
"strings",
".",
"LastIndex",
"(",
"listenAddr",
",",
"\"",
"\"",
")",
... | // randListenFn only exists to allow testing of randListen, by letting the caller
// replace randPort with a func that actually has a predictable result. | [
"randListenFn",
"only",
"exists",
"to",
"allow",
"testing",
"of",
"randListen",
"by",
"letting",
"the",
"caller",
"replace",
"randPort",
"with",
"a",
"func",
"that",
"actually",
"has",
"a",
"predictable",
"result",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L253-L263 |
31,528 | perkeep/perkeep | pkg/server/app/app.go | baseURL | func baseURL(serverBaseURL, listenAddr string) (string, error) {
backendURL, err := url.Parse(serverBaseURL)
if err != nil {
return "", fmt.Errorf("invalid baseURL %q: %v", serverBaseURL, err)
}
scheme := backendURL.Scheme
host := backendURL.Host
if netutil.HasPort(host) {
host = host[:strings.LastIndex(host,... | go | func baseURL(serverBaseURL, listenAddr string) (string, error) {
backendURL, err := url.Parse(serverBaseURL)
if err != nil {
return "", fmt.Errorf("invalid baseURL %q: %v", serverBaseURL, err)
}
scheme := backendURL.Scheme
host := backendURL.Host
if netutil.HasPort(host) {
host = host[:strings.LastIndex(host,... | [
"func",
"baseURL",
"(",
"serverBaseURL",
",",
"listenAddr",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"backendURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"serverBaseURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",... | // baseURL returns the concatenation of the scheme and host parts of
// serverBaseURL with the port of listenAddr. | [
"baseURL",
"returns",
"the",
"concatenation",
"of",
"the",
"scheme",
"and",
"host",
"parts",
"of",
"serverBaseURL",
"with",
"the",
"port",
"of",
"listenAddr",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L272-L287 |
31,529 | perkeep/perkeep | pkg/server/app/app.go | FromJSONConfig | func FromJSONConfig(config jsonconfig.Obj, prefix, serverBaseURL string) (HandlerConfig, error) {
hc := HandlerConfig{
Program: config.RequiredString("program"),
Prefix: config.OptionalString("prefix", prefix),
BackendURL: config.OptionalString("backendURL", ""),
Listen: config.OptionalS... | go | func FromJSONConfig(config jsonconfig.Obj, prefix, serverBaseURL string) (HandlerConfig, error) {
hc := HandlerConfig{
Program: config.RequiredString("program"),
Prefix: config.OptionalString("prefix", prefix),
BackendURL: config.OptionalString("backendURL", ""),
Listen: config.OptionalS... | [
"func",
"FromJSONConfig",
"(",
"config",
"jsonconfig",
".",
"Obj",
",",
"prefix",
",",
"serverBaseURL",
"string",
")",
"(",
"HandlerConfig",
",",
"error",
")",
"{",
"hc",
":=",
"HandlerConfig",
"{",
"Program",
":",
"config",
".",
"RequiredString",
"(",
"\"",... | // FromJSONConfig creates an HandlerConfig from the contents of config.
// prefix and serverBaseURL are used if not found in config. | [
"FromJSONConfig",
"creates",
"an",
"HandlerConfig",
"from",
"the",
"contents",
"of",
"config",
".",
"prefix",
"and",
"serverBaseURL",
"are",
"used",
"if",
"not",
"found",
"in",
"config",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L340-L355 |
31,530 | perkeep/perkeep | pkg/server/app/app.go | InitHandler | func (a *Handler) InitHandler(hl blobserver.FindHandlerByTyper) error {
apName := a.ProgramName()
searchPrefix, _, err := hl.FindHandlerByType("search")
if err != nil {
return fmt.Errorf("No search handler configured, which is necessary for the %v app handler", apName)
}
var sh *search.Handler
_, hi := hl.AllHa... | go | func (a *Handler) InitHandler(hl blobserver.FindHandlerByTyper) error {
apName := a.ProgramName()
searchPrefix, _, err := hl.FindHandlerByType("search")
if err != nil {
return fmt.Errorf("No search handler configured, which is necessary for the %v app handler", apName)
}
var sh *search.Handler
_, hi := hl.AllHa... | [
"func",
"(",
"a",
"*",
"Handler",
")",
"InitHandler",
"(",
"hl",
"blobserver",
".",
"FindHandlerByTyper",
")",
"error",
"{",
"apName",
":=",
"a",
".",
"ProgramName",
"(",
")",
"\n",
"searchPrefix",
",",
"_",
",",
"err",
":=",
"hl",
".",
"FindHandlerByTyp... | // InitHandler sets the app handler's search handler, if the app handler was configured
// to have one with HasSearch. | [
"InitHandler",
"sets",
"the",
"app",
"handler",
"s",
"search",
"handler",
"if",
"the",
"app",
"handler",
"was",
"configured",
"to",
"have",
"one",
"with",
"HasSearch",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L442-L457 |
31,531 | perkeep/perkeep | pkg/server/app/app.go | Quit | func (a *Handler) Quit() error {
err := a.process.Signal(os.Interrupt)
if err != nil {
return err
}
c := make(chan error)
go func() {
_, err := a.process.Wait()
c <- err
}()
select {
case err = <-c:
case <-time.After(5 * time.Second):
// TODO Do we want to SIGKILL here or just leave the app alone?
e... | go | func (a *Handler) Quit() error {
err := a.process.Signal(os.Interrupt)
if err != nil {
return err
}
c := make(chan error)
go func() {
_, err := a.process.Wait()
c <- err
}()
select {
case err = <-c:
case <-time.After(5 * time.Second):
// TODO Do we want to SIGKILL here or just leave the app alone?
e... | [
"func",
"(",
"a",
"*",
"Handler",
")",
"Quit",
"(",
")",
"error",
"{",
"err",
":=",
"a",
".",
"process",
".",
"Signal",
"(",
"os",
".",
"Interrupt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"c",
":=",
"make"... | // Quit sends the app's process a SIGINT, and waits up to 5 seconds for it
// to exit, returning an error if it doesn't. | [
"Quit",
"sends",
"the",
"app",
"s",
"process",
"a",
"SIGINT",
"and",
"waits",
"up",
"to",
"5",
"seconds",
"for",
"it",
"to",
"exit",
"returning",
"an",
"error",
"if",
"it",
"doesn",
"t",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L536-L554 |
31,532 | perkeep/perkeep | pkg/cacher/cacher.go | NewCachingFetcher | func NewCachingFetcher(cache blobserver.Cache, fetcher blob.Fetcher) *CachingFetcher {
return &CachingFetcher{c: cache, sf: fetcher}
} | go | func NewCachingFetcher(cache blobserver.Cache, fetcher blob.Fetcher) *CachingFetcher {
return &CachingFetcher{c: cache, sf: fetcher}
} | [
"func",
"NewCachingFetcher",
"(",
"cache",
"blobserver",
".",
"Cache",
",",
"fetcher",
"blob",
".",
"Fetcher",
")",
"*",
"CachingFetcher",
"{",
"return",
"&",
"CachingFetcher",
"{",
"c",
":",
"cache",
",",
"sf",
":",
"fetcher",
"}",
"\n",
"}"
] | // NewCachingFetcher returns a CachingFetcher that fetches from
// fetcher and writes to and serves from cache. | [
"NewCachingFetcher",
"returns",
"a",
"CachingFetcher",
"that",
"fetches",
"from",
"fetcher",
"and",
"writes",
"to",
"and",
"serves",
"from",
"cache",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/cacher/cacher.go#L38-L40 |
31,533 | perkeep/perkeep | pkg/cacher/cacher.go | SetCacheHitHook | func (cf *CachingFetcher) SetCacheHitHook(fn func(br blob.Ref, rc io.ReadCloser) (io.ReadCloser, error)) {
cf.cacheHitHook = fn
} | go | func (cf *CachingFetcher) SetCacheHitHook(fn func(br blob.Ref, rc io.ReadCloser) (io.ReadCloser, error)) {
cf.cacheHitHook = fn
} | [
"func",
"(",
"cf",
"*",
"CachingFetcher",
")",
"SetCacheHitHook",
"(",
"fn",
"func",
"(",
"br",
"blob",
".",
"Ref",
",",
"rc",
"io",
".",
"ReadCloser",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
")",
"{",
"cf",
".",
"cacheHitHook",
"=",
... | // SetCacheHitHook sets a function that will modify the return values from Fetch
// in the case of a cache hit.
// Its purpose is to add potential side-effects from calling the Fetcher that would
// have happened if we had had a cache miss. It is the responsibility of fn to
// return a ReadCloser equivalent to the stat... | [
"SetCacheHitHook",
"sets",
"a",
"function",
"that",
"will",
"modify",
"the",
"return",
"values",
"from",
"Fetch",
"in",
"the",
"case",
"of",
"a",
"cache",
"hit",
".",
"Its",
"purpose",
"is",
"to",
"add",
"potential",
"side",
"-",
"effects",
"from",
"callin... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/cacher/cacher.go#L60-L62 |
31,534 | perkeep/perkeep | pkg/fs/mut.go | maybeAddChild | func (n *mutDir) maybeAddChild(name string, permanode *search.DescribedPermanode,
child mutFileOrDir) {
if current, ok := n.children[name]; !ok ||
current.permanodeString() != child.permanodeString() {
child.xattr().load(permanode)
n.children[name] = child
}
} | go | func (n *mutDir) maybeAddChild(name string, permanode *search.DescribedPermanode,
child mutFileOrDir) {
if current, ok := n.children[name]; !ok ||
current.permanodeString() != child.permanodeString() {
child.xattr().load(permanode)
n.children[name] = child
}
} | [
"func",
"(",
"n",
"*",
"mutDir",
")",
"maybeAddChild",
"(",
"name",
"string",
",",
"permanode",
"*",
"search",
".",
"DescribedPermanode",
",",
"child",
"mutFileOrDir",
")",
"{",
"if",
"current",
",",
"ok",
":=",
"n",
".",
"children",
"[",
"name",
"]",
... | // maybeAddChild adds a child directory to this mutable directory
// unless it already has one with this name and permanode. | [
"maybeAddChild",
"adds",
"a",
"child",
"directory",
"to",
"this",
"mutable",
"directory",
"unless",
"it",
"already",
"has",
"one",
"with",
"this",
"name",
"and",
"permanode",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/mut.go#L233-L241 |
31,535 | perkeep/perkeep | pkg/fs/mut.go | Release | func (h *mutFileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) error {
h.tmp.Close()
os.Remove(h.tmp.Name())
h.tmp = nil
return nil
} | go | func (h *mutFileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) error {
h.tmp.Close()
os.Remove(h.tmp.Name())
h.tmp = nil
return nil
} | [
"func",
"(",
"h",
"*",
"mutFileHandle",
")",
"Release",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"ReleaseRequest",
")",
"error",
"{",
"h",
".",
"tmp",
".",
"Close",
"(",
")",
"\n",
"os",
".",
"Remove",
"(",
"h",
".",
"... | // Release is called when a file handle is no longer needed. This is
// called asynchronously after the last handle to a file is closed. | [
"Release",
"is",
"called",
"when",
"a",
"file",
"handle",
"is",
"no",
"longer",
"needed",
".",
"This",
"is",
"called",
"asynchronously",
"after",
"the",
"last",
"handle",
"to",
"a",
"file",
"is",
"closed",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/mut.go#L871-L877 |
31,536 | perkeep/perkeep | pkg/fs/time.go | parseCanonicalTime | func parseCanonicalTime(in string) (time.Time, error) {
if len(in) < 20 || in[len(in)-1] != 'Z' {
return time.Time{}, errUnparseableTimestamp
}
if !(in[4] == '-' && in[7] == '-' && in[10] == 'T' &&
in[13] == ':' && in[16] == ':' && (in[19] == '.' || in[19] == 'Z')) {
return time.Time{}, fmt.Errorf("positional... | go | func parseCanonicalTime(in string) (time.Time, error) {
if len(in) < 20 || in[len(in)-1] != 'Z' {
return time.Time{}, errUnparseableTimestamp
}
if !(in[4] == '-' && in[7] == '-' && in[10] == 'T' &&
in[13] == ':' && in[16] == ':' && (in[19] == '.' || in[19] == 'Z')) {
return time.Time{}, fmt.Errorf("positional... | [
"func",
"parseCanonicalTime",
"(",
"in",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"if",
"len",
"(",
"in",
")",
"<",
"20",
"||",
"in",
"[",
"len",
"(",
"in",
")",
"-",
"1",
"]",
"!=",
"'Z'",
"{",
"return",
"time",
".",
... | // Hand crafted this parser since it's a really common path. | [
"Hand",
"crafted",
"this",
"parser",
"since",
"it",
"s",
"a",
"really",
"common",
"path",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/time.go#L60-L122 |
31,537 | perkeep/perkeep | pkg/index/memindex.go | NewMemoryIndex | func NewMemoryIndex() *Index {
ix, err := New(sorted.NewMemoryKeyValue())
if err != nil {
// Nothing to fail in memory, so worth panicing about
// if we ever see something.
panic(err)
}
return ix
} | go | func NewMemoryIndex() *Index {
ix, err := New(sorted.NewMemoryKeyValue())
if err != nil {
// Nothing to fail in memory, so worth panicing about
// if we ever see something.
panic(err)
}
return ix
} | [
"func",
"NewMemoryIndex",
"(",
")",
"*",
"Index",
"{",
"ix",
",",
"err",
":=",
"New",
"(",
"sorted",
".",
"NewMemoryKeyValue",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Nothing to fail in memory, so worth panicing about",
"// if we ever see something... | // NewMemoryIndex returns an Index backed only by memory, for use in tests. | [
"NewMemoryIndex",
"returns",
"an",
"Index",
"backed",
"only",
"by",
"memory",
"for",
"use",
"in",
"tests",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/memindex.go#L31-L39 |
31,538 | perkeep/perkeep | app/scanningcabinet/scancab/pdf.go | pageCountPoppler | func pageCountPoppler(filename string) (cnt int, err error) {
cmd := exec.Command("pdfinfo", filename)
out, err := cmd.CombinedOutput()
if err != nil {
return cnt, fmt.Errorf("could not get page count with pdfinfo: %v, %v", err, string(out))
}
sc := bufio.NewScanner(bytes.NewReader(out))
for sc.Scan() {
l := ... | go | func pageCountPoppler(filename string) (cnt int, err error) {
cmd := exec.Command("pdfinfo", filename)
out, err := cmd.CombinedOutput()
if err != nil {
return cnt, fmt.Errorf("could not get page count with pdfinfo: %v, %v", err, string(out))
}
sc := bufio.NewScanner(bytes.NewReader(out))
for sc.Scan() {
l := ... | [
"func",
"pageCountPoppler",
"(",
"filename",
"string",
")",
"(",
"cnt",
"int",
",",
"err",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"filename",
")",
"\n",
"out",
",",
"err",
":=",
"cmd",
".",
"CombinedOutput",
"("... | // pageCountPoppler calls the tool pdfinfo from the Poppler project for
// filename and parses the output for the page count which is then returned. If
// any error occurs or the pages count information is not found, an error is
// returned. | [
"pageCountPoppler",
"calls",
"the",
"tool",
"pdfinfo",
"from",
"the",
"Poppler",
"project",
"for",
"filename",
"and",
"parses",
"the",
"output",
"for",
"the",
"page",
"count",
"which",
"is",
"then",
"returned",
".",
"If",
"any",
"error",
"occurs",
"or",
"the... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/scancab/pdf.go#L37-L55 |
31,539 | perkeep/perkeep | app/scanningcabinet/scancab/pdf.go | pageCountNative | func pageCountNative(filename string) (int, error) {
f, err := os.Open(filename)
if err != nil {
return 0, err
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return 0, err
}
p, err := pdf.NewReader(f, fi.Size())
if err != nil {
return 0, err
}
c := p.NumPage()
if c < 1 {
return 0, errors.New(... | go | func pageCountNative(filename string) (int, error) {
f, err := os.Open(filename)
if err != nil {
return 0, err
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return 0, err
}
p, err := pdf.NewReader(f, fi.Size())
if err != nil {
return 0, err
}
c := p.NumPage()
if c < 1 {
return 0, errors.New(... | [
"func",
"pageCountNative",
"(",
"filename",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"defer... | // pageCountNative uses a native Go library to extract and return the number of
// pages in the PDF document. It returns an error if the filename is not of a
// PDF file, or if it failed to decode the PDF. | [
"pageCountNative",
"uses",
"a",
"native",
"Go",
"library",
"to",
"extract",
"and",
"return",
"the",
"number",
"of",
"pages",
"in",
"the",
"PDF",
"document",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"filename",
"is",
"not",
"of",
"a",
"PDF",
"fil... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/scancab/pdf.go#L60-L79 |
31,540 | perkeep/perkeep | app/scanningcabinet/scancab/pdf.go | pageCount | func pageCount(filename string) (int, error) {
n, err := pageCountNative(filename)
if err != nil {
// fallback to using pdfinfo when internal count failed
n, err = pageCountPoppler(filename)
}
return n, err
} | go | func pageCount(filename string) (int, error) {
n, err := pageCountNative(filename)
if err != nil {
// fallback to using pdfinfo when internal count failed
n, err = pageCountPoppler(filename)
}
return n, err
} | [
"func",
"pageCount",
"(",
"filename",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"pageCountNative",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// fallback to using pdfinfo when internal count failed",
"n",
",",
... | // pageCount returns the number of pages in the given PDF file, or an error if
// it could not be determined. The function may trigger calls to external tools
// to achieve a valid count after native counting has been tried without
// success. | [
"pageCount",
"returns",
"the",
"number",
"of",
"pages",
"in",
"the",
"given",
"PDF",
"file",
"or",
"an",
"error",
"if",
"it",
"could",
"not",
"be",
"determined",
".",
"The",
"function",
"may",
"trigger",
"calls",
"to",
"external",
"tools",
"to",
"achieve",... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/scancab/pdf.go#L85-L92 |
31,541 | perkeep/perkeep | pkg/search/predicate.go | SearchHelp | func SearchHelp() string {
type help struct{ Name, Description string }
h := []help{}
for _, p := range keywords {
h = append(h, help{p.Name(), p.Description()})
}
b, err := json.MarshalIndent(h, "", " ")
if err != nil {
return "Error marshalling"
}
return string(b)
} | go | func SearchHelp() string {
type help struct{ Name, Description string }
h := []help{}
for _, p := range keywords {
h = append(h, help{p.Name(), p.Description()})
}
b, err := json.MarshalIndent(h, "", " ")
if err != nil {
return "Error marshalling"
}
return string(b)
} | [
"func",
"SearchHelp",
"(",
")",
"string",
"{",
"type",
"help",
"struct",
"{",
"Name",
",",
"Description",
"string",
"}",
"\n",
"h",
":=",
"[",
"]",
"help",
"{",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"keywords",
"{",
"h",
"=",
"append",
... | // SearchHelp returns JSON of an array of predicate names and descriptions. | [
"SearchHelp",
"returns",
"JSON",
"of",
"an",
"array",
"of",
"predicate",
"names",
"and",
"descriptions",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/predicate.go#L91-L102 |
31,542 | perkeep/perkeep | pkg/blobserver/receive.go | ReceiveString | func ReceiveString(ctx context.Context, dst BlobReceiver, s string) (blob.SizedRef, error) {
return Receive(ctx, dst, blob.RefFromString(s), strings.NewReader(s))
} | go | func ReceiveString(ctx context.Context, dst BlobReceiver, s string) (blob.SizedRef, error) {
return Receive(ctx, dst, blob.RefFromString(s), strings.NewReader(s))
} | [
"func",
"ReceiveString",
"(",
"ctx",
"context",
".",
"Context",
",",
"dst",
"BlobReceiver",
",",
"s",
"string",
")",
"(",
"blob",
".",
"SizedRef",
",",
"error",
")",
"{",
"return",
"Receive",
"(",
"ctx",
",",
"dst",
",",
"blob",
".",
"RefFromString",
"... | // ReceiveString uploads the blob given by the string s to dst
// and returns its blobref and size. | [
"ReceiveString",
"uploads",
"the",
"blob",
"given",
"by",
"the",
"string",
"s",
"to",
"dst",
"and",
"returns",
"its",
"blobref",
"and",
"size",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/receive.go#L35-L37 |
31,543 | perkeep/perkeep | pkg/blobserver/receive.go | Receive | func Receive(ctx context.Context, dst BlobReceiver, br blob.Ref, src io.Reader) (blob.SizedRef, error) {
return receive(ctx, dst, br, src, true)
} | go | func Receive(ctx context.Context, dst BlobReceiver, br blob.Ref, src io.Reader) (blob.SizedRef, error) {
return receive(ctx, dst, br, src, true)
} | [
"func",
"Receive",
"(",
"ctx",
"context",
".",
"Context",
",",
"dst",
"BlobReceiver",
",",
"br",
"blob",
".",
"Ref",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"blob",
".",
"SizedRef",
",",
"error",
")",
"{",
"return",
"receive",
"(",
"ctx",
",",
"... | // Receive wraps calling a BlobReceiver's ReceiveBlob method,
// additionally providing verification of the src digest, and also
// notifying the blob hub on success.
// The error will be ErrCorruptBlob if the blobref didn't match. | [
"Receive",
"wraps",
"calling",
"a",
"BlobReceiver",
"s",
"ReceiveBlob",
"method",
"additionally",
"providing",
"verification",
"of",
"the",
"src",
"digest",
"and",
"also",
"notifying",
"the",
"blob",
"hub",
"on",
"success",
".",
"The",
"error",
"will",
"be",
"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/receive.go#L43-L45 |
31,544 | perkeep/perkeep | pkg/importer/importer.go | Register | func Register(name string, im Importer) {
if _, dup := importers[name]; dup {
panic("Dup registration of importer " + name)
}
if _, dup := reservedImporterKey[name]; dup {
panic("Dup registration of importer " + name)
}
if pt := im.Properties().PermanodeImporterType; pt != "" {
if _, dup := importers[pt]; du... | go | func Register(name string, im Importer) {
if _, dup := importers[name]; dup {
panic("Dup registration of importer " + name)
}
if _, dup := reservedImporterKey[name]; dup {
panic("Dup registration of importer " + name)
}
if pt := im.Properties().PermanodeImporterType; pt != "" {
if _, dup := importers[pt]; du... | [
"func",
"Register",
"(",
"name",
"string",
",",
"im",
"Importer",
")",
"{",
"if",
"_",
",",
"dup",
":=",
"importers",
"[",
"name",
"]",
";",
"dup",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"name",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"dup",
":=",
... | // Register registers a site-specific importer. It should only be called from init,
// and not from concurrent goroutines. | [
"Register",
"registers",
"a",
"site",
"-",
"specific",
"importer",
".",
"It",
"should",
"only",
"be",
"called",
"from",
"init",
"and",
"not",
"from",
"concurrent",
"goroutines",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L171-L188 |
31,545 | perkeep/perkeep | pkg/importer/importer.go | Context | func (rc *RunContext) Context() context.Context {
if rc.ctx != nil {
return rc.ctx
}
return context.Background()
} | go | func (rc *RunContext) Context() context.Context {
if rc.ctx != nil {
return rc.ctx
}
return context.Background()
} | [
"func",
"(",
"rc",
"*",
"RunContext",
")",
"Context",
"(",
")",
"context",
".",
"Context",
"{",
"if",
"rc",
".",
"ctx",
"!=",
"nil",
"{",
"return",
"rc",
".",
"ctx",
"\n",
"}",
"\n",
"return",
"context",
".",
"Background",
"(",
")",
"\n",
"}"
] | // Context returns the run's context. It is always non-nil. | [
"Context",
"returns",
"the",
"run",
"s",
"context",
".",
"It",
"is",
"always",
"non",
"-",
"nil",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L345-L350 |
31,546 | perkeep/perkeep | pkg/importer/importer.go | CreateAccount | func CreateAccount(h *Host, impl string) (*RunContext, error) {
imp, ok := h.imp[impl]
if !ok {
return nil, fmt.Errorf("host does not have a %v importer", impl)
}
ia, err := imp.newAccount()
if err != nil {
return nil, fmt.Errorf("could not create new account for importer %v: %v", impl, err)
}
rc := &RunCont... | go | func CreateAccount(h *Host, impl string) (*RunContext, error) {
imp, ok := h.imp[impl]
if !ok {
return nil, fmt.Errorf("host does not have a %v importer", impl)
}
ia, err := imp.newAccount()
if err != nil {
return nil, fmt.Errorf("could not create new account for importer %v: %v", impl, err)
}
rc := &RunCont... | [
"func",
"CreateAccount",
"(",
"h",
"*",
"Host",
",",
"impl",
"string",
")",
"(",
"*",
"RunContext",
",",
"error",
")",
"{",
"imp",
",",
"ok",
":=",
"h",
".",
"imp",
"[",
"impl",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",... | // CreateAccount creates a new importer account for the Host h, and the importer
// implementation named impl. It returns a RunContext setup with that account. | [
"CreateAccount",
"creates",
"a",
"new",
"importer",
"account",
"for",
"the",
"Host",
"h",
"and",
"the",
"importer",
"implementation",
"named",
"impl",
".",
"It",
"returns",
"a",
"RunContext",
"setup",
"with",
"that",
"account",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L354-L370 |
31,547 | perkeep/perkeep | pkg/importer/importer.go | AccountsStatus | func (h *Host) AccountsStatus() (interface{}, []camtypes.StatusError) {
h.didInit.Wait()
var s []accountStatus
var errs []camtypes.StatusError
for _, impName := range h.importers {
imp := h.imp[impName]
accts, _ := imp.Accounts()
for _, ia := range accts {
as := accountStatus{
Type: impName,
Href: ... | go | func (h *Host) AccountsStatus() (interface{}, []camtypes.StatusError) {
h.didInit.Wait()
var s []accountStatus
var errs []camtypes.StatusError
for _, impName := range h.importers {
imp := h.imp[impName]
accts, _ := imp.Accounts()
for _, ia := range accts {
as := accountStatus{
Type: impName,
Href: ... | [
"func",
"(",
"h",
"*",
"Host",
")",
"AccountsStatus",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"[",
"]",
"camtypes",
".",
"StatusError",
")",
"{",
"h",
".",
"didInit",
".",
"Wait",
"(",
")",
"\n",
"var",
"s",
"[",
"]",
"accountStatus",
"\n",
"v... | // AccountsStatus returns the currently configured accounts and their status for
// inclusion in the status.json document, as rendered by the web UI. | [
"AccountsStatus",
"returns",
"the",
"currently",
"configured",
"accounts",
"and",
"their",
"status",
"for",
"inclusion",
"in",
"the",
"status",
".",
"json",
"document",
"as",
"rendered",
"by",
"the",
"web",
"UI",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L439-L471 |
31,548 | perkeep/perkeep | pkg/importer/importer.go | RunImporterAccount | func (h *Host) RunImporterAccount(importerType string, accountNode blob.Ref) error {
h.didInit.Wait()
imp, ok := h.imp[importerType]
if !ok {
return fmt.Errorf("no %q importer for this account", importerType)
}
accounts, err := imp.Accounts()
if err != nil {
return err
}
for _, ia := range accounts {
if i... | go | func (h *Host) RunImporterAccount(importerType string, accountNode blob.Ref) error {
h.didInit.Wait()
imp, ok := h.imp[importerType]
if !ok {
return fmt.Errorf("no %q importer for this account", importerType)
}
accounts, err := imp.Accounts()
if err != nil {
return err
}
for _, ia := range accounts {
if i... | [
"func",
"(",
"h",
"*",
"Host",
")",
"RunImporterAccount",
"(",
"importerType",
"string",
",",
"accountNode",
"blob",
".",
"Ref",
")",
"error",
"{",
"h",
".",
"didInit",
".",
"Wait",
"(",
")",
"\n",
"imp",
",",
"ok",
":=",
"h",
".",
"imp",
"[",
"imp... | // RunImporterAccount runs the importerType importer on the account described in
// accountNode. | [
"RunImporterAccount",
"runs",
"the",
"importerType",
"importer",
"on",
"the",
"account",
"described",
"in",
"accountNode",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L475-L492 |
31,549 | perkeep/perkeep | pkg/importer/importer.go | HTTPClient | func (h *Host) HTTPClient() *http.Client {
if h.client == nil {
return http.DefaultClient
}
return h.client
} | go | func (h *Host) HTTPClient() *http.Client {
if h.client == nil {
return http.DefaultClient
}
return h.client
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"HTTPClient",
"(",
")",
"*",
"http",
".",
"Client",
"{",
"if",
"h",
".",
"client",
"==",
"nil",
"{",
"return",
"http",
".",
"DefaultClient",
"\n",
"}",
"\n",
"return",
"h",
".",
"client",
"\n",
"}"
] | // HTTPClient returns the HTTP client to use. | [
"HTTPClient",
"returns",
"the",
"HTTP",
"client",
"to",
"use",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1333-L1338 |
31,550 | perkeep/perkeep | pkg/importer/importer.go | HTTPTransport | func (h *Host) HTTPTransport() http.RoundTripper {
if h.transport == nil {
return http.DefaultTransport
}
return h.transport
} | go | func (h *Host) HTTPTransport() http.RoundTripper {
if h.transport == nil {
return http.DefaultTransport
}
return h.transport
} | [
"func",
"(",
"h",
"*",
"Host",
")",
"HTTPTransport",
"(",
")",
"http",
".",
"RoundTripper",
"{",
"if",
"h",
".",
"transport",
"==",
"nil",
"{",
"return",
"http",
".",
"DefaultTransport",
"\n",
"}",
"\n",
"return",
"h",
".",
"transport",
"\n",
"}"
] | // HTTPTransport returns the HTTP transport to use. | [
"HTTPTransport",
"returns",
"the",
"HTTP",
"transport",
"to",
"use",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1341-L1346 |
31,551 | perkeep/perkeep | pkg/importer/importer.go | NewObject | func (h *Host) NewObject() (*Object, error) {
ctx := context.TODO() // TODO: move the NewObject method to some "ImportRun" type with a context field?
pn, err := h.upload(ctx, schema.NewUnsignedPermanode())
if err != nil {
return nil, err
}
// No need to do a describe query against it: we know it's
// empty (has... | go | func (h *Host) NewObject() (*Object, error) {
ctx := context.TODO() // TODO: move the NewObject method to some "ImportRun" type with a context field?
pn, err := h.upload(ctx, schema.NewUnsignedPermanode())
if err != nil {
return nil, err
}
// No need to do a describe query against it: we know it's
// empty (has... | [
"func",
"(",
"h",
"*",
"Host",
")",
"NewObject",
"(",
")",
"(",
"*",
"Object",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"// TODO: move the NewObject method to some \"ImportRun\" type with a context field?",
"\n",
"pn",
",",
"err",
... | // NewObject creates a new permanode and returns its Object wrapper. | [
"NewObject",
"creates",
"a",
"new",
"permanode",
"and",
"returns",
"its",
"Object",
"wrapper",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1366-L1375 |
31,552 | perkeep/perkeep | pkg/importer/importer.go | Attr | func (o *Object) Attr(attr string) string {
o.mu.RLock()
defer o.mu.RUnlock()
if v := o.attr[attr]; len(v) > 0 {
return v[0]
}
return ""
} | go | func (o *Object) Attr(attr string) string {
o.mu.RLock()
defer o.mu.RUnlock()
if v := o.attr[attr]; len(v) > 0 {
return v[0]
}
return ""
} | [
"func",
"(",
"o",
"*",
"Object",
")",
"Attr",
"(",
"attr",
"string",
")",
"string",
"{",
"o",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"o",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"v",
":=",
"o",
".",
"attr",
"[",
"attr",
... | // Attr returns the object's attribute value for the provided attr,
// or the empty string if unset. To distinguish between unset,
// an empty string, or multiple attribute values, use Attrs. | [
"Attr",
"returns",
"the",
"object",
"s",
"attribute",
"value",
"for",
"the",
"provided",
"attr",
"or",
"the",
"empty",
"string",
"if",
"unset",
".",
"To",
"distinguish",
"between",
"unset",
"an",
"empty",
"string",
"or",
"multiple",
"attribute",
"values",
"u... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1396-L1403 |
31,553 | perkeep/perkeep | pkg/importer/importer.go | Attrs | func (o *Object) Attrs(attr string) []string {
o.mu.RLock()
defer o.mu.RUnlock()
return o.attr[attr]
} | go | func (o *Object) Attrs(attr string) []string {
o.mu.RLock()
defer o.mu.RUnlock()
return o.attr[attr]
} | [
"func",
"(",
"o",
"*",
"Object",
")",
"Attrs",
"(",
"attr",
"string",
")",
"[",
"]",
"string",
"{",
"o",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"o",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"o",
".",
"attr",
"[",
"attr"... | // Attrs returns the attribute values for the provided attr. | [
"Attrs",
"returns",
"the",
"attribute",
"values",
"for",
"the",
"provided",
"attr",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1406-L1410 |
31,554 | perkeep/perkeep | pkg/importer/importer.go | ForeachAttr | func (o *Object) ForeachAttr(fn func(key, value string)) {
o.mu.RLock()
defer o.mu.RUnlock()
for k, vv := range o.attr {
for _, v := range vv {
fn(k, v)
}
}
} | go | func (o *Object) ForeachAttr(fn func(key, value string)) {
o.mu.RLock()
defer o.mu.RUnlock()
for k, vv := range o.attr {
for _, v := range vv {
fn(k, v)
}
}
} | [
"func",
"(",
"o",
"*",
"Object",
")",
"ForeachAttr",
"(",
"fn",
"func",
"(",
"key",
",",
"value",
"string",
")",
")",
"{",
"o",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"o",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"k",
",",... | // ForeachAttr runs fn for each of the object's attributes & values.
// There might be multiple values for the same attribute.
// The internal lock is held while running, so no mutations should be
// made or it will deadlock. | [
"ForeachAttr",
"runs",
"fn",
"for",
"each",
"of",
"the",
"object",
"s",
"attributes",
"&",
"values",
".",
"There",
"might",
"be",
"multiple",
"values",
"for",
"the",
"same",
"attribute",
".",
"The",
"internal",
"lock",
"is",
"held",
"while",
"running",
"so... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1416-L1424 |
31,555 | perkeep/perkeep | pkg/importer/importer.go | DelAttr | func (o *Object) DelAttr(key, value string) error {
ctx := context.TODO()
o.mu.Lock()
defer o.mu.Unlock()
_, err := o.h.upload(ctx, schema.NewDelAttributeClaim(o.pn, key, value))
if err != nil {
return err
}
if o.attr == nil {
o.attr = make(map[string][]string)
return nil
}
if value == "" {
delete(o.at... | go | func (o *Object) DelAttr(key, value string) error {
ctx := context.TODO()
o.mu.Lock()
defer o.mu.Unlock()
_, err := o.h.upload(ctx, schema.NewDelAttributeClaim(o.pn, key, value))
if err != nil {
return err
}
if o.attr == nil {
o.attr = make(map[string][]string)
return nil
}
if value == "" {
delete(o.at... | [
"func",
"(",
"o",
"*",
"Object",
")",
"DelAttr",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n",
"o",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"o",
".",
"mu",
".",
"Unlock",
... | // DelAttr removes value from the values set for the attribute attr of
// permaNode. If value is empty then all the values for attribute are cleared. | [
"DelAttr",
"removes",
"value",
"from",
"the",
"values",
"set",
"for",
"the",
"attribute",
"attr",
"of",
"permaNode",
".",
"If",
"value",
"is",
"empty",
"then",
"all",
"the",
"values",
"for",
"attribute",
"are",
"cleared",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1428-L1452 |
31,556 | perkeep/perkeep | pkg/importer/importer.go | SetAttr | func (o *Object) SetAttr(key, value string) error {
ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field?
if o.Attr(key) == value {
return nil
}
_, err := o.h.upload(ctx, schema.NewSetAttributeClaim(o.pn, key, value))
if err != nil {... | go | func (o *Object) SetAttr(key, value string) error {
ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field?
if o.Attr(key) == value {
return nil
}
_, err := o.h.upload(ctx, schema.NewSetAttributeClaim(o.pn, key, value))
if err != nil {... | [
"func",
"(",
"o",
"*",
"Object",
")",
"SetAttr",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"// TODO: make it possible to get a context via Object; either new context field, or via some \"ImportRun\" field?",
"\... | // SetAttr sets the attribute key to value. | [
"SetAttr",
"sets",
"the",
"attribute",
"key",
"to",
"value",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1455-L1471 |
31,557 | perkeep/perkeep | pkg/importer/importer.go | SetAttrValues | func (o *Object) SetAttrValues(key string, attrs []string) error {
ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field?
exists := asSet(o.Attrs(key))
actual := asSet(attrs)
o.mu.Lock()
defer o.mu.Unlock()
// add new values
for v :=... | go | func (o *Object) SetAttrValues(key string, attrs []string) error {
ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field?
exists := asSet(o.Attrs(key))
actual := asSet(attrs)
o.mu.Lock()
defer o.mu.Unlock()
// add new values
for v :=... | [
"func",
"(",
"o",
"*",
"Object",
")",
"SetAttrValues",
"(",
"key",
"string",
",",
"attrs",
"[",
"]",
"string",
")",
"error",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"// TODO: make it possible to get a context via Object; either new context field, or via ... | // SetAttrValues sets multi-valued attribute. | [
"SetAttrValues",
"sets",
"multi",
"-",
"valued",
"attribute",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1502-L1532 |
31,558 | perkeep/perkeep | pkg/importer/importer.go | ObjectFromRef | func (h *Host) ObjectFromRef(permanodeRef blob.Ref) (*Object, error) {
ctx := context.TODO()
res, err := h.search.Describe(ctx, &search.DescribeRequest{
BlobRef: permanodeRef,
Depth: 1,
})
if err != nil {
return nil, err
}
db, ok := res.Meta[permanodeRef.String()]
if !ok {
return nil, fmt.Errorf("perma... | go | func (h *Host) ObjectFromRef(permanodeRef blob.Ref) (*Object, error) {
ctx := context.TODO()
res, err := h.search.Describe(ctx, &search.DescribeRequest{
BlobRef: permanodeRef,
Depth: 1,
})
if err != nil {
return nil, err
}
db, ok := res.Meta[permanodeRef.String()]
if !ok {
return nil, fmt.Errorf("perma... | [
"func",
"(",
"h",
"*",
"Host",
")",
"ObjectFromRef",
"(",
"permanodeRef",
"blob",
".",
"Ref",
")",
"(",
"*",
"Object",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n",
"res",
",",
"err",
":=",
"h",
".",
"search",
".",
... | // ObjectFromRef returns the object given by the named permanode | [
"ObjectFromRef",
"returns",
"the",
"object",
"given",
"by",
"the",
"named",
"permanode"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1577-L1599 |
31,559 | perkeep/perkeep | pkg/blobserver/memory/mem.go | NewCache | func NewCache(size int64) *Storage {
return &Storage{
maxSize: size,
lru: lru.New(0), // infinite items; we evict by size, not count
}
} | go | func NewCache(size int64) *Storage {
return &Storage{
maxSize: size,
lru: lru.New(0), // infinite items; we evict by size, not count
}
} | [
"func",
"NewCache",
"(",
"size",
"int64",
")",
"*",
"Storage",
"{",
"return",
"&",
"Storage",
"{",
"maxSize",
":",
"size",
",",
"lru",
":",
"lru",
".",
"New",
"(",
"0",
")",
",",
"// infinite items; we evict by size, not count",
"}",
"\n",
"}"
] | // NewCache returns a cache that won't store more than size bytes.
// Blobs are evicted in LRU order. | [
"NewCache",
"returns",
"a",
"cache",
"that",
"won",
"t",
"store",
"more",
"than",
"size",
"bytes",
".",
"Blobs",
"are",
"evicted",
"in",
"LRU",
"order",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L75-L80 |
31,560 | perkeep/perkeep | pkg/blobserver/memory/mem.go | NumBlobs | func (s *Storage) NumBlobs() int {
s.mu.RLock()
defer s.mu.RUnlock()
return len(s.m)
} | go | func (s *Storage) NumBlobs() int {
s.mu.RLock()
defer s.mu.RUnlock()
return len(s.m)
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"NumBlobs",
"(",
")",
"int",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"s",
".",
"m",
")",
"\n",
"}"
] | // NumBlobs returns the number of blobs stored in s. | [
"NumBlobs",
"returns",
"the",
"number",
"of",
"blobs",
"stored",
"in",
"s",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L287-L291 |
31,561 | perkeep/perkeep | pkg/blobserver/memory/mem.go | SumBlobSize | func (s *Storage) SumBlobSize() int64 {
s.mu.RLock()
defer s.mu.RUnlock()
return s.size
} | go | func (s *Storage) SumBlobSize() int64 {
s.mu.RLock()
defer s.mu.RUnlock()
return s.size
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"SumBlobSize",
"(",
")",
"int64",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"s",
".",
"size",
"\n",
"}"
] | // SumBlobSize returns the total size in bytes of all the blobs in s. | [
"SumBlobSize",
"returns",
"the",
"total",
"size",
"in",
"bytes",
"of",
"all",
"the",
"blobs",
"in",
"s",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L294-L298 |
31,562 | perkeep/perkeep | pkg/blobserver/memory/mem.go | BlobrefStrings | func (s *Storage) BlobrefStrings() []string {
s.mu.RLock()
defer s.mu.RUnlock()
sorted := make([]string, 0, len(s.m))
for br := range s.m {
sorted = append(sorted, br.String())
}
sort.Strings(sorted)
return sorted
} | go | func (s *Storage) BlobrefStrings() []string {
s.mu.RLock()
defer s.mu.RUnlock()
sorted := make([]string, 0, len(s.m))
for br := range s.m {
sorted = append(sorted, br.String())
}
sort.Strings(sorted)
return sorted
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"BlobrefStrings",
"(",
")",
"[",
"]",
"string",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"sorted",
":=",
"make",
"(",
"[",
"]",
"string",
... | // BlobrefStrings returns the sorted stringified blobrefs stored in s. | [
"BlobrefStrings",
"returns",
"the",
"sorted",
"stringified",
"blobrefs",
"stored",
"in",
"s",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L301-L310 |
31,563 | perkeep/perkeep | pkg/blobserver/memory/mem.go | Stats | func (s *Storage) Stats() (blobsFetched, bytesFetched int64) {
return atomic.LoadInt64(&s.blobsFetched), atomic.LoadInt64(&s.bytesFetched)
} | go | func (s *Storage) Stats() (blobsFetched, bytesFetched int64) {
return atomic.LoadInt64(&s.blobsFetched), atomic.LoadInt64(&s.bytesFetched)
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"Stats",
"(",
")",
"(",
"blobsFetched",
",",
"bytesFetched",
"int64",
")",
"{",
"return",
"atomic",
".",
"LoadInt64",
"(",
"&",
"s",
".",
"blobsFetched",
")",
",",
"atomic",
".",
"LoadInt64",
"(",
"&",
"s",
".",... | // Stats returns the number of blobs and number of bytes that were fetched from s. | [
"Stats",
"returns",
"the",
"number",
"of",
"blobs",
"and",
"number",
"of",
"bytes",
"that",
"were",
"fetched",
"from",
"s",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L313-L315 |
31,564 | perkeep/perkeep | internal/netutil/ident.go | ConnUserid | func ConnUserid(conn net.Conn) (uid int, err error) {
return AddrPairUserid(conn.LocalAddr(), conn.RemoteAddr())
} | go | func ConnUserid(conn net.Conn) (uid int, err error) {
return AddrPairUserid(conn.LocalAddr(), conn.RemoteAddr())
} | [
"func",
"ConnUserid",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"uid",
"int",
",",
"err",
"error",
")",
"{",
"return",
"AddrPairUserid",
"(",
"conn",
".",
"LocalAddr",
"(",
")",
",",
"conn",
".",
"RemoteAddr",
"(",
")",
")",
"\n",
"}"
] | // ConnUserid returns the uid that owns the given localhost connection.
// The returned error is ErrNotFound if the connection wasn't found. | [
"ConnUserid",
"returns",
"the",
"uid",
"that",
"owns",
"the",
"given",
"localhost",
"connection",
".",
"The",
"returned",
"error",
"is",
"ErrNotFound",
"if",
"the",
"connection",
"wasn",
"t",
"found",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/ident.go#L44-L46 |
31,565 | perkeep/perkeep | website/pk-web/godoc.go | writeNode | func writeNode(w io.Writer, fset *token.FileSet, x interface{}) {
// convert trailing tabs into spaces using a tconv filter
// to ensure a good outcome in most browsers (there may still
// be tabs in comments and strings, but converting those into
// the right number of spaces is much harder)
//
// TODO(gri) reth... | go | func writeNode(w io.Writer, fset *token.FileSet, x interface{}) {
// convert trailing tabs into spaces using a tconv filter
// to ensure a good outcome in most browsers (there may still
// be tabs in comments and strings, but converting those into
// the right number of spaces is much harder)
//
// TODO(gri) reth... | [
"func",
"writeNode",
"(",
"w",
"io",
".",
"Writer",
",",
"fset",
"*",
"token",
".",
"FileSet",
",",
"x",
"interface",
"{",
"}",
")",
"{",
"// convert trailing tabs into spaces using a tconv filter",
"// to ensure a good outcome in most browsers (there may still",
"// be t... | // Write an AST node to w. | [
"Write",
"an",
"AST",
"node",
"to",
"w",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/godoc.go#L138-L152 |
31,566 | perkeep/perkeep | server/perkeepd/ui/goui/selectallbutton/selectall.go | getQuery | func (d SelectAllBtnDef) getQuery() *search.SearchQuery {
predicate := d.Props().callbacks.GetQuery()
if !strings.HasPrefix(predicate, "ref:") {
return &search.SearchQuery{
Limit: -1,
Expression: predicate,
}
}
// If we've got a ref: predicate, assume the given blobRef is a container, and
// find i... | go | func (d SelectAllBtnDef) getQuery() *search.SearchQuery {
predicate := d.Props().callbacks.GetQuery()
if !strings.HasPrefix(predicate, "ref:") {
return &search.SearchQuery{
Limit: -1,
Expression: predicate,
}
}
// If we've got a ref: predicate, assume the given blobRef is a container, and
// find i... | [
"func",
"(",
"d",
"SelectAllBtnDef",
")",
"getQuery",
"(",
")",
"*",
"search",
".",
"SearchQuery",
"{",
"predicate",
":=",
"d",
".",
"Props",
"(",
")",
".",
"callbacks",
".",
"GetQuery",
"(",
")",
"\n",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"p... | // getQuery returns the query corresponding to the current search in the web UI. | [
"getQuery",
"returns",
"the",
"query",
"corresponding",
"to",
"the",
"current",
"search",
"in",
"the",
"web",
"UI",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/selectallbutton/selectall.go#L145-L173 |
31,567 | perkeep/perkeep | server/perkeepd/ui/goui/selectallbutton/selectall.go | findAll | func (d SelectAllBtnDef) findAll() (map[string]bool, error) {
query := d.getQuery()
if query == nil {
return nil, nil
}
authToken := d.Props().authToken
am, err := auth.TokenOrNone(authToken)
if err != nil {
return nil, fmt.Errorf("Error setting up auth: %v", err)
}
cl, err := client.New(client.OptionAuthMo... | go | func (d SelectAllBtnDef) findAll() (map[string]bool, error) {
query := d.getQuery()
if query == nil {
return nil, nil
}
authToken := d.Props().authToken
am, err := auth.TokenOrNone(authToken)
if err != nil {
return nil, fmt.Errorf("Error setting up auth: %v", err)
}
cl, err := client.New(client.OptionAuthMo... | [
"func",
"(",
"d",
"SelectAllBtnDef",
")",
"findAll",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"bool",
",",
"error",
")",
"{",
"query",
":=",
"d",
".",
"getQuery",
"(",
")",
"\n",
"if",
"query",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n"... | // findAll returns all the permanodes matching the current web UI search
// session. The javascript UI code uses a javascript object with blobRefs as
// properties to represent a user's selection of permanodes. Since gopherjs
// converts a Go map to a javascript object, findAll returns such a map so it
// matches direc... | [
"findAll",
"returns",
"all",
"the",
"permanodes",
"matching",
"the",
"current",
"web",
"UI",
"search",
"session",
".",
"The",
"javascript",
"UI",
"code",
"uses",
"a",
"javascript",
"object",
"with",
"blobRefs",
"as",
"properties",
"to",
"represent",
"a",
"user... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/selectallbutton/selectall.go#L180-L203 |
31,568 | perkeep/perkeep | pkg/app/app.go | Client | func Client() (*client.Client, error) {
server := os.Getenv("CAMLI_API_HOST")
if server == "" {
return nil, errors.New("CAMLI_API_HOST var not set")
}
am, err := basicAuth()
if err != nil {
return nil, err
}
return client.New(
client.OptionNoExternalConfig(),
client.OptionServer(server),
client.OptionA... | go | func Client() (*client.Client, error) {
server := os.Getenv("CAMLI_API_HOST")
if server == "" {
return nil, errors.New("CAMLI_API_HOST var not set")
}
am, err := basicAuth()
if err != nil {
return nil, err
}
return client.New(
client.OptionNoExternalConfig(),
client.OptionServer(server),
client.OptionA... | [
"func",
"Client",
"(",
")",
"(",
"*",
"client",
".",
"Client",
",",
"error",
")",
"{",
"server",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"server",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\""... | // Client returns a Perkeep client as defined by environment variables
// automatically supplied by the Perkeep server host. | [
"Client",
"returns",
"a",
"Perkeep",
"client",
"as",
"defined",
"by",
"environment",
"variables",
"automatically",
"supplied",
"by",
"the",
"Perkeep",
"server",
"host",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/app/app.go#L55-L69 |
31,569 | perkeep/perkeep | cmd/pk/sync.go | storageFromParam | func (c *syncCmd) storageFromParam(which storageType, val string) (blobserver.Storage, error) {
var httpClient *http.Client
if val == "" {
switch which {
case storageThird:
return nil, nil
case storageSource:
discl := c.discoClient()
src, err := discl.BlobRoot()
if err != nil {
return nil, fmt.... | go | func (c *syncCmd) storageFromParam(which storageType, val string) (blobserver.Storage, error) {
var httpClient *http.Client
if val == "" {
switch which {
case storageThird:
return nil, nil
case storageSource:
discl := c.discoClient()
src, err := discl.BlobRoot()
if err != nil {
return nil, fmt.... | [
"func",
"(",
"c",
"*",
"syncCmd",
")",
"storageFromParam",
"(",
"which",
"storageType",
",",
"val",
"string",
")",
"(",
"blobserver",
".",
"Storage",
",",
"error",
")",
"{",
"var",
"httpClient",
"*",
"http",
".",
"Client",
"\n\n",
"if",
"val",
"==",
"\... | // which is one of "src", "dest", or "thirdleg" | [
"which",
"is",
"one",
"of",
"src",
"dest",
"or",
"thirdleg"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk/sync.go#L160-L214 |
31,570 | perkeep/perkeep | pkg/client/remove.go | RemoveBlobs | func (c *Client) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error {
if c.sto != nil {
return c.sto.RemoveBlobs(ctx, blobs)
}
pfx, err := c.prefix()
if err != nil {
return err
}
url_ := fmt.Sprintf("%s/camli/remove", pfx)
params := make(url.Values) // "blobN" -> BlobRefStr
needsDelete := ... | go | func (c *Client) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error {
if c.sto != nil {
return c.sto.RemoveBlobs(ctx, blobs)
}
pfx, err := c.prefix()
if err != nil {
return err
}
url_ := fmt.Sprintf("%s/camli/remove", pfx)
params := make(url.Values) // "blobN" -> BlobRefStr
needsDelete := ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"RemoveBlobs",
"(",
"ctx",
"context",
".",
"Context",
",",
"blobs",
"[",
"]",
"blob",
".",
"Ref",
")",
"error",
"{",
"if",
"c",
".",
"sto",
"!=",
"nil",
"{",
"return",
"c",
".",
"sto",
".",
"RemoveBlobs",
"("... | // RemoveBlobs removes the list of blobs. An error is returned if the
// server failed to remove a blob. Removing a non-existent blob isn't
// an error. | [
"RemoveBlobs",
"removes",
"the",
"list",
"of",
"blobs",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"server",
"failed",
"to",
"remove",
"a",
"blob",
".",
"Removing",
"a",
"non",
"-",
"existent",
"blob",
"isn",
"t",
"an",
"error",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/remove.go#L35-L87 |
31,571 | perkeep/perkeep | pkg/client/remove.go | RemoveBlob | func (c *Client) RemoveBlob(ctx context.Context, b blob.Ref) error {
return c.RemoveBlobs(ctx, []blob.Ref{b})
} | go | func (c *Client) RemoveBlob(ctx context.Context, b blob.Ref) error {
return c.RemoveBlobs(ctx, []blob.Ref{b})
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RemoveBlob",
"(",
"ctx",
"context",
".",
"Context",
",",
"b",
"blob",
".",
"Ref",
")",
"error",
"{",
"return",
"c",
".",
"RemoveBlobs",
"(",
"ctx",
",",
"[",
"]",
"blob",
".",
"Ref",
"{",
"b",
"}",
")",
"\... | // RemoveBlob removes the provided blob. An error is returned if the server failed to remove
// the blob. Removing a non-existent blob isn't an error. | [
"RemoveBlob",
"removes",
"the",
"provided",
"blob",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"server",
"failed",
"to",
"remove",
"the",
"blob",
".",
"Removing",
"a",
"non",
"-",
"existent",
"blob",
"isn",
"t",
"an",
"error",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/remove.go#L91-L93 |
31,572 | perkeep/perkeep | cmd/pk/list.go | setClient | func (c *listCmd) setClient() error {
ss, err := c.syncCmd.storageFromParam("src", c.syncCmd.src)
if err != nil {
fmt.Errorf("Could not set client for describe requests: %v", err)
}
var ok bool
c.cl, ok = ss.(*client.Client)
if !ok {
return fmt.Errorf("storageFromParam returned a %T, was expecting a *client.C... | go | func (c *listCmd) setClient() error {
ss, err := c.syncCmd.storageFromParam("src", c.syncCmd.src)
if err != nil {
fmt.Errorf("Could not set client for describe requests: %v", err)
}
var ok bool
c.cl, ok = ss.(*client.Client)
if !ok {
return fmt.Errorf("storageFromParam returned a %T, was expecting a *client.C... | [
"func",
"(",
"c",
"*",
"listCmd",
")",
"setClient",
"(",
")",
"error",
"{",
"ss",
",",
"err",
":=",
"c",
".",
"syncCmd",
".",
"storageFromParam",
"(",
"\"",
"\"",
",",
"c",
".",
"syncCmd",
".",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // setClient configures a client for c, for the describe requests. | [
"setClient",
"configures",
"a",
"client",
"for",
"c",
"for",
"the",
"describe",
"requests",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk/list.go#L147-L158 |
31,573 | perkeep/perkeep | internal/httputil/faketransport.go | NewRegexpFakeTransport | func NewRegexpFakeTransport(allMatchers []*Matcher) (http.RoundTripper, error) {
var result regexpFakeTransport = []*regexPair{}
for _, matcher := range allMatchers {
r, err := regexp.Compile(matcher.URLRegex)
if err != nil {
return nil, err
}
pair := regexPair{r, matcher.Fn}
result = append(result, &pai... | go | func NewRegexpFakeTransport(allMatchers []*Matcher) (http.RoundTripper, error) {
var result regexpFakeTransport = []*regexPair{}
for _, matcher := range allMatchers {
r, err := regexp.Compile(matcher.URLRegex)
if err != nil {
return nil, err
}
pair := regexPair{r, matcher.Fn}
result = append(result, &pai... | [
"func",
"NewRegexpFakeTransport",
"(",
"allMatchers",
"[",
"]",
"*",
"Matcher",
")",
"(",
"http",
".",
"RoundTripper",
",",
"error",
")",
"{",
"var",
"result",
"regexpFakeTransport",
"=",
"[",
"]",
"*",
"regexPair",
"{",
"}",
"\n",
"for",
"_",
",",
"matc... | // NewRegexpFakeTransport takes a slice of Matchers and returns an
// http.RoundTripper that will apply the function associated with the
// first UrlRegex that matches. | [
"NewRegexpFakeTransport",
"takes",
"a",
"slice",
"of",
"Matchers",
"and",
"returns",
"an",
"http",
".",
"RoundTripper",
"that",
"will",
"apply",
"the",
"function",
"associated",
"with",
"the",
"first",
"UrlRegex",
"that",
"matches",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/faketransport.go#L57-L68 |
31,574 | perkeep/perkeep | internal/httputil/faketransport.go | FileResponder | func FileResponder(filename string) func() *http.Response {
return func() *http.Response {
f, err := os.Open(filename)
if err != nil {
return &http.Response{StatusCode: 404, Status: "404 Not Found", Body: types.EmptyBody}
}
return &http.Response{StatusCode: 200, Status: "200 OK", Body: f}
}
} | go | func FileResponder(filename string) func() *http.Response {
return func() *http.Response {
f, err := os.Open(filename)
if err != nil {
return &http.Response{StatusCode: 404, Status: "404 Not Found", Body: types.EmptyBody}
}
return &http.Response{StatusCode: 200, Status: "200 OK", Body: f}
}
} | [
"func",
"FileResponder",
"(",
"filename",
"string",
")",
"func",
"(",
")",
"*",
"http",
".",
"Response",
"{",
"return",
"func",
"(",
")",
"*",
"http",
".",
"Response",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",... | // FileResponder returns an HTTP response generator that returns the
// contents of the named file. | [
"FileResponder",
"returns",
"an",
"HTTP",
"response",
"generator",
"that",
"returns",
"the",
"contents",
"of",
"the",
"named",
"file",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/faketransport.go#L89-L97 |
31,575 | perkeep/perkeep | internal/httputil/faketransport.go | StaticResponder | func StaticResponder(res string) func() *http.Response {
_, err := http.ReadResponse(bufio.NewReader(strings.NewReader(res)), nil)
if err != nil {
panic("Invalid response given to StaticResponder: " + err.Error())
}
return func() *http.Response {
res, _ := http.ReadResponse(bufio.NewReader(strings.NewReader(res... | go | func StaticResponder(res string) func() *http.Response {
_, err := http.ReadResponse(bufio.NewReader(strings.NewReader(res)), nil)
if err != nil {
panic("Invalid response given to StaticResponder: " + err.Error())
}
return func() *http.Response {
res, _ := http.ReadResponse(bufio.NewReader(strings.NewReader(res... | [
"func",
"StaticResponder",
"(",
"res",
"string",
")",
"func",
"(",
")",
"*",
"http",
".",
"Response",
"{",
"_",
",",
"err",
":=",
"http",
".",
"ReadResponse",
"(",
"bufio",
".",
"NewReader",
"(",
"strings",
".",
"NewReader",
"(",
"res",
")",
")",
","... | // StaticResponder returns an HTTP response generator that parses res
// for an entire HTTP response, including headers and body. | [
"StaticResponder",
"returns",
"an",
"HTTP",
"response",
"generator",
"that",
"parses",
"res",
"for",
"an",
"entire",
"HTTP",
"response",
"including",
"headers",
"and",
"body",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/faketransport.go#L101-L110 |
31,576 | perkeep/perkeep | internal/video/thumbnail/thumbnailer.go | Command | func (f FFmpegThumbnailer) Command(uri *url.URL) (string, []string) {
return "ffmpeg", []string{
"-seekable", "1",
"-i", uri.String(),
"-vf", "thumbnail",
"-frames:v", "1",
"-f", "image2pipe",
"-c:v", "png",
"pipe:1",
}
} | go | func (f FFmpegThumbnailer) Command(uri *url.URL) (string, []string) {
return "ffmpeg", []string{
"-seekable", "1",
"-i", uri.String(),
"-vf", "thumbnail",
"-frames:v", "1",
"-f", "image2pipe",
"-c:v", "png",
"pipe:1",
}
} | [
"func",
"(",
"f",
"FFmpegThumbnailer",
")",
"Command",
"(",
"uri",
"*",
"url",
".",
"URL",
")",
"(",
"string",
",",
"[",
"]",
"string",
")",
"{",
"return",
"\"",
"\"",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
... | // Command implements the Command method for the Thumbnailer interface. | [
"Command",
"implements",
"the",
"Command",
"method",
"for",
"the",
"Thumbnailer",
"interface",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/video/thumbnail/thumbnailer.go#L48-L58 |
31,577 | perkeep/perkeep | pkg/sorted/kv.go | NewKeyValue | func NewKeyValue(cfg jsonconfig.Obj) (KeyValue, error) {
var s KeyValue
var err error
typ := cfg.RequiredString("type")
ctor, ok := ctors[typ]
if typ != "" && !ok {
return nil, fmt.Errorf("Invalid sorted.KeyValue type %q", typ)
}
if ok {
s, err = ctor(cfg)
if err != nil {
we, ok := err.(NeedWipeError)
... | go | func NewKeyValue(cfg jsonconfig.Obj) (KeyValue, error) {
var s KeyValue
var err error
typ := cfg.RequiredString("type")
ctor, ok := ctors[typ]
if typ != "" && !ok {
return nil, fmt.Errorf("Invalid sorted.KeyValue type %q", typ)
}
if ok {
s, err = ctor(cfg)
if err != nil {
we, ok := err.(NeedWipeError)
... | [
"func",
"NewKeyValue",
"(",
"cfg",
"jsonconfig",
".",
"Obj",
")",
"(",
"KeyValue",
",",
"error",
")",
"{",
"var",
"s",
"KeyValue",
"\n",
"var",
"err",
"error",
"\n",
"typ",
":=",
"cfg",
".",
"RequiredString",
"(",
"\"",
"\"",
")",
"\n",
"ctor",
",",
... | // NewKeyValue returns a KeyValue as defined by cfg.
// It returns an error of type NeedWipeError when the returned KeyValue should
// be fixed with Wipe. | [
"NewKeyValue",
"returns",
"a",
"KeyValue",
"as",
"defined",
"by",
"cfg",
".",
"It",
"returns",
"an",
"error",
"of",
"type",
"NeedWipeError",
"when",
"the",
"returned",
"KeyValue",
"should",
"be",
"fixed",
"with",
"Wipe",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/kv.go#L204-L227 |
31,578 | perkeep/perkeep | pkg/sorted/kv.go | NewKeyValueMaybeWipe | func NewKeyValueMaybeWipe(cfg jsonconfig.Obj) (KeyValue, error) {
kv, err := NewKeyValue(cfg)
if err == nil {
return kv, nil
}
if _, ok := err.(NeedWipeError); !ok {
return nil, err
}
wiper, ok := kv.(Wiper)
if !ok {
return nil, fmt.Errorf("storage type %T needs wiping because %v. But it doesn't support so... | go | func NewKeyValueMaybeWipe(cfg jsonconfig.Obj) (KeyValue, error) {
kv, err := NewKeyValue(cfg)
if err == nil {
return kv, nil
}
if _, ok := err.(NeedWipeError); !ok {
return nil, err
}
wiper, ok := kv.(Wiper)
if !ok {
return nil, fmt.Errorf("storage type %T needs wiping because %v. But it doesn't support so... | [
"func",
"NewKeyValueMaybeWipe",
"(",
"cfg",
"jsonconfig",
".",
"Obj",
")",
"(",
"KeyValue",
",",
"error",
")",
"{",
"kv",
",",
"err",
":=",
"NewKeyValue",
"(",
"cfg",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"kv",
",",
"nil",
"\n",
"}",
... | // NewKeyValueMaybeWipe calls NewKeyValue and wipes the KeyValue if, and only
// if, NewKeyValue has returned a NeedWipeError. | [
"NewKeyValueMaybeWipe",
"calls",
"NewKeyValue",
"and",
"wipes",
"the",
"KeyValue",
"if",
"and",
"only",
"if",
"NewKeyValue",
"has",
"returned",
"a",
"NeedWipeError",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/kv.go#L231-L248 |
31,579 | perkeep/perkeep | pkg/sorted/kv.go | CheckSizes | func CheckSizes(key, value string) error {
if len(key) > MaxKeySize {
return ErrKeyTooLarge
}
if len(value) > MaxValueSize {
return ErrValueTooLarge
}
return nil
} | go | func CheckSizes(key, value string) error {
if len(key) > MaxKeySize {
return ErrKeyTooLarge
}
if len(value) > MaxValueSize {
return ErrValueTooLarge
}
return nil
} | [
"func",
"CheckSizes",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"key",
")",
">",
"MaxKeySize",
"{",
"return",
"ErrKeyTooLarge",
"\n",
"}",
"\n",
"if",
"len",
"(",
"value",
")",
">",
"MaxValueSize",
"{",
"return",
"ErrValu... | // CheckSizes returns ErrKeyTooLarge if key does not respect KeyMaxSize or
// ErrValueTooLarge if value does not respect ValueMaxSize | [
"CheckSizes",
"returns",
"ErrKeyTooLarge",
"if",
"key",
"does",
"not",
"respect",
"KeyMaxSize",
"or",
"ErrValueTooLarge",
"if",
"value",
"does",
"not",
"respect",
"ValueMaxSize"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/kv.go#L273-L281 |
31,580 | perkeep/perkeep | pkg/search/query.go | addContinueConstraint | func (q *SearchQuery) addContinueConstraint() error {
cont := q.Continue
if cont == "" {
return nil
}
if q.Constraint.onlyMatchesPermanode() {
tokent, lastbr, ok := parsePermanodeContinueToken(cont)
if !ok {
return errors.New("Unexpected continue token")
}
if q.Sort == LastModifiedDesc || q.Sort == Cre... | go | func (q *SearchQuery) addContinueConstraint() error {
cont := q.Continue
if cont == "" {
return nil
}
if q.Constraint.onlyMatchesPermanode() {
tokent, lastbr, ok := parsePermanodeContinueToken(cont)
if !ok {
return errors.New("Unexpected continue token")
}
if q.Sort == LastModifiedDesc || q.Sort == Cre... | [
"func",
"(",
"q",
"*",
"SearchQuery",
")",
"addContinueConstraint",
"(",
")",
"error",
"{",
"cont",
":=",
"q",
".",
"Continue",
"\n",
"if",
"cont",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"q",
".",
"Constraint",
".",
"onlyMatch... | // addContinueConstraint conditionally modifies q.Constraint to scroll
// past the results as indicated by q.Continue. | [
"addContinueConstraint",
"conditionally",
"modifies",
"q",
".",
"Constraint",
"to",
"scroll",
"past",
"the",
"results",
"as",
"indicated",
"by",
"q",
".",
"Continue",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L195-L233 |
31,581 | perkeep/perkeep | pkg/search/query.go | matchesPermanodeTypes | func (c *Constraint) matchesPermanodeTypes() []string {
if c == nil {
return nil
}
if pc := c.Permanode; pc != nil && pc.Attr == "camliNodeType" && pc.Value != "" {
return []string{pc.Value}
}
if lc := c.Logical; lc != nil {
sa := lc.A.matchesPermanodeTypes()
sb := lc.B.matchesPermanodeTypes()
switch lc.... | go | func (c *Constraint) matchesPermanodeTypes() []string {
if c == nil {
return nil
}
if pc := c.Permanode; pc != nil && pc.Attr == "camliNodeType" && pc.Value != "" {
return []string{pc.Value}
}
if lc := c.Logical; lc != nil {
sa := lc.A.matchesPermanodeTypes()
sb := lc.B.matchesPermanodeTypes()
switch lc.... | [
"func",
"(",
"c",
"*",
"Constraint",
")",
"matchesPermanodeTypes",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"pc",
":=",
"c",
".",
"Permanode",
";",
"pc",
"!=",
"nil",
"&&",
"pc",
".",... | // matchesPermanodeTypes returns a set of valid permanode types that a matching
// permanode must have as its "camliNodeType" attribute.
// It returns a zero-length slice if this constraint might include things other
// things. | [
"matchesPermanodeTypes",
"returns",
"a",
"set",
"of",
"valid",
"permanode",
"types",
"that",
"a",
"matching",
"permanode",
"must",
"have",
"as",
"its",
"camliNodeType",
"attribute",
".",
"It",
"returns",
"a",
"zero",
"-",
"length",
"slice",
"if",
"this",
"cons... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L338-L360 |
31,582 | perkeep/perkeep | pkg/search/query.go | matchesAtMostOneBlob | func (c *Constraint) matchesAtMostOneBlob() blob.Ref {
if c == nil {
return blob.Ref{}
}
if c.BlobRefPrefix != "" {
br, ok := blob.Parse(c.BlobRefPrefix)
if ok {
return br
}
}
if c.Logical != nil && c.Logical.Op == "and" {
if br := c.Logical.A.matchesAtMostOneBlob(); br.Valid() {
return br
}
if... | go | func (c *Constraint) matchesAtMostOneBlob() blob.Ref {
if c == nil {
return blob.Ref{}
}
if c.BlobRefPrefix != "" {
br, ok := blob.Parse(c.BlobRefPrefix)
if ok {
return br
}
}
if c.Logical != nil && c.Logical.Op == "and" {
if br := c.Logical.A.matchesAtMostOneBlob(); br.Valid() {
return br
}
if... | [
"func",
"(",
"c",
"*",
"Constraint",
")",
"matchesAtMostOneBlob",
"(",
")",
"blob",
".",
"Ref",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"blob",
".",
"Ref",
"{",
"}",
"\n",
"}",
"\n",
"if",
"c",
".",
"BlobRefPrefix",
"!=",
"\"",
"\"",
"{",
"br... | // matchesAtMostOneBlob reports whether this constraint matches at most a single blob.
// If so, it returns that blob. Otherwise it returns a zero, invalid blob.Ref. | [
"matchesAtMostOneBlob",
"reports",
"whether",
"this",
"constraint",
"matches",
"at",
"most",
"a",
"single",
"blob",
".",
"If",
"so",
"it",
"returns",
"that",
"blob",
".",
"Otherwise",
"it",
"returns",
"a",
"zero",
"invalid",
"blob",
".",
"Ref",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L364-L383 |
31,583 | perkeep/perkeep | pkg/search/query.go | setResultContinue | func (q *SearchQuery) setResultContinue(corpus *index.Corpus, res *SearchResult) {
if !q.Constraint.onlyMatchesPermanode() {
return
}
var pnTimeFunc func(blob.Ref) (t time.Time, ok bool)
switch q.Sort {
case LastModifiedDesc:
pnTimeFunc = corpus.PermanodeModtime
case CreatedDesc:
pnTimeFunc = corpus.Permano... | go | func (q *SearchQuery) setResultContinue(corpus *index.Corpus, res *SearchResult) {
if !q.Constraint.onlyMatchesPermanode() {
return
}
var pnTimeFunc func(blob.Ref) (t time.Time, ok bool)
switch q.Sort {
case LastModifiedDesc:
pnTimeFunc = corpus.PermanodeModtime
case CreatedDesc:
pnTimeFunc = corpus.Permano... | [
"func",
"(",
"q",
"*",
"SearchQuery",
")",
"setResultContinue",
"(",
"corpus",
"*",
"index",
".",
"Corpus",
",",
"res",
"*",
"SearchResult",
")",
"{",
"if",
"!",
"q",
".",
"Constraint",
".",
"onlyMatchesPermanode",
"(",
")",
"{",
"return",
"\n",
"}",
"... | // setResultContinue sets res.Continue if q is suitable for having a continue token.
// The corpus is locked for reads. | [
"setResultContinue",
"sets",
"res",
".",
"Continue",
"if",
"q",
"is",
"suitable",
"for",
"having",
"a",
"continue",
"token",
".",
"The",
"corpus",
"is",
"locked",
"for",
"reads",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L1359-L1382 |
31,584 | perkeep/perkeep | pkg/search/query.go | hasValueConstraint | func (c *PermanodeConstraint) hasValueConstraint() bool {
// If a field has been added or removed, update this after adding the new field to the return statement if necessary.
const expectedFields = 15
if numPermanodeFields != expectedFields {
panic(fmt.Sprintf("PermanodeConstraint field count changed (now %v rath... | go | func (c *PermanodeConstraint) hasValueConstraint() bool {
// If a field has been added or removed, update this after adding the new field to the return statement if necessary.
const expectedFields = 15
if numPermanodeFields != expectedFields {
panic(fmt.Sprintf("PermanodeConstraint field count changed (now %v rath... | [
"func",
"(",
"c",
"*",
"PermanodeConstraint",
")",
"hasValueConstraint",
"(",
")",
"bool",
"{",
"// If a field has been added or removed, update this after adding the new field to the return statement if necessary.",
"const",
"expectedFields",
"=",
"15",
"\n",
"if",
"numPermanode... | // hasValueConstraint returns true if one or more constraints that check an attribute's value are set. | [
"hasValueConstraint",
"returns",
"true",
"if",
"one",
"or",
"more",
"constraints",
"that",
"check",
"an",
"attribute",
"s",
"value",
"are",
"set",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L1668-L1679 |
31,585 | perkeep/perkeep | pkg/search/query.go | permanodeMatchesAttrVals | func (c *PermanodeConstraint) permanodeMatchesAttrVals(ctx context.Context, s *search, vals []string) (bool, error) {
if c.NumValue != nil && !c.NumValue.intMatches(int64(len(vals))) {
return false, nil
}
if c.hasValueConstraint() {
nmatch := 0
for _, val := range vals {
match, err := c.permanodeMatchesAttr... | go | func (c *PermanodeConstraint) permanodeMatchesAttrVals(ctx context.Context, s *search, vals []string) (bool, error) {
if c.NumValue != nil && !c.NumValue.intMatches(int64(len(vals))) {
return false, nil
}
if c.hasValueConstraint() {
nmatch := 0
for _, val := range vals {
match, err := c.permanodeMatchesAttr... | [
"func",
"(",
"c",
"*",
"PermanodeConstraint",
")",
"permanodeMatchesAttrVals",
"(",
"ctx",
"context",
".",
"Context",
",",
"s",
"*",
"search",
",",
"vals",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"c",
".",
"NumValue",
"!=",
... | // permanodeMatchesAttrVals checks that the values in vals - all of them, if c.ValueAll is set -
// match the values for c.Attr.
// vals are the current permanode values of c.Attr. | [
"permanodeMatchesAttrVals",
"checks",
"that",
"the",
"values",
"in",
"vals",
"-",
"all",
"of",
"them",
"if",
"c",
".",
"ValueAll",
"is",
"set",
"-",
"match",
"the",
"values",
"for",
"c",
".",
"Attr",
".",
"vals",
"are",
"the",
"current",
"permanode",
"va... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L1822-L1845 |
31,586 | perkeep/perkeep | pkg/search/query.go | hasMatchingParent | func (c *DirConstraint) hasMatchingParent(ctx context.Context, s *search, parents map[blob.Ref]struct{}) (bool, error) {
for parent := range parents {
meta, err := s.blobMeta(ctx, parent)
if err != nil {
if os.IsNotExist(err) {
continue
}
return false, err
}
ok, err := c.blobMatches(ctx, s, parent... | go | func (c *DirConstraint) hasMatchingParent(ctx context.Context, s *search, parents map[blob.Ref]struct{}) (bool, error) {
for parent := range parents {
meta, err := s.blobMeta(ctx, parent)
if err != nil {
if os.IsNotExist(err) {
continue
}
return false, err
}
ok, err := c.blobMatches(ctx, s, parent... | [
"func",
"(",
"c",
"*",
"DirConstraint",
")",
"hasMatchingParent",
"(",
"ctx",
"context",
".",
"Context",
",",
"s",
"*",
"search",
",",
"parents",
"map",
"[",
"blob",
".",
"Ref",
"]",
"struct",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"fo... | // hasMatchingParent checks all parents against c and returns true as soon as one of
// them matches, or returns false if none of them is a match. | [
"hasMatchingParent",
"checks",
"all",
"parents",
"against",
"c",
"and",
"returns",
"true",
"as",
"soon",
"as",
"one",
"of",
"them",
"matches",
"or",
"returns",
"false",
"if",
"none",
"of",
"them",
"is",
"a",
"match",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L2185-L2203 |
31,587 | perkeep/perkeep | pkg/search/query.go | hasMatchingChild | func (c *DirConstraint) hasMatchingChild(ctx context.Context, s *search, children map[blob.Ref]struct{},
matcher func(context.Context, *search, blob.Ref, camtypes.BlobMeta) (bool, error)) (bool, error) {
// TODO(mpl): See if we're guaranteed to be CPU-bound (i.e. all resources are in
// corpus), and if not, add some... | go | func (c *DirConstraint) hasMatchingChild(ctx context.Context, s *search, children map[blob.Ref]struct{},
matcher func(context.Context, *search, blob.Ref, camtypes.BlobMeta) (bool, error)) (bool, error) {
// TODO(mpl): See if we're guaranteed to be CPU-bound (i.e. all resources are in
// corpus), and if not, add some... | [
"func",
"(",
"c",
"*",
"DirConstraint",
")",
"hasMatchingChild",
"(",
"ctx",
"context",
".",
"Context",
",",
"s",
"*",
"search",
",",
"children",
"map",
"[",
"blob",
".",
"Ref",
"]",
"struct",
"{",
"}",
",",
"matcher",
"func",
"(",
"context",
".",
"C... | // hasMatchingChild runs matcher against each child and returns true as soon as
// there is a match, of false if none of them is a match. | [
"hasMatchingChild",
"runs",
"matcher",
"against",
"each",
"child",
"and",
"returns",
"true",
"as",
"soon",
"as",
"there",
"is",
"a",
"match",
"of",
"false",
"if",
"none",
"of",
"them",
"is",
"a",
"match",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/query.go#L2207-L2228 |
31,588 | perkeep/perkeep | pkg/blobserver/localdisk/generation.go | StorageGeneration | func (ds *DiskStorage) StorageGeneration() (initTime time.Time, random string, err error) {
return ds.gen.StorageGeneration()
} | go | func (ds *DiskStorage) StorageGeneration() (initTime time.Time, random string, err error) {
return ds.gen.StorageGeneration()
} | [
"func",
"(",
"ds",
"*",
"DiskStorage",
")",
"StorageGeneration",
"(",
")",
"(",
"initTime",
"time",
".",
"Time",
",",
"random",
"string",
",",
"err",
"error",
")",
"{",
"return",
"ds",
".",
"gen",
".",
"StorageGeneration",
"(",
")",
"\n",
"}"
] | // StorageGeneration returns the generation's initialization time,
// and the random string. | [
"StorageGeneration",
"returns",
"the",
"generation",
"s",
"initialization",
"time",
"and",
"the",
"random",
"string",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/localdisk/generation.go#L30-L32 |
31,589 | perkeep/perkeep | internal/osutil/gce/gce.go | LogWriter | func LogWriter() (w io.WriteCloser, err error) {
w = multiWriteCloser{
w: os.Stderr,
// Because we don't actually want to close os.Stderr (which we could).
closer: types.NopCloser,
}
if !env.OnGCE() {
return
}
projID, err := metadata.ProjectID()
if projID == "" {
log.Printf("Error getting project ID: %v... | go | func LogWriter() (w io.WriteCloser, err error) {
w = multiWriteCloser{
w: os.Stderr,
// Because we don't actually want to close os.Stderr (which we could).
closer: types.NopCloser,
}
if !env.OnGCE() {
return
}
projID, err := metadata.ProjectID()
if projID == "" {
log.Printf("Error getting project ID: %v... | [
"func",
"LogWriter",
"(",
")",
"(",
"w",
"io",
".",
"WriteCloser",
",",
"err",
"error",
")",
"{",
"w",
"=",
"multiWriteCloser",
"{",
"w",
":",
"os",
".",
"Stderr",
",",
"// Because we don't actually want to close os.Stderr (which we could).",
"closer",
":",
"typ... | // LogWriter returns an environment-specific io.WriteCloser suitable for passing
// to log.SetOutput. It will also include writing to os.Stderr as well.
// Since it might be writing to a Google Cloud Logger, it is the responsibility
// of the caller to Close it when needed, to flush the last log entries. | [
"LogWriter",
"returns",
"an",
"environment",
"-",
"specific",
"io",
".",
"WriteCloser",
"suitable",
"for",
"passing",
"to",
"log",
".",
"SetOutput",
".",
"It",
"will",
"also",
"include",
"writing",
"to",
"os",
".",
"Stderr",
"as",
"well",
".",
"Since",
"it... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/gce/gce.go#L102-L145 |
31,590 | perkeep/perkeep | internal/osutil/gce/gce.go | resetInstance | func resetInstance() error {
if !env.OnGCE() {
return errors.New("cannot reset instance if not on GCE")
}
ctx := context.Background()
inst, err := gceInstance()
if err != nil {
return err
}
cs, projectID, zone, name := inst.cis, inst.projectID, inst.zone, inst.name
call := cs.Reset(projectID, zone, name)... | go | func resetInstance() error {
if !env.OnGCE() {
return errors.New("cannot reset instance if not on GCE")
}
ctx := context.Background()
inst, err := gceInstance()
if err != nil {
return err
}
cs, projectID, zone, name := inst.cis, inst.projectID, inst.zone, inst.name
call := cs.Reset(projectID, zone, name)... | [
"func",
"resetInstance",
"(",
")",
"error",
"{",
"if",
"!",
"env",
".",
"OnGCE",
"(",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n\n",
"inst",
",",
"er... | // resetInstance reboots the GCE VM that this process is running in. | [
"resetInstance",
"reboots",
"the",
"GCE",
"VM",
"that",
"this",
"process",
"is",
"running",
"in",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/gce/gce.go#L188-L237 |
31,591 | perkeep/perkeep | server/perkeepd/ui/goui/sharebutton/sharebutton.go | OnClick | func (d ShareItemsBtnDef) OnClick(e *react.SyntheticMouseEvent) {
go func() {
sharedURL, err := d.shareSelection()
if err != nil {
dom.GetWindow().Alert(fmt.Sprintf("%v", err))
return
}
prefix, err := d.urlPrefix()
if err != nil {
dom.GetWindow().Alert(fmt.Sprintf("Cannot display full share URL: %v"... | go | func (d ShareItemsBtnDef) OnClick(e *react.SyntheticMouseEvent) {
go func() {
sharedURL, err := d.shareSelection()
if err != nil {
dom.GetWindow().Alert(fmt.Sprintf("%v", err))
return
}
prefix, err := d.urlPrefix()
if err != nil {
dom.GetWindow().Alert(fmt.Sprintf("Cannot display full share URL: %v"... | [
"func",
"(",
"d",
"ShareItemsBtnDef",
")",
"OnClick",
"(",
"e",
"*",
"react",
".",
"SyntheticMouseEvent",
")",
"{",
"go",
"func",
"(",
")",
"{",
"sharedURL",
",",
"err",
":=",
"d",
".",
"shareSelection",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // On success, handleShareSelection calls d.showSharedURL with the URL that can
// be used to share the item. If the item is a file, the URL can be used directly
// to fetch the file. If the item is a directory, the URL should be used with
// pk-get -shared. | [
"On",
"success",
"handleShareSelection",
"calls",
"d",
".",
"showSharedURL",
"with",
"the",
"URL",
"that",
"can",
"be",
"used",
"to",
"share",
"the",
"item",
".",
"If",
"the",
"item",
"is",
"a",
"file",
"the",
"URL",
"can",
"be",
"used",
"directly",
"to"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/sharebutton/sharebutton.go#L166-L183 |
31,592 | perkeep/perkeep | server/perkeepd/ui/goui/sharebutton/sharebutton.go | mkdir | func mkdir(am auth.AuthMode, children []blob.Ref) (blob.Ref, error) {
cl, err := client.New(client.OptionAuthMode(am))
if err != nil {
return blob.Ref{}, err
}
var newdir blob.Ref
ss := schema.NewStaticSet()
subsets := ss.SetStaticSetMembers(children)
for _, v := range subsets {
// TODO(mpl): make them concu... | go | func mkdir(am auth.AuthMode, children []blob.Ref) (blob.Ref, error) {
cl, err := client.New(client.OptionAuthMode(am))
if err != nil {
return blob.Ref{}, err
}
var newdir blob.Ref
ss := schema.NewStaticSet()
subsets := ss.SetStaticSetMembers(children)
for _, v := range subsets {
// TODO(mpl): make them concu... | [
"func",
"mkdir",
"(",
"am",
"auth",
".",
"AuthMode",
",",
"children",
"[",
"]",
"blob",
".",
"Ref",
")",
"(",
"blob",
".",
"Ref",
",",
"error",
")",
"{",
"cl",
",",
"err",
":=",
"client",
".",
"New",
"(",
"client",
".",
"OptionAuthMode",
"(",
"am... | // mkdir creates a new directory blob, with children composing its static-set,
// and uploads it. It returns the blobRef of the new directory. | [
"mkdir",
"creates",
"a",
"new",
"directory",
"blob",
"with",
"children",
"composing",
"its",
"static",
"-",
"set",
"and",
"uploads",
"it",
".",
"It",
"returns",
"the",
"blobRef",
"of",
"the",
"new",
"directory",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/sharebutton/sharebutton.go#L225-L252 |
31,593 | perkeep/perkeep | server/perkeepd/ui/goui/sharebutton/sharebutton.go | shareFile | func shareFile(am auth.AuthMode, target blob.Ref, isDir bool) (string, error) {
cl, err := client.New(client.OptionAuthMode(am))
if err != nil {
return "", err
}
claim, err := newShareClaim(cl, target)
if err != nil {
return "", err
}
shareRoot, err := cl.ShareRoot()
if err != nil {
return "", err
}
if ... | go | func shareFile(am auth.AuthMode, target blob.Ref, isDir bool) (string, error) {
cl, err := client.New(client.OptionAuthMode(am))
if err != nil {
return "", err
}
claim, err := newShareClaim(cl, target)
if err != nil {
return "", err
}
shareRoot, err := cl.ShareRoot()
if err != nil {
return "", err
}
if ... | [
"func",
"shareFile",
"(",
"am",
"auth",
".",
"AuthMode",
",",
"target",
"blob",
".",
"Ref",
",",
"isDir",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"cl",
",",
"err",
":=",
"client",
".",
"New",
"(",
"client",
".",
"OptionAuthMode",
"(",
"... | // shareFile returns the URL that can be used to share the target item. If the
// item is a file, the URL can be used directly to fetch the file. If the item is a
// directory, the URL should be used with pk-get -shared. | [
"shareFile",
"returns",
"the",
"URL",
"that",
"can",
"be",
"used",
"to",
"share",
"the",
"target",
"item",
".",
"If",
"the",
"item",
"is",
"a",
"file",
"the",
"URL",
"can",
"be",
"used",
"directly",
"to",
"fetch",
"the",
"file",
".",
"If",
"the",
"it... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/sharebutton/sharebutton.go#L257-L274 |
31,594 | perkeep/perkeep | server/perkeepd/ui/goui/sharebutton/sharebutton.go | newShareClaim | func newShareClaim(cl *client.Client, target blob.Ref) (blob.Ref, error) {
var claim blob.Ref
signer, err := cl.ServerPublicKeyBlobRef()
if err != nil {
return claim, fmt.Errorf("could not get signer: %v", err)
}
shareSchema := schema.NewShareRef(schema.ShareHaveRef, true)
shareSchema.SetShareTarget(target)
un... | go | func newShareClaim(cl *client.Client, target blob.Ref) (blob.Ref, error) {
var claim blob.Ref
signer, err := cl.ServerPublicKeyBlobRef()
if err != nil {
return claim, fmt.Errorf("could not get signer: %v", err)
}
shareSchema := schema.NewShareRef(schema.ShareHaveRef, true)
shareSchema.SetShareTarget(target)
un... | [
"func",
"newShareClaim",
"(",
"cl",
"*",
"client",
".",
"Client",
",",
"target",
"blob",
".",
"Ref",
")",
"(",
"blob",
".",
"Ref",
",",
"error",
")",
"{",
"var",
"claim",
"blob",
".",
"Ref",
"\n",
"signer",
",",
"err",
":=",
"cl",
".",
"ServerPubli... | // newShareClaim creates, signs, and uploads a transitive haveref share claim
// for sharing the target item. It returns the ref of the claim. | [
"newShareClaim",
"creates",
"signs",
"and",
"uploads",
"a",
"transitive",
"haveref",
"share",
"claim",
"for",
"sharing",
"the",
"target",
"item",
".",
"It",
"returns",
"the",
"ref",
"of",
"the",
"claim",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/sharebutton/sharebutton.go#L278-L299 |
31,595 | perkeep/perkeep | pkg/importer/gphotos/download.go | fileAsPhoto | func (dl *downloader) fileAsPhoto(f *drive.File) *photo {
if f == nil {
return nil
}
if f.Size == 0 {
// anything non-binary can't be a photo, so skip it.
return nil
}
if !inPhotoSpace(f) {
// not a photo
return nil
}
p := &photo{
ID: f.Id,
Name: f.Name,
Starred: ... | go | func (dl *downloader) fileAsPhoto(f *drive.File) *photo {
if f == nil {
return nil
}
if f.Size == 0 {
// anything non-binary can't be a photo, so skip it.
return nil
}
if !inPhotoSpace(f) {
// not a photo
return nil
}
p := &photo{
ID: f.Id,
Name: f.Name,
Starred: ... | [
"func",
"(",
"dl",
"*",
"downloader",
")",
"fileAsPhoto",
"(",
"f",
"*",
"drive",
".",
"File",
")",
"*",
"photo",
"{",
"if",
"f",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"f",
".",
"Size",
"==",
"0",
"{",
"// anything non-binary ca... | // fileAsPhoto returns a photo populated with the information found about f,
// or nil if f is not actually a photo from Google Photos.
//
// The returned photo contains only the metadata;
// the content of the photo can be downloaded with dl.openPhoto. | [
"fileAsPhoto",
"returns",
"a",
"photo",
"populated",
"with",
"the",
"information",
"found",
"about",
"f",
"or",
"nil",
"if",
"f",
"is",
"not",
"actually",
"a",
"photo",
"from",
"Google",
"Photos",
".",
"The",
"returned",
"photo",
"contains",
"only",
"the",
... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/gphotos/download.go#L281-L315 |
31,596 | perkeep/perkeep | pkg/importer/gphotos/download.go | rateLimit | func (dl *downloader) rateLimit(ctx context.Context, f func() error) error {
const (
msgRateLimitExceeded = "Rate Limit Exceeded"
msgUserRateLimitExceeded = "User Rate Limit Exceeded"
msgUserRateLimitExceededShort = "userRateLimitExceeded"
)
// Ensure a 1 minute try limit.
ctx, cancel := contex... | go | func (dl *downloader) rateLimit(ctx context.Context, f func() error) error {
const (
msgRateLimitExceeded = "Rate Limit Exceeded"
msgUserRateLimitExceeded = "User Rate Limit Exceeded"
msgUserRateLimitExceededShort = "userRateLimitExceeded"
)
// Ensure a 1 minute try limit.
ctx, cancel := contex... | [
"func",
"(",
"dl",
"*",
"downloader",
")",
"rateLimit",
"(",
"ctx",
"context",
".",
"Context",
",",
"f",
"func",
"(",
")",
"error",
")",
"error",
"{",
"const",
"(",
"msgRateLimitExceeded",
"=",
"\"",
"\"",
"\n",
"msgUserRateLimitExceeded",
"=",
"\"",
"\"... | // rateLimit calls f obeying the global Rate limit.
// On "Rate Limit Exceeded" error, it sleeps and tries later. | [
"rateLimit",
"calls",
"f",
"obeying",
"the",
"global",
"Rate",
"limit",
".",
"On",
"Rate",
"Limit",
"Exceeded",
"error",
"it",
"sleeps",
"and",
"tries",
"later",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/gphotos/download.go#L319-L364 |
31,597 | perkeep/perkeep | internal/magic/magic.go | MIMEType | func MIMEType(hdr []byte) string {
hlen := len(hdr)
for _, pte := range matchTable {
if pte.fn != nil {
if pte.fn(hdr) {
return pte.mtype
}
continue
}
plen := pte.offset + len(pte.prefix)
if hlen > plen && bytes.Equal(hdr[pte.offset:plen], pte.prefix) {
return pte.mtype
}
}
t := http.Detec... | go | func MIMEType(hdr []byte) string {
hlen := len(hdr)
for _, pte := range matchTable {
if pte.fn != nil {
if pte.fn(hdr) {
return pte.mtype
}
continue
}
plen := pte.offset + len(pte.prefix)
if hlen > plen && bytes.Equal(hdr[pte.offset:plen], pte.prefix) {
return pte.mtype
}
}
t := http.Detec... | [
"func",
"MIMEType",
"(",
"hdr",
"[",
"]",
"byte",
")",
"string",
"{",
"hlen",
":=",
"len",
"(",
"hdr",
")",
"\n",
"for",
"_",
",",
"pte",
":=",
"range",
"matchTable",
"{",
"if",
"pte",
".",
"fn",
"!=",
"nil",
"{",
"if",
"pte",
".",
"fn",
"(",
... | // MIMEType returns the MIME type from the data in the provided header
// of the data.
// It returns the empty string if the MIME type can't be determined. | [
"MIMEType",
"returns",
"the",
"MIME",
"type",
"from",
"the",
"data",
"in",
"the",
"provided",
"header",
"of",
"the",
"data",
".",
"It",
"returns",
"the",
"empty",
"string",
"if",
"the",
"MIME",
"type",
"can",
"t",
"be",
"determined",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/magic/magic.go#L173-L193 |
31,598 | perkeep/perkeep | internal/magic/magic.go | MIMETypeFromReaderAt | func MIMETypeFromReaderAt(ra io.ReaderAt) (mime string) {
var buf [1024]byte
n, _ := ra.ReadAt(buf[:], 0)
return MIMEType(buf[:n])
} | go | func MIMETypeFromReaderAt(ra io.ReaderAt) (mime string) {
var buf [1024]byte
n, _ := ra.ReadAt(buf[:], 0)
return MIMEType(buf[:n])
} | [
"func",
"MIMETypeFromReaderAt",
"(",
"ra",
"io",
".",
"ReaderAt",
")",
"(",
"mime",
"string",
")",
"{",
"var",
"buf",
"[",
"1024",
"]",
"byte",
"\n",
"n",
",",
"_",
":=",
"ra",
".",
"ReadAt",
"(",
"buf",
"[",
":",
"]",
",",
"0",
")",
"\n",
"ret... | // MIMETypeFromReaderAt takes a ReaderAt, sniffs the beginning of it,
// and returns the MIME type if sniffed, else the empty string. | [
"MIMETypeFromReaderAt",
"takes",
"a",
"ReaderAt",
"sniffs",
"the",
"beginning",
"of",
"it",
"and",
"returns",
"the",
"MIME",
"type",
"if",
"sniffed",
"else",
"the",
"empty",
"string",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/magic/magic.go#L211-L215 |
31,599 | perkeep/perkeep | internal/magic/magic.go | HasExtension | func HasExtension(filename string, extensions map[string]bool) bool {
var ext string
if e := filepath.Ext(filename); strings.HasPrefix(e, ".") {
ext = e[1:]
} else {
return false
}
// Case-insensitive lookup.
// Optimistically assume a short ASCII extension and be
// allocation-free in that case.
var buf [... | go | func HasExtension(filename string, extensions map[string]bool) bool {
var ext string
if e := filepath.Ext(filename); strings.HasPrefix(e, ".") {
ext = e[1:]
} else {
return false
}
// Case-insensitive lookup.
// Optimistically assume a short ASCII extension and be
// allocation-free in that case.
var buf [... | [
"func",
"HasExtension",
"(",
"filename",
"string",
",",
"extensions",
"map",
"[",
"string",
"]",
"bool",
")",
"bool",
"{",
"var",
"ext",
"string",
"\n",
"if",
"e",
":=",
"filepath",
".",
"Ext",
"(",
"filename",
")",
";",
"strings",
".",
"HasPrefix",
"(... | // HasExtension returns whether the file extension of filename is among
// extensions. It is a case-insensitive lookup, optimized for the ASCII case. | [
"HasExtension",
"returns",
"whether",
"the",
"file",
"extension",
"of",
"filename",
"is",
"among",
"extensions",
".",
"It",
"is",
"a",
"case",
"-",
"insensitive",
"lookup",
"optimized",
"for",
"the",
"ASCII",
"case",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/magic/magic.go#L235-L264 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.