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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
perkeep/perkeep
internal/magic/magic.go
MIMETypeByExtension
func MIMETypeByExtension(ext string) string { mimeParts := strings.SplitN(mime.TypeByExtension(ext), ";", 2) return strings.TrimSpace(mimeParts[0]) }
go
func MIMETypeByExtension(ext string) string { mimeParts := strings.SplitN(mime.TypeByExtension(ext), ";", 2) return strings.TrimSpace(mimeParts[0]) }
[ "func", "MIMETypeByExtension", "(", "ext", "string", ")", "string", "{", "mimeParts", ":=", "strings", ".", "SplitN", "(", "mime", ".", "TypeByExtension", "(", "ext", ")", ",", "\"", "\"", ",", "2", ")", "\n", "return", "strings", ".", "TrimSpace", "(", ...
// MIMETypeByExtension calls mime.TypeByExtension, and removes optional parameters, // to keep only the type and subtype.
[ "MIMETypeByExtension", "calls", "mime", ".", "TypeByExtension", "and", "removes", "optional", "parameters", "to", "keep", "only", "the", "type", "and", "subtype", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/magic/magic.go#L268-L271
train
perkeep/perkeep
pkg/blobserver/blobpacked/blobpacked.go
checkLargeIntegrity
func (s *storage) checkLargeIntegrity() (RecoveryMode, error) { inLarge := 0 var missing []blob.Ref // blobs in large but not in meta var extra []blob.Ref // blobs in meta but not in large t := s.meta.Find(zipMetaPrefix, zipMetaPrefixLimit) defer t.Close() iterate := true var enumFunc func(sb blob.SizedRef) er...
go
func (s *storage) checkLargeIntegrity() (RecoveryMode, error) { inLarge := 0 var missing []blob.Ref // blobs in large but not in meta var extra []blob.Ref // blobs in meta but not in large t := s.meta.Find(zipMetaPrefix, zipMetaPrefixLimit) defer t.Close() iterate := true var enumFunc func(sb blob.SizedRef) er...
[ "func", "(", "s", "*", "storage", ")", "checkLargeIntegrity", "(", ")", "(", "RecoveryMode", ",", "error", ")", "{", "inLarge", ":=", "0", "\n", "var", "missing", "[", "]", "blob", ".", "Ref", "// blobs in large but not in meta", "\n", "var", "extra", "[",...
// checkLargeIntegrity verifies that all large blobs in the large storage are // indexed in meta, and vice-versa, that all rows in meta referring to a large blob // correspond to an existing large blob in the large storage. If any of the above // is not true, it returns the recovery mode that should be used to fix the ...
[ "checkLargeIntegrity", "verifies", "that", "all", "large", "blobs", "in", "the", "large", "storage", "are", "indexed", "in", "meta", "and", "vice", "-", "versa", "that", "all", "rows", "in", "meta", "referring", "to", "a", "large", "blob", "correspond", "to"...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobpacked/blobpacked.go#L383-L441
train
perkeep/perkeep
pkg/blobserver/blobpacked/blobpacked.go
getMetaRow
func (s *storage) getMetaRow(br blob.Ref) (meta, error) { v, err := s.meta.Get(blobMetaPrefix + br.String()) if err == sorted.ErrNotFound { return meta{}, nil } if err != nil { return meta{}, fmt.Errorf("blobpacked.getMetaRow(%v) = %v", br, err) } return parseMetaRow([]byte(v)) }
go
func (s *storage) getMetaRow(br blob.Ref) (meta, error) { v, err := s.meta.Get(blobMetaPrefix + br.String()) if err == sorted.ErrNotFound { return meta{}, nil } if err != nil { return meta{}, fmt.Errorf("blobpacked.getMetaRow(%v) = %v", br, err) } return parseMetaRow([]byte(v)) }
[ "func", "(", "s", "*", "storage", ")", "getMetaRow", "(", "br", "blob", ".", "Ref", ")", "(", "meta", ",", "error", ")", "{", "v", ",", "err", ":=", "s", ".", "meta", ".", "Get", "(", "blobMetaPrefix", "+", "br", ".", "String", "(", ")", ")", ...
// if not found, err == nil.
[ "if", "not", "found", "err", "==", "nil", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobpacked/blobpacked.go#L841-L850
train
perkeep/perkeep
pkg/blobserver/blobpacked/blobpacked.go
check
func check(err error) { if err != nil { b := make([]byte, 2<<10) b = b[:runtime.Stack(b, false)] log.Printf("Unlikely error condition triggered: %v at %s", err, b) panic(err) } }
go
func check(err error) { if err != nil { b := make([]byte, 2<<10) b = b[:runtime.Stack(b, false)] log.Printf("Unlikely error condition triggered: %v at %s", err, b) panic(err) } }
[ "func", "check", "(", "err", "error", ")", "{", "if", "err", "!=", "nil", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "2", "<<", "10", ")", "\n", "b", "=", "b", "[", ":", "runtime", ".", "Stack", "(", "b", ",", "false", ")", "]", ...
// check should only be used for things which really shouldn't ever happen, but should // still be checked. If there is interesting logic in the 'else', then don't use this.
[ "check", "should", "only", "be", "used", "for", "things", "which", "really", "shouldn", "t", "ever", "happen", "but", "should", "still", "be", "checked", ".", "If", "there", "is", "interesting", "logic", "in", "the", "else", "then", "don", "t", "use", "t...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobpacked/blobpacked.go#L1297-L1304
train
perkeep/perkeep
pkg/blobserver/blobpacked/blobpacked.go
foreachZipBlob
func (s *storage) foreachZipBlob(ctx context.Context, zipRef blob.Ref, fn func(BlobAndPos) error) error { sb, err := blobserver.StatBlob(ctx, s.large, zipRef) if err != nil { return err } zr, err := zip.NewReader(blob.ReaderAt(ctx, s.large, zipRef), int64(sb.Size)) if err != nil { return zipOpenError{zipRef, e...
go
func (s *storage) foreachZipBlob(ctx context.Context, zipRef blob.Ref, fn func(BlobAndPos) error) error { sb, err := blobserver.StatBlob(ctx, s.large, zipRef) if err != nil { return err } zr, err := zip.NewReader(blob.ReaderAt(ctx, s.large, zipRef), int64(sb.Size)) if err != nil { return zipOpenError{zipRef, e...
[ "func", "(", "s", "*", "storage", ")", "foreachZipBlob", "(", "ctx", "context", ".", "Context", ",", "zipRef", "blob", ".", "Ref", ",", "fn", "func", "(", "BlobAndPos", ")", "error", ")", "error", "{", "sb", ",", "err", ":=", "blobserver", ".", "Stat...
// foreachZipBlob calls fn for each blob in the zip pack blob // identified by zipRef. If fn returns a non-nil error, // foreachZipBlob stops enumerating with that error.
[ "foreachZipBlob", "calls", "fn", "for", "each", "blob", "in", "the", "zip", "pack", "blob", "identified", "by", "zipRef", ".", "If", "fn", "returns", "a", "non", "-", "nil", "error", "foreachZipBlob", "stops", "enumerating", "with", "that", "error", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobpacked/blobpacked.go#L1522-L1590
train
perkeep/perkeep
pkg/blobserver/blobpacked/blobpacked.go
deleteZipPack
func (s *storage) deleteZipPack(ctx context.Context, br blob.Ref) error { inUse, err := s.zipPartsInUse(ctx, br) if err != nil { return err } if len(inUse) > 0 { return fmt.Errorf("can't delete zip pack %v: %d parts in use: %v", br, len(inUse), inUse) } if err := s.large.RemoveBlobs(ctx, []blob.Ref{br}); err ...
go
func (s *storage) deleteZipPack(ctx context.Context, br blob.Ref) error { inUse, err := s.zipPartsInUse(ctx, br) if err != nil { return err } if len(inUse) > 0 { return fmt.Errorf("can't delete zip pack %v: %d parts in use: %v", br, len(inUse), inUse) } if err := s.large.RemoveBlobs(ctx, []blob.Ref{br}); err ...
[ "func", "(", "s", "*", "storage", ")", "deleteZipPack", "(", "ctx", "context", ".", "Context", ",", "br", "blob", ".", "Ref", ")", "error", "{", "inUse", ",", "err", ":=", "s", ".", "zipPartsInUse", "(", "ctx", ",", "br", ")", "\n", "if", "err", ...
// deleteZipPack deletes the zip pack file br, but only if that zip // file's parts are deleted already from the meta index.
[ "deleteZipPack", "deletes", "the", "zip", "pack", "file", "br", "but", "only", "if", "that", "zip", "file", "s", "parts", "are", "deleted", "already", "from", "the", "meta", "index", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobpacked/blobpacked.go#L1594-L1606
train
perkeep/perkeep
internal/video/thumbnail/service.go
NewService
func NewService(th Thumbnailer, timeout time.Duration, maxProcs int) *Service { var g *syncutil.Gate if maxProcs > 0 { g = syncutil.NewGate(maxProcs) } return &Service{ thumbnailer: th, timeout: timeout, gate: g, } }
go
func NewService(th Thumbnailer, timeout time.Duration, maxProcs int) *Service { var g *syncutil.Gate if maxProcs > 0 { g = syncutil.NewGate(maxProcs) } return &Service{ thumbnailer: th, timeout: timeout, gate: g, } }
[ "func", "NewService", "(", "th", "Thumbnailer", ",", "timeout", "time", ".", "Duration", ",", "maxProcs", "int", ")", "*", "Service", "{", "var", "g", "*", "syncutil", ".", "Gate", "\n", "if", "maxProcs", ">", "0", "{", "g", "=", "syncutil", ".", "Ne...
// NewService builds a new Service. Zero timeout or maxProcs means no limit.
[ "NewService", "builds", "a", "new", "Service", ".", "Zero", "timeout", "or", "maxProcs", "means", "no", "limit", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/video/thumbnail/service.go#L82-L94
train
perkeep/perkeep
internal/video/thumbnail/service.go
Generate
func (s *Service) Generate(videoRef blob.Ref, w io.Writer, src blob.Fetcher) error { if s.gate != nil { s.gate.Start() defer s.gate.Done() } ln, err := netutil.ListenOnLocalRandomPort() if err != nil { return err } defer ln.Close() videoURI := &url.URL{ Scheme: "http", Host: ln.Addr().String(), ...
go
func (s *Service) Generate(videoRef blob.Ref, w io.Writer, src blob.Fetcher) error { if s.gate != nil { s.gate.Start() defer s.gate.Done() } ln, err := netutil.ListenOnLocalRandomPort() if err != nil { return err } defer ln.Close() videoURI := &url.URL{ Scheme: "http", Host: ln.Addr().String(), ...
[ "func", "(", "s", "*", "Service", ")", "Generate", "(", "videoRef", "blob", ".", "Ref", ",", "w", "io", ".", "Writer", ",", "src", "blob", ".", "Fetcher", ")", "error", "{", "if", "s", ".", "gate", "!=", "nil", "{", "s", ".", "gate", ".", "Star...
// Generate reads the video given by videoRef from src and writes its thumbnail image to w.
[ "Generate", "reads", "the", "video", "given", "by", "videoRef", "from", "src", "and", "writes", "its", "thumbnail", "image", "to", "w", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/video/thumbnail/service.go#L99-L155
train
perkeep/perkeep
server/perkeepd/ui/goui/downloadbutton/gen_DownloadItemsBtn_reactGen.go
Props
func (d DownloadItemsBtnDef) Props() DownloadItemsBtnProps { uprops := d.ComponentDef.Props() return uprops.(DownloadItemsBtnProps) }
go
func (d DownloadItemsBtnDef) Props() DownloadItemsBtnProps { uprops := d.ComponentDef.Props() return uprops.(DownloadItemsBtnProps) }
[ "func", "(", "d", "DownloadItemsBtnDef", ")", "Props", "(", ")", "DownloadItemsBtnProps", "{", "uprops", ":=", "d", ".", "ComponentDef", ".", "Props", "(", ")", "\n", "return", "uprops", ".", "(", "DownloadItemsBtnProps", ")", "\n", "}" ]
// Props is an auto-generated proxy to the current props of DownloadItemsBtn
[ "Props", "is", "an", "auto", "-", "generated", "proxy", "to", "the", "current", "props", "of", "DownloadItemsBtn" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/downloadbutton/gen_DownloadItemsBtn_reactGen.go#L30-L33
train
perkeep/perkeep
pkg/server/import_share.go
importAll
func (si *shareImporter) importAll(ctx context.Context) error { src, shared, err := client.NewFromShareRoot(ctx, si.shareURL, client.OptionNoExternalConfig()) if err != nil { return err } si.src = src si.br = shared si.workc = make(chan work, 2*numWorkers) defer close(si.workc) // fan out over a pool of numW...
go
func (si *shareImporter) importAll(ctx context.Context) error { src, shared, err := client.NewFromShareRoot(ctx, si.shareURL, client.OptionNoExternalConfig()) if err != nil { return err } si.src = src si.br = shared si.workc = make(chan work, 2*numWorkers) defer close(si.workc) // fan out over a pool of numW...
[ "func", "(", "si", "*", "shareImporter", ")", "importAll", "(", "ctx", "context", ".", "Context", ")", "error", "{", "src", ",", "shared", ",", "err", ":=", "client", ".", "NewFromShareRoot", "(", "ctx", ",", "si", ".", "shareURL", ",", "client", ".", ...
// importAll imports all the shared contents transitively reachable under // si.shareURL.
[ "importAll", "imports", "all", "the", "shared", "contents", "transitively", "reachable", "under", "si", ".", "shareURL", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/import_share.go#L176-L207
train
perkeep/perkeep
pkg/server/import_share.go
importAssembled
func (si *shareImporter) importAssembled(ctx context.Context) { res, err := http.Get(si.shareURL) if err != nil { return } defer res.Body.Close() br, err := schema.WriteFileFromReader(ctx, si.dest, "", res.Body) if err != nil { return } si.mu.Lock() si.br = br si.mu.Unlock() return }
go
func (si *shareImporter) importAssembled(ctx context.Context) { res, err := http.Get(si.shareURL) if err != nil { return } defer res.Body.Close() br, err := schema.WriteFileFromReader(ctx, si.dest, "", res.Body) if err != nil { return } si.mu.Lock() si.br = br si.mu.Unlock() return }
[ "func", "(", "si", "*", "shareImporter", ")", "importAssembled", "(", "ctx", "context", ".", "Context", ")", "{", "res", ",", "err", ":=", "http", ".", "Get", "(", "si", ".", "shareURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}"...
// importAssembled imports the assembled file shared at si.shareURL.
[ "importAssembled", "imports", "the", "assembled", "file", "shared", "at", "si", ".", "shareURL", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/import_share.go#L210-L224
train
perkeep/perkeep
pkg/server/import_share.go
isAssembled
func (si *shareImporter) isAssembled() (bool, error) { u, err := url.Parse(si.shareURL) if err != nil { return false, err } isAs, _ := strconv.ParseBool(u.Query().Get("assemble")) return isAs, nil }
go
func (si *shareImporter) isAssembled() (bool, error) { u, err := url.Parse(si.shareURL) if err != nil { return false, err } isAs, _ := strconv.ParseBool(u.Query().Get("assemble")) return isAs, nil }
[ "func", "(", "si", "*", "shareImporter", ")", "isAssembled", "(", ")", "(", "bool", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "si", ".", "shareURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", ...
// isAssembled reports whether si.shareURL is of a shared assembled file.
[ "isAssembled", "reports", "whether", "si", ".", "shareURL", "is", "of", "a", "shared", "assembled", "file", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/import_share.go#L227-L234
train
perkeep/perkeep
pkg/server/import_share.go
serveProgress
func (si *shareImporter) serveProgress(w http.ResponseWriter, r *http.Request) { si.mu.RLock() defer si.mu.RUnlock() httputil.ReturnJSON(w, camtypes.ShareImportProgress{ FilesSeen: si.seen, FilesCopied: si.copied, Running: si.running, Assembled: si.assembled, BlobRef: si.br, }) }
go
func (si *shareImporter) serveProgress(w http.ResponseWriter, r *http.Request) { si.mu.RLock() defer si.mu.RUnlock() httputil.ReturnJSON(w, camtypes.ShareImportProgress{ FilesSeen: si.seen, FilesCopied: si.copied, Running: si.running, Assembled: si.assembled, BlobRef: si.br, }) }
[ "func", "(", "si", "*", "shareImporter", ")", "serveProgress", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "si", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "si", ".", "mu", ".", "RUnlock", "(", ...
// serveProgress serves the state of the currently running importing process
[ "serveProgress", "serves", "the", "state", "of", "the", "currently", "running", "importing", "process" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/import_share.go#L304-L314
train
perkeep/perkeep
internal/httputil/certs.go
GenSelfTLS
func GenSelfTLS(hostname string) (certPEM, keyPEM []byte, err error) { priv, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { return certPEM, keyPEM, fmt.Errorf("failed to generate private key: %s", err) } now := time.Now() if hostname == "" { hostname = "localhost" } serialNumberLimit := new(big....
go
func GenSelfTLS(hostname string) (certPEM, keyPEM []byte, err error) { priv, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { return certPEM, keyPEM, fmt.Errorf("failed to generate private key: %s", err) } now := time.Now() if hostname == "" { hostname = "localhost" } serialNumberLimit := new(big....
[ "func", "GenSelfTLS", "(", "hostname", "string", ")", "(", "certPEM", ",", "keyPEM", "[", "]", "byte", ",", "err", "error", ")", "{", "priv", ",", "err", ":=", "rsa", ".", "GenerateKey", "(", "rand", ".", "Reader", ",", "2048", ")", "\n", "if", "er...
// GenSelfTLS generates a self-signed certificate and key for hostname.
[ "GenSelfTLS", "generates", "a", "self", "-", "signed", "certificate", "and", "key", "for", "hostname", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/certs.go#L54-L100
train
perkeep/perkeep
internal/httputil/certs.go
CertFingerprint
func CertFingerprint(certPEM []byte) (string, error) { p, _ := pem.Decode(certPEM) if p == nil { return "", errors.New("no valid PEM data found") } cert, err := x509.ParseCertificate(p.Bytes) if err != nil { return "", fmt.Errorf("failed to parse certificate: %v", err) } return hashutil.SHA256Prefix(cert.Raw...
go
func CertFingerprint(certPEM []byte) (string, error) { p, _ := pem.Decode(certPEM) if p == nil { return "", errors.New("no valid PEM data found") } cert, err := x509.ParseCertificate(p.Bytes) if err != nil { return "", fmt.Errorf("failed to parse certificate: %v", err) } return hashutil.SHA256Prefix(cert.Raw...
[ "func", "CertFingerprint", "(", "certPEM", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "p", ",", "_", ":=", "pem", ".", "Decode", "(", "certPEM", ")", "\n", "if", "p", "==", "nil", "{", "return", "\"", "\"", ",", "errors", ".", ...
// CertFingerprint returns the SHA-256 prefix of the x509 certificate encoded in certPEM.
[ "CertFingerprint", "returns", "the", "SHA", "-", "256", "prefix", "of", "the", "x509", "certificate", "encoded", "in", "certPEM", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/certs.go#L103-L113
train
perkeep/perkeep
internal/httputil/certs.go
GenSelfTLSFiles
func GenSelfTLSFiles(hostname, certPath, keyPath string) (fingerprint string, err error) { cert, key, err := GenSelfTLS(hostname) if err != nil { return "", err } sig, err := CertFingerprint(cert) if err != nil { return "", fmt.Errorf("could not get SHA-256 fingerprint of certificate: %v", err) } if err := w...
go
func GenSelfTLSFiles(hostname, certPath, keyPath string) (fingerprint string, err error) { cert, key, err := GenSelfTLS(hostname) if err != nil { return "", err } sig, err := CertFingerprint(cert) if err != nil { return "", fmt.Errorf("could not get SHA-256 fingerprint of certificate: %v", err) } if err := w...
[ "func", "GenSelfTLSFiles", "(", "hostname", ",", "certPath", ",", "keyPath", "string", ")", "(", "fingerprint", "string", ",", "err", "error", ")", "{", "cert", ",", "key", ",", "err", ":=", "GenSelfTLS", "(", "hostname", ")", "\n", "if", "err", "!=", ...
// GenSelfTLSFiles generates a self-signed certificate and key for hostname, // and writes them to the given paths. If it succeeds it also returns // the SHA256 prefix of the new cert.
[ "GenSelfTLSFiles", "generates", "a", "self", "-", "signed", "certificate", "and", "key", "for", "hostname", "and", "writes", "them", "to", "the", "given", "paths", ".", "If", "it", "succeeds", "it", "also", "returns", "the", "SHA256", "prefix", "of", "the", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/certs.go#L118-L134
train
perkeep/perkeep
pkg/types/camtypes/search.go
Contains
func (b LocationBounds) Contains(loc Location) bool { if b.SpansDateLine() { return loc.Longitude >= b.West || loc.Longitude <= b.East } return loc.Longitude >= b.West && loc.Longitude <= b.East }
go
func (b LocationBounds) Contains(loc Location) bool { if b.SpansDateLine() { return loc.Longitude >= b.West || loc.Longitude <= b.East } return loc.Longitude >= b.West && loc.Longitude <= b.East }
[ "func", "(", "b", "LocationBounds", ")", "Contains", "(", "loc", "Location", ")", "bool", "{", "if", "b", ".", "SpansDateLine", "(", ")", "{", "return", "loc", ".", "Longitude", ">=", "b", ".", "West", "||", "loc", ".", "Longitude", "<=", "b", ".", ...
// Contains reports whether loc is in the bounds b.
[ "Contains", "reports", "whether", "loc", "is", "in", "the", "bounds", "b", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/types/camtypes/search.go#L285-L290
train
perkeep/perkeep
pkg/types/camtypes/search.go
Expand
func (b LocationBounds) Expand(loc Location) LocationBounds { if b == (LocationBounds{}) { return LocationBounds{ North: loc.Latitude, South: loc.Latitude, West: loc.Longitude, East: loc.Longitude, } } nb := LocationBounds{ North: b.North, South: b.South, West: b.West, East: b.East, } i...
go
func (b LocationBounds) Expand(loc Location) LocationBounds { if b == (LocationBounds{}) { return LocationBounds{ North: loc.Latitude, South: loc.Latitude, West: loc.Longitude, East: loc.Longitude, } } nb := LocationBounds{ North: b.North, South: b.South, West: b.West, East: b.East, } i...
[ "func", "(", "b", "LocationBounds", ")", "Expand", "(", "loc", "Location", ")", "LocationBounds", "{", "if", "b", "==", "(", "LocationBounds", "{", "}", ")", "{", "return", "LocationBounds", "{", "North", ":", "loc", ".", "Latitude", ",", "South", ":", ...
// Expand returns a new LocationBounds nb. If either of loc coordinates is // outside of b, nb is the dimensions of b expanded as little as possible in // order to include loc. Otherwise, nb is just a copy of b.
[ "Expand", "returns", "a", "new", "LocationBounds", "nb", ".", "If", "either", "of", "loc", "coordinates", "is", "outside", "of", "b", "nb", "is", "the", "dimensions", "of", "b", "expanded", "as", "little", "as", "possible", "in", "order", "to", "include", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/types/camtypes/search.go#L302-L345
train
perkeep/perkeep
internal/osutil/restart_windows.go
SelfPath
func SelfPath() (string, error) { kernel32, err := syscall.LoadDLL("kernel32.dll") if err != nil { return "", err } sysproc, err := kernel32.FindProc("GetModuleFileNameW") if err != nil { return "", err } b := make([]uint16, syscall.MAX_PATH) r, _, err := sysproc.Call(0, uintptr(unsafe.Pointer(&b[0])), uint...
go
func SelfPath() (string, error) { kernel32, err := syscall.LoadDLL("kernel32.dll") if err != nil { return "", err } sysproc, err := kernel32.FindProc("GetModuleFileNameW") if err != nil { return "", err } b := make([]uint16, syscall.MAX_PATH) r, _, err := sysproc.Call(0, uintptr(unsafe.Pointer(&b[0])), uint...
[ "func", "SelfPath", "(", ")", "(", "string", ",", "error", ")", "{", "kernel32", ",", "err", ":=", "syscall", ".", "LoadDLL", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "sysproc",...
// SelfPath returns the path of the executable for the currently running // process.
[ "SelfPath", "returns", "the", "path", "of", "the", "executable", "for", "the", "currently", "running", "process", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/restart_windows.go#L30-L46
train
perkeep/perkeep
cmd/pk/googinit.go
prompt
func prompt(promptText string) string { fmt.Fprint(cmdmain.Stdout, promptText) sc := bufio.NewScanner(cmdmain.Stdin) sc.Scan() return strings.TrimSpace(sc.Text()) }
go
func prompt(promptText string) string { fmt.Fprint(cmdmain.Stdout, promptText) sc := bufio.NewScanner(cmdmain.Stdin) sc.Scan() return strings.TrimSpace(sc.Text()) }
[ "func", "prompt", "(", "promptText", "string", ")", "string", "{", "fmt", ".", "Fprint", "(", "cmdmain", ".", "Stdout", ",", "promptText", ")", "\n", "sc", ":=", "bufio", ".", "NewScanner", "(", "cmdmain", ".", "Stdin", ")", "\n", "sc", ".", "Scan", ...
// Prompt the user for an input line. Return the given input.
[ "Prompt", "the", "user", "for", "an", "input", "line", ".", "Return", "the", "given", "input", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk/googinit.go#L116-L121
train
perkeep/perkeep
pkg/fs/xattr.go
load
func (x *xattr) load(p *search.DescribedPermanode) { x.mu.Lock() defer x.mu.Unlock() *x.xattrs = map[string][]byte{} for k, v := range p.Attr { if strings.HasPrefix(k, xattrPrefix) { name := k[len(xattrPrefix):] val, err := base64.StdEncoding.DecodeString(v[0]) if err != nil { Logger.Printf("Base64 ...
go
func (x *xattr) load(p *search.DescribedPermanode) { x.mu.Lock() defer x.mu.Unlock() *x.xattrs = map[string][]byte{} for k, v := range p.Attr { if strings.HasPrefix(k, xattrPrefix) { name := k[len(xattrPrefix):] val, err := base64.StdEncoding.DecodeString(v[0]) if err != nil { Logger.Printf("Base64 ...
[ "func", "(", "x", "*", "xattr", ")", "load", "(", "p", "*", "search", ".", "DescribedPermanode", ")", "{", "x", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "x", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "*", "x", ".", "xattrs", "=", "m...
// load is invoked after the creation of a fuse.Node that may contain extended // attributes. This creates the node's xattr map as well as fills it with any // extended attributes found in the permanode's claims.
[ "load", "is", "invoked", "after", "the", "creation", "of", "a", "fuse", ".", "Node", "that", "may", "contain", "extended", "attributes", ".", "This", "creates", "the", "node", "s", "xattr", "map", "as", "well", "as", "fills", "it", "with", "any", "extend...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/xattr.go#L58-L74
train
perkeep/perkeep
pkg/blobserver/stat.go
StatBlob
func StatBlob(ctx context.Context, bs BlobStatter, br blob.Ref) (blob.SizedRef, error) { var ret blob.SizedRef err := bs.StatBlobs(ctx, []blob.Ref{br}, func(sb blob.SizedRef) error { ret = sb return nil }) if err == nil && !ret.Ref.Valid() { err = os.ErrNotExist } return ret, err }
go
func StatBlob(ctx context.Context, bs BlobStatter, br blob.Ref) (blob.SizedRef, error) { var ret blob.SizedRef err := bs.StatBlobs(ctx, []blob.Ref{br}, func(sb blob.SizedRef) error { ret = sb return nil }) if err == nil && !ret.Ref.Valid() { err = os.ErrNotExist } return ret, err }
[ "func", "StatBlob", "(", "ctx", "context", ".", "Context", ",", "bs", "BlobStatter", ",", "br", "blob", ".", "Ref", ")", "(", "blob", ".", "SizedRef", ",", "error", ")", "{", "var", "ret", "blob", ".", "SizedRef", "\n", "err", ":=", "bs", ".", "Sta...
// StatBlob calls bs.StatBlobs to stat a single blob. // If the blob is not found, the error is os.ErrNotExist.
[ "StatBlob", "calls", "bs", ".", "StatBlobs", "to", "stat", "a", "single", "blob", ".", "If", "the", "blob", "is", "not", "found", "the", "error", "is", "os", ".", "ErrNotExist", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/stat.go#L31-L41
train
perkeep/perkeep
pkg/blobserver/stat.go
StatBlobs
func StatBlobs(ctx context.Context, bs BlobStatter, blobs []blob.Ref) (map[blob.Ref]blob.SizedRef, error) { var m map[blob.Ref]blob.SizedRef err := bs.StatBlobs(ctx, blobs, func(sb blob.SizedRef) error { if m == nil { m = make(map[blob.Ref]blob.SizedRef) } m[sb.Ref] = sb return nil }) return m, err }
go
func StatBlobs(ctx context.Context, bs BlobStatter, blobs []blob.Ref) (map[blob.Ref]blob.SizedRef, error) { var m map[blob.Ref]blob.SizedRef err := bs.StatBlobs(ctx, blobs, func(sb blob.SizedRef) error { if m == nil { m = make(map[blob.Ref]blob.SizedRef) } m[sb.Ref] = sb return nil }) return m, err }
[ "func", "StatBlobs", "(", "ctx", "context", ".", "Context", ",", "bs", "BlobStatter", ",", "blobs", "[", "]", "blob", ".", "Ref", ")", "(", "map", "[", "blob", ".", "Ref", "]", "blob", ".", "SizedRef", ",", "error", ")", "{", "var", "m", "map", "...
// StatBlobs stats multiple blobs and returns a map // of the found refs to their sizes.
[ "StatBlobs", "stats", "multiple", "blobs", "and", "returns", "a", "map", "of", "the", "found", "refs", "to", "their", "sizes", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/stat.go#L45-L55
train
perkeep/perkeep
website/pk-web/contributors.go
add
func (a *author) add(src *author) { if src == nil { return } a.Emails = append(a.Emails, src.Emails...) a.Names = append(a.Names, src.Names...) a.Commits += src.Commits if src.Role != "" { a.Role = src.Role } if src.URL != "" { a.URL = src.URL } }
go
func (a *author) add(src *author) { if src == nil { return } a.Emails = append(a.Emails, src.Emails...) a.Names = append(a.Names, src.Names...) a.Commits += src.Commits if src.Role != "" { a.Role = src.Role } if src.URL != "" { a.URL = src.URL } }
[ "func", "(", "a", "*", "author", ")", "add", "(", "src", "*", "author", ")", "{", "if", "src", "==", "nil", "{", "return", "\n", "}", "\n", "a", ".", "Emails", "=", "append", "(", "a", ".", "Emails", ",", "src", ".", "Emails", "...", ")", "\n...
// add merges src's fields into a's.
[ "add", "merges", "src", "s", "fields", "into", "a", "s", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/contributors.go#L45-L58
train
perkeep/perkeep
website/pk-web/contributors.go
contribHandler
func contribHandler() http.HandlerFunc { c, err := genContribPage() if err != nil { log.Printf("Couldn't generate contributors page: %v", err) log.Printf("Using static contributors page") return mainHandler } title := "" if m := h1TitlePattern.FindSubmatch(c); len(m) > 1 { title = string(m[1]) } return ...
go
func contribHandler() http.HandlerFunc { c, err := genContribPage() if err != nil { log.Printf("Couldn't generate contributors page: %v", err) log.Printf("Using static contributors page") return mainHandler } title := "" if m := h1TitlePattern.FindSubmatch(c); len(m) > 1 { title = string(m[1]) } return ...
[ "func", "contribHandler", "(", ")", "http", ".", "HandlerFunc", "{", "c", ",", "err", ":=", "genContribPage", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "log", ".", "Printf", "(", ...
// contribHandler returns a handler that serves the generated contributors page, // or the static file handler if it couldn't run git for any reason.
[ "contribHandler", "returns", "a", "handler", "that", "serves", "the", "generated", "contributors", "page", "or", "the", "static", "file", "handler", "if", "it", "couldn", "t", "run", "git", "for", "any", "reason", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/contributors.go#L184-L202
train
perkeep/perkeep
pkg/schema/sign.go
SignJSON
func (s *Signer) SignJSON(ctx context.Context, json string, t time.Time) (string, error) { sr := s.baseSigReq sr.UnsignedJSON = json sr.SignatureTime = t return sr.Sign(ctx) }
go
func (s *Signer) SignJSON(ctx context.Context, json string, t time.Time) (string, error) { sr := s.baseSigReq sr.UnsignedJSON = json sr.SignatureTime = t return sr.Sign(ctx) }
[ "func", "(", "s", "*", "Signer", ")", "SignJSON", "(", "ctx", "context", ".", "Context", ",", "json", "string", ",", "t", "time", ".", "Time", ")", "(", "string", ",", "error", ")", "{", "sr", ":=", "s", ".", "baseSigReq", "\n", "sr", ".", "Unsig...
// SignJSON signs the provided json at the optional time t. // If t is the zero Time, the current time is used.
[ "SignJSON", "signs", "the", "provided", "json", "at", "the", "optional", "time", "t", ".", "If", "t", "is", "the", "zero", "Time", "the", "current", "time", "is", "used", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/sign.go#L120-L125
train
perkeep/perkeep
pkg/server/ui.go
InitHandler
func (ui *UIHandler) InitHandler(hl blobserver.FindHandlerByTyper) error { // InitHandler is called after all handlers have been setup, so the bootstrap // of the camliRoot node for publishers in dev-mode is already done. searchPrefix, _, err := hl.FindHandlerByType("search") if err != nil { return errors.New("No...
go
func (ui *UIHandler) InitHandler(hl blobserver.FindHandlerByTyper) error { // InitHandler is called after all handlers have been setup, so the bootstrap // of the camliRoot node for publishers in dev-mode is already done. searchPrefix, _, err := hl.FindHandlerByType("search") if err != nil { return errors.New("No...
[ "func", "(", "ui", "*", "UIHandler", ")", "InitHandler", "(", "hl", "blobserver", ".", "FindHandlerByTyper", ")", "error", "{", "// InitHandler is called after all handlers have been setup, so the bootstrap", "// of the camliRoot node for publishers in dev-mode is already done.", "...
// InitHandler goes through all the other configured handlers to discover // the publisher ones, and uses them to populate ui.publishRoots.
[ "InitHandler", "goes", "through", "all", "the", "other", "configured", "handlers", "to", "discover", "the", "publisher", "ones", "and", "uses", "them", "to", "populate", "ui", ".", "publishRoots", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/ui.go#L253-L322
train
perkeep/perkeep
pkg/server/ui.go
ServeStaticFile
func ServeStaticFile(rw http.ResponseWriter, req *http.Request, root http.FileSystem, file string) { f, err := root.Open("/" + file) if err != nil { http.NotFound(rw, req) log.Printf("Failed to open file %q from embedded resources: %v", file, err) return } defer f.Close() var modTime time.Time if fi, err :=...
go
func ServeStaticFile(rw http.ResponseWriter, req *http.Request, root http.FileSystem, file string) { f, err := root.Open("/" + file) if err != nil { http.NotFound(rw, req) log.Printf("Failed to open file %q from embedded resources: %v", file, err) return } defer f.Close() var modTime time.Time if fi, err :=...
[ "func", "ServeStaticFile", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "root", "http", ".", "FileSystem", ",", "file", "string", ")", "{", "f", ",", "err", ":=", "root", ".", "Open", "(", "\"", "\"", "+", ...
// ServeStaticFile serves file from the root virtual filesystem.
[ "ServeStaticFile", "serves", "file", "from", "the", "root", "virtual", "filesystem", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/ui.go#L488-L506
train
perkeep/perkeep
pkg/server/ui.go
serveDepsJS
func serveDepsJS(rw http.ResponseWriter, req *http.Request, dir string) { var root http.FileSystem if dir == "" { root = uistatic.Files } else { root = http.Dir(dir) } b, err := closure.GenDeps(root) if err != nil { log.Print(err) http.Error(rw, "Server error", 500) return } rw.Header().Set("Content-...
go
func serveDepsJS(rw http.ResponseWriter, req *http.Request, dir string) { var root http.FileSystem if dir == "" { root = uistatic.Files } else { root = http.Dir(dir) } b, err := closure.GenDeps(root) if err != nil { log.Print(err) http.Error(rw, "Server error", 500) return } rw.Header().Set("Content-...
[ "func", "serveDepsJS", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "dir", "string", ")", "{", "var", "root", "http", ".", "FileSystem", "\n", "if", "dir", "==", "\"", "\"", "{", "root", "=", "uistatic", "."...
// serveDepsJS serves an auto-generated Closure deps.js file.
[ "serveDepsJS", "serves", "an", "auto", "-", "generated", "Closure", "deps", ".", "js", "file", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/ui.go#L672-L689
train
perkeep/perkeep
pkg/sorted/kvfile/kvfile.go
NewStorage
func NewStorage(file string) (sorted.KeyValue, error) { return newKeyValueFromJSONConfig(jsonconfig.Obj{"file": file}) }
go
func NewStorage(file string) (sorted.KeyValue, error) { return newKeyValueFromJSONConfig(jsonconfig.Obj{"file": file}) }
[ "func", "NewStorage", "(", "file", "string", ")", "(", "sorted", ".", "KeyValue", ",", "error", ")", "{", "return", "newKeyValueFromJSONConfig", "(", "jsonconfig", ".", "Obj", "{", "\"", "\"", ":", "file", "}", ")", "\n", "}" ]
// NewStorage is a convenience that calls newKeyValueFromJSONConfig // with file as the kv storage file.
[ "NewStorage", "is", "a", "convenience", "that", "calls", "newKeyValueFromJSONConfig", "with", "file", "as", "the", "kv", "storage", "file", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/kvfile/kvfile.go#L46-L48
train
perkeep/perkeep
pkg/client/upload.go
NewUploadHandleFromString
func NewUploadHandleFromString(data string) *UploadHandle { bref := blob.RefFromString(data) r := strings.NewReader(data) return &UploadHandle{BlobRef: bref, Size: uint32(len(data)), Contents: r} }
go
func NewUploadHandleFromString(data string) *UploadHandle { bref := blob.RefFromString(data) r := strings.NewReader(data) return &UploadHandle{BlobRef: bref, Size: uint32(len(data)), Contents: r} }
[ "func", "NewUploadHandleFromString", "(", "data", "string", ")", "*", "UploadHandle", "{", "bref", ":=", "blob", ".", "RefFromString", "(", "data", ")", "\n", "r", ":=", "strings", ".", "NewReader", "(", "data", ")", "\n", "return", "&", "UploadHandle", "{...
// NewUploadHandleFromString returns an upload handle
[ "NewUploadHandleFromString", "returns", "an", "upload", "handle" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/upload.go#L132-L136
train
perkeep/perkeep
pkg/client/upload.go
doStat
func (c *Client) doStat(ctx context.Context, blobs []blob.Ref, wait time.Duration, gated bool, fn func(blob.SizedRef) error) error { var buf bytes.Buffer fmt.Fprintf(&buf, "camliversion=1") if wait > 0 { secs := int(wait.Seconds()) if secs == 0 { secs = 1 } fmt.Fprintf(&buf, "&maxwaitsec=%d", secs) } fo...
go
func (c *Client) doStat(ctx context.Context, blobs []blob.Ref, wait time.Duration, gated bool, fn func(blob.SizedRef) error) error { var buf bytes.Buffer fmt.Fprintf(&buf, "camliversion=1") if wait > 0 { secs := int(wait.Seconds()) if secs == 0 { secs = 1 } fmt.Fprintf(&buf, "&maxwaitsec=%d", secs) } fo...
[ "func", "(", "c", "*", "Client", ")", "doStat", "(", "ctx", "context", ".", "Context", ",", "blobs", "[", "]", "blob", ".", "Ref", ",", "wait", "time", ".", "Duration", ",", "gated", "bool", ",", "fn", "func", "(", "blob", ".", "SizedRef", ")", "...
// doStat does an HTTP request for the stat. the number of blobs is used verbatim. No extra splitting // or batching is done at this layer. // The semantics are the same as blobserver.BlobStatter. // gate controls whether it uses httpGate to pause on requests.
[ "doStat", "does", "an", "HTTP", "request", "for", "the", "stat", ".", "the", "number", "of", "blobs", "is", "used", "verbatim", ".", "No", "extra", "splitting", "or", "batching", "is", "done", "at", "this", "layer", ".", "The", "semantics", "are", "the",...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/upload.go#L194-L242
train
perkeep/perkeep
pkg/client/upload.go
readerAndSize
func (h *UploadHandle) readerAndSize() (io.Reader, int64, error) { if h.Size > 0 { return h.Contents, int64(h.Size), nil } var b bytes.Buffer n, err := io.Copy(&b, h.Contents) if err != nil { return nil, 0, err } return &b, n, nil }
go
func (h *UploadHandle) readerAndSize() (io.Reader, int64, error) { if h.Size > 0 { return h.Contents, int64(h.Size), nil } var b bytes.Buffer n, err := io.Copy(&b, h.Contents) if err != nil { return nil, 0, err } return &b, n, nil }
[ "func", "(", "h", "*", "UploadHandle", ")", "readerAndSize", "(", ")", "(", "io", ".", "Reader", ",", "int64", ",", "error", ")", "{", "if", "h", ".", "Size", ">", "0", "{", "return", "h", ".", "Contents", ",", "int64", "(", "h", ".", "Size", "...
// Figure out the size of the contents. // If the size was provided, trust it.
[ "Figure", "out", "the", "size", "of", "the", "contents", ".", "If", "the", "size", "was", "provided", "trust", "it", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/upload.go#L246-L256
train
perkeep/perkeep
pkg/search/expr.go
readInternal
func (p *parser) readInternal() *token { for t := range p.tokens { return &t } return &token{tokenEOF, "", -1} }
go
func (p *parser) readInternal() *token { for t := range p.tokens { return &t } return &token{tokenEOF, "", -1} }
[ "func", "(", "p", "*", "parser", ")", "readInternal", "(", ")", "*", "token", "{", "for", "t", ":=", "range", "p", ".", "tokens", "{", "return", "&", "t", "\n", "}", "\n", "return", "&", "token", "{", "tokenEOF", ",", "\"", "\"", ",", "-", "1",...
// ReadInternal should not be called directly, use 'next' or 'peek'
[ "ReadInternal", "should", "not", "be", "called", "directly", "use", "next", "or", "peek" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/expr.go#L109-L114
train
perkeep/perkeep
pkg/search/expr.go
atomWords
func (p *parser) atomWords() (a atom, start int, err error) { i := p.peek() start = i.start a = atom{} switch i.typ { case tokenLiteral: err = newParseExpError(noLiteralSupport, *i) return case tokenQuotedLiteral: err = newParseExpError(noQuotedLiteralSupport, *i) return case tokenColon: err = newParse...
go
func (p *parser) atomWords() (a atom, start int, err error) { i := p.peek() start = i.start a = atom{} switch i.typ { case tokenLiteral: err = newParseExpError(noLiteralSupport, *i) return case tokenQuotedLiteral: err = newParseExpError(noQuotedLiteralSupport, *i) return case tokenColon: err = newParse...
[ "func", "(", "p", "*", "parser", ")", "atomWords", "(", ")", "(", "a", "atom", ",", "start", "int", ",", "err", "error", ")", "{", "i", ":=", "p", ".", "peek", "(", ")", "\n", "start", "=", "i", ".", "start", "\n", "a", "=", "atom", "{", "}...
// AtomWords returns the parsed atom, the starting position of this // atom and an error.
[ "AtomWords", "returns", "the", "parsed", "atom", "the", "starting", "position", "of", "this", "atom", "and", "an", "error", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/expr.go#L256-L295
train
perkeep/perkeep
pkg/blobserver/mongo/mongo.go
configFromJSON
func configFromJSON(cfg jsonconfig.Obj) (config, error) { conf := config{ server: cfg.OptionalString("host", "localhost"), database: cfg.RequiredString("database"), collection: cfg.OptionalString("collection", "blobs"), user: cfg.OptionalString("user", ""), password: cfg.OptionalString("passwor...
go
func configFromJSON(cfg jsonconfig.Obj) (config, error) { conf := config{ server: cfg.OptionalString("host", "localhost"), database: cfg.RequiredString("database"), collection: cfg.OptionalString("collection", "blobs"), user: cfg.OptionalString("user", ""), password: cfg.OptionalString("passwor...
[ "func", "configFromJSON", "(", "cfg", "jsonconfig", ".", "Obj", ")", "(", "config", ",", "error", ")", "{", "conf", ":=", "config", "{", "server", ":", "cfg", ".", "OptionalString", "(", "\"", "\"", ",", "\"", "\"", ")", ",", "database", ":", "cfg", ...
// ConfigFromJSON populates Config from cfg, and validates // cfg. It returns an error if cfg fails to validate.
[ "ConfigFromJSON", "populates", "Config", "from", "cfg", "and", "validates", "cfg", ".", "It", "returns", "an", "error", "if", "cfg", "fails", "to", "validate", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/mongo/mongo.go#L119-L131
train
perkeep/perkeep
server/perkeepd/perkeepd.go
certHostname
func certHostname(listen, baseURL string) (string, error) { hostPort, err := netutil.HostPort(baseURL) if err != nil { hostPort = listen } hostname, _, err := net.SplitHostPort(hostPort) if err != nil { return "", fmt.Errorf("failed to find hostname for cert from address %q: %v", hostPort, err) } return host...
go
func certHostname(listen, baseURL string) (string, error) { hostPort, err := netutil.HostPort(baseURL) if err != nil { hostPort = listen } hostname, _, err := net.SplitHostPort(hostPort) if err != nil { return "", fmt.Errorf("failed to find hostname for cert from address %q: %v", hostPort, err) } return host...
[ "func", "certHostname", "(", "listen", ",", "baseURL", "string", ")", "(", "string", ",", "error", ")", "{", "hostPort", ",", "err", ":=", "netutil", ".", "HostPort", "(", "baseURL", ")", "\n", "if", "err", "!=", "nil", "{", "hostPort", "=", "listen", ...
// certHostname figures out the name to use for the TLS certificates, using baseURL // and falling back to the listen address if baseURL is empty or invalid.
[ "certHostname", "figures", "out", "the", "name", "to", "use", "for", "the", "TLS", "certificates", "using", "baseURL", "and", "falling", "back", "to", "the", "listen", "address", "if", "baseURL", "is", "empty", "or", "invalid", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/perkeepd.go#L352-L362
train
perkeep/perkeep
server/perkeepd/perkeepd.go
checkGeoKey
func checkGeoKey() error { if _, err := geocode.GetAPIKey(); err == nil { return nil } keyPath, err := geocode.GetAPIKeyPath() if err != nil { return fmt.Errorf("error getting Geocoding API key path: %v", err) } if env.OnGCE() { keyPath = strings.TrimPrefix(keyPath, "/gcs/") return fmt.Errorf("for locatio...
go
func checkGeoKey() error { if _, err := geocode.GetAPIKey(); err == nil { return nil } keyPath, err := geocode.GetAPIKeyPath() if err != nil { return fmt.Errorf("error getting Geocoding API key path: %v", err) } if env.OnGCE() { keyPath = strings.TrimPrefix(keyPath, "/gcs/") return fmt.Errorf("for locatio...
[ "func", "checkGeoKey", "(", ")", "error", "{", "if", "_", ",", "err", ":=", "geocode", ".", "GetAPIKey", "(", ")", ";", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "keyPath", ",", "err", ":=", "geocode", ".", "GetAPIKeyPath", "(", ")...
// checkGeoKey returns nil if we have a Google Geocoding API key file stored // in the config dir. Otherwise it returns instruction about it as the error.
[ "checkGeoKey", "returns", "nil", "if", "we", "have", "a", "Google", "Geocoding", "API", "key", "file", "stored", "in", "the", "config", "dir", ".", "Otherwise", "it", "returns", "instruction", "about", "it", "as", "the", "error", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/perkeepd.go#L375-L388
train
perkeep/perkeep
pkg/index/util.go
Dup
func (s *dupSkipper) Dup(v string) bool { if s.m == nil { s.m = make(map[string]bool) } if s.m[v] { return true } s.m[v] = true return false }
go
func (s *dupSkipper) Dup(v string) bool { if s.m == nil { s.m = make(map[string]bool) } if s.m[v] { return true } s.m[v] = true return false }
[ "func", "(", "s", "*", "dupSkipper", ")", "Dup", "(", "v", "string", ")", "bool", "{", "if", "s", ".", "m", "==", "nil", "{", "s", ".", "m", "=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "}", "\n", "if", "s", ".", "m", "...
// not thread safe.
[ "not", "thread", "safe", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/util.go#L39-L48
train
perkeep/perkeep
pkg/index/util.go
claimPtrsAttrValue
func claimPtrsAttrValue(claims []*camtypes.Claim, attr string, at time.Time, signerFilter SignerRefSet) string { return claimsIntfAttrValue(claimPtrSlice(claims), attr, at, signerFilter) }
go
func claimPtrsAttrValue(claims []*camtypes.Claim, attr string, at time.Time, signerFilter SignerRefSet) string { return claimsIntfAttrValue(claimPtrSlice(claims), attr, at, signerFilter) }
[ "func", "claimPtrsAttrValue", "(", "claims", "[", "]", "*", "camtypes", ".", "Claim", ",", "attr", "string", ",", "at", "time", ".", "Time", ",", "signerFilter", "SignerRefSet", ")", "string", "{", "return", "claimsIntfAttrValue", "(", "claimPtrSlice", "(", ...
// claimPtrsAttrValue returns the value of attr from claims, // or the empty string if not found. // Claims should be sorted by claim.Date.
[ "claimPtrsAttrValue", "returns", "the", "value", "of", "attr", "from", "claims", "or", "the", "empty", "string", "if", "not", "found", ".", "Claims", "should", "be", "sorted", "by", "claim", ".", "Date", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/util.go#L53-L55
train
perkeep/perkeep
pkg/index/util.go
claimsIntfAttrValue
func claimsIntfAttrValue(claims claimsIntf, attr string, at time.Time, signerFilter SignerRefSet) string { if claims == nil { panic("nil claims argument in claimsIntfAttrValue") } if at.IsZero() { at = time.Now() } // use a small static buffer as it speeds up // search.BenchmarkQueryPermanodeLocation by 6-7...
go
func claimsIntfAttrValue(claims claimsIntf, attr string, at time.Time, signerFilter SignerRefSet) string { if claims == nil { panic("nil claims argument in claimsIntfAttrValue") } if at.IsZero() { at = time.Now() } // use a small static buffer as it speeds up // search.BenchmarkQueryPermanodeLocation by 6-7...
[ "func", "claimsIntfAttrValue", "(", "claims", "claimsIntf", ",", "attr", "string", ",", "at", "time", ".", "Time", ",", "signerFilter", "SignerRefSet", ")", "string", "{", "if", "claims", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n"...
// claimsIntfAttrValue finds the value of an attribute in a list of claims // or empty string if not found. claims must be non-nil. // If signerFilter contains any refs, a claim is only taken into account if it // has been signed by one of the given signer refs.
[ "claimsIntfAttrValue", "finds", "the", "value", "of", "an", "attribute", "in", "a", "list", "of", "claims", "or", "empty", "string", "if", "not", "found", ".", "claims", "must", "be", "non", "-", "nil", ".", "If", "signerFilter", "contains", "any", "refs",...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/util.go#L76-L127
train
perkeep/perkeep
pkg/blobserver/blobhub.go
GetHub
func GetHub(storage interface{}) BlobHub { if h, ok := getHub(storage); ok { return h } hubmu.Lock() defer hubmu.Unlock() h, ok := stohub[storage] if ok { return h } h = new(memHub) stohub[storage] = h return h }
go
func GetHub(storage interface{}) BlobHub { if h, ok := getHub(storage); ok { return h } hubmu.Lock() defer hubmu.Unlock() h, ok := stohub[storage] if ok { return h } h = new(memHub) stohub[storage] = h return h }
[ "func", "GetHub", "(", "storage", "interface", "{", "}", ")", "BlobHub", "{", "if", "h", ",", "ok", ":=", "getHub", "(", "storage", ")", ";", "ok", "{", "return", "h", "\n", "}", "\n", "hubmu", ".", "Lock", "(", ")", "\n", "defer", "hubmu", ".", ...
// GetHub return a BlobHub for the given storage implementation.
[ "GetHub", "return", "a", "BlobHub", "for", "the", "given", "storage", "implementation", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobhub.go#L59-L72
train
perkeep/perkeep
pkg/blobserver/blobhub.go
WaitForBlob
func WaitForBlob(storage interface{}, deadline time.Time, blobs []blob.Ref) { hub := GetHub(storage) ch := make(chan blob.Ref, 1) if len(blobs) == 0 { hub.RegisterListener(ch) defer hub.UnregisterListener(ch) } for _, br := range blobs { hub.RegisterBlobListener(br, ch) defer hub.UnregisterBlobListener(br,...
go
func WaitForBlob(storage interface{}, deadline time.Time, blobs []blob.Ref) { hub := GetHub(storage) ch := make(chan blob.Ref, 1) if len(blobs) == 0 { hub.RegisterListener(ch) defer hub.UnregisterListener(ch) } for _, br := range blobs { hub.RegisterBlobListener(br, ch) defer hub.UnregisterBlobListener(br,...
[ "func", "WaitForBlob", "(", "storage", "interface", "{", "}", ",", "deadline", "time", ".", "Time", ",", "blobs", "[", "]", "blob", ".", "Ref", ")", "{", "hub", ":=", "GetHub", "(", "storage", ")", "\n", "ch", ":=", "make", "(", "chan", "blob", "."...
// WaitForBlob waits until deadline for blobs to arrive. If blobs is empty, any // blobs are waited on. Otherwise, those specific blobs are waited on. // When WaitForBlob returns, nothing may have happened.
[ "WaitForBlob", "waits", "until", "deadline", "for", "blobs", "to", "arrive", ".", "If", "blobs", "is", "empty", "any", "blobs", "are", "waited", "on", ".", "Otherwise", "those", "specific", "blobs", "are", "waited", "on", ".", "When", "WaitForBlob", "returns...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobhub.go#L87-L111
train
perkeep/perkeep
pkg/index/receive.go
indexReadyBlobs
func (ix *Index) indexReadyBlobs(ctx context.Context) { defer ix.reindexWg.Done() ix.RLock() // For tests if ix.oooDisabled { ix.RUnlock() return } ix.RUnlock() failed := make(map[blob.Ref]bool) for { ix.Lock() if len(ix.readyReindex) == 0 { ix.Unlock() return } var br blob.Ref for br = rang...
go
func (ix *Index) indexReadyBlobs(ctx context.Context) { defer ix.reindexWg.Done() ix.RLock() // For tests if ix.oooDisabled { ix.RUnlock() return } ix.RUnlock() failed := make(map[blob.Ref]bool) for { ix.Lock() if len(ix.readyReindex) == 0 { ix.Unlock() return } var br blob.Ref for br = rang...
[ "func", "(", "ix", "*", "Index", ")", "indexReadyBlobs", "(", "ctx", "context", ".", "Context", ")", "{", "defer", "ix", ".", "reindexWg", ".", "Done", "(", ")", "\n", "ix", ".", "RLock", "(", ")", "\n", "// For tests", "if", "ix", ".", "oooDisabled"...
// indexReadyBlobs indexes blobs that have been recently marked as ready to be // reindexed, after the blobs they depend on eventually were indexed.
[ "indexReadyBlobs", "indexes", "blobs", "that", "have", "been", "recently", "marked", "as", "ready", "to", "be", "reindexed", "after", "the", "blobs", "they", "depend", "on", "eventually", "were", "indexed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L132-L164
train
perkeep/perkeep
pkg/index/receive.go
noteBlobIndexed
func (ix *Index) noteBlobIndexed(br blob.Ref) { for _, needer := range ix.neededBy[br] { newNeeds := blobsFilteringOut(ix.needs[needer], br) if len(newNeeds) == 0 { ix.readyReindex[needer] = true delete(ix.needs, needer) ix.reindexWg.Add(1) go ix.indexReadyBlobs(context.Background()) } else { ix.n...
go
func (ix *Index) noteBlobIndexed(br blob.Ref) { for _, needer := range ix.neededBy[br] { newNeeds := blobsFilteringOut(ix.needs[needer], br) if len(newNeeds) == 0 { ix.readyReindex[needer] = true delete(ix.needs, needer) ix.reindexWg.Add(1) go ix.indexReadyBlobs(context.Background()) } else { ix.n...
[ "func", "(", "ix", "*", "Index", ")", "noteBlobIndexed", "(", "br", "blob", ".", "Ref", ")", "{", "for", "_", ",", "needer", ":=", "range", "ix", ".", "neededBy", "[", "br", "]", "{", "newNeeds", ":=", "blobsFilteringOut", "(", "ix", ".", "needs", ...
// noteBlobIndexed checks if the recent indexing of br now allows the blobs that // were depending on br, to be indexed in turn. If yes, they're reindexed // asynchronously by indexReadyBlobs.
[ "noteBlobIndexed", "checks", "if", "the", "recent", "indexing", "of", "br", "now", "allows", "the", "blobs", "that", "were", "depending", "on", "br", "to", "be", "indexed", "in", "turn", ".", "If", "yes", "they", "re", "reindexed", "asynchronously", "by", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L169-L182
train
perkeep/perkeep
pkg/index/receive.go
commit
func (ix *Index) commit(mm *mutationMap) error { // We want the update of the deletes cache to be atomic // with the transaction commit, so we lock here instead // of within updateDeletesCache. ix.deletes.Lock() defer ix.deletes.Unlock() bm := ix.s.BeginBatch() for k, v := range mm.kv { bm.Set(k, v) } err :=...
go
func (ix *Index) commit(mm *mutationMap) error { // We want the update of the deletes cache to be atomic // with the transaction commit, so we lock here instead // of within updateDeletesCache. ix.deletes.Lock() defer ix.deletes.Unlock() bm := ix.s.BeginBatch() for k, v := range mm.kv { bm.Set(k, v) } err :=...
[ "func", "(", "ix", "*", "Index", ")", "commit", "(", "mm", "*", "mutationMap", ")", "error", "{", "// We want the update of the deletes cache to be atomic", "// with the transaction commit, so we lock here instead", "// of within updateDeletesCache.", "ix", ".", "deletes", "....
// commit writes the contents of the mutationMap on a batch // mutation and commits that batch. It also updates the deletes // cache.
[ "commit", "writes", "the", "contents", "of", "the", "mutationMap", "on", "a", "batch", "mutation", "and", "commits", "that", "batch", ".", "It", "also", "updates", "the", "deletes", "cache", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L303-L323
train
perkeep/perkeep
pkg/index/receive.go
hasErrNotExist
func (tf *trackErrorsFetcher) hasErrNotExist() bool { tf.mu.RLock() defer tf.mu.RUnlock() if len(tf.errs) == 0 { return false } for _, v := range tf.errs { if v != os.ErrNotExist { return false } } return true }
go
func (tf *trackErrorsFetcher) hasErrNotExist() bool { tf.mu.RLock() defer tf.mu.RUnlock() if len(tf.errs) == 0 { return false } for _, v := range tf.errs { if v != os.ErrNotExist { return false } } return true }
[ "func", "(", "tf", "*", "trackErrorsFetcher", ")", "hasErrNotExist", "(", ")", "bool", "{", "tf", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "tf", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "len", "(", "tf", ".", "errs", ")", "==", ...
// hasErrNotExist reports whether tf recorded any error and if all of them are // os.ErrNotExist errors.
[ "hasErrNotExist", "reports", "whether", "tf", "recorded", "any", "error", "and", "if", "all", "of", "them", "are", "os", ".", "ErrNotExist", "errors", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L423-L435
train
perkeep/perkeep
pkg/index/receive.go
readPrefixOrFile
func readPrefixOrFile(prefix []byte, fetcher blob.Fetcher, b *schema.Blob, fn func(filePrefixReader) error) (err error) { pr := bytes.NewReader(prefix) err = fn(pr) if err == io.EOF || err == io.ErrUnexpectedEOF { var fr *schema.FileReader fr, err = b.NewFileReader(fetcher) if err == nil { err = fn(fr) f...
go
func readPrefixOrFile(prefix []byte, fetcher blob.Fetcher, b *schema.Blob, fn func(filePrefixReader) error) (err error) { pr := bytes.NewReader(prefix) err = fn(pr) if err == io.EOF || err == io.ErrUnexpectedEOF { var fr *schema.FileReader fr, err = b.NewFileReader(fetcher) if err == nil { err = fn(fr) f...
[ "func", "readPrefixOrFile", "(", "prefix", "[", "]", "byte", ",", "fetcher", "blob", ".", "Fetcher", ",", "b", "*", "schema", ".", "Blob", ",", "fn", "func", "(", "filePrefixReader", ")", "error", ")", "(", "err", "error", ")", "{", "pr", ":=", "byte...
// readPrefixOrFile executes a given func with a reader on the passed prefix and // falls back to passing a reader on the whole file if the func returns an error.
[ "readPrefixOrFile", "executes", "a", "given", "func", "with", "a", "reader", "on", "the", "passed", "prefix", "and", "falls", "back", "to", "passing", "a", "reader", "on", "the", "whole", "file", "if", "the", "func", "returns", "an", "error", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L445-L457
train
perkeep/perkeep
pkg/index/receive.go
indexMusic
func indexMusic(r readerutil.SizeReaderAt, wholeRef blob.Ref, mm *mutationMap) { tag, err := taglib.Decode(r, r.Size()) if err != nil { log.Print("index: error parsing tag: ", err) return } var footerLength int64 = 0 if hasTag, err := media.HasID3v1Tag(r); err != nil { log.Print("index: unable to check for ...
go
func indexMusic(r readerutil.SizeReaderAt, wholeRef blob.Ref, mm *mutationMap) { tag, err := taglib.Decode(r, r.Size()) if err != nil { log.Print("index: error parsing tag: ", err) return } var footerLength int64 = 0 if hasTag, err := media.HasID3v1Tag(r); err != nil { log.Print("index: unable to check for ...
[ "func", "indexMusic", "(", "r", "readerutil", ".", "SizeReaderAt", ",", "wholeRef", "blob", ".", "Ref", ",", "mm", "*", "mutationMap", ")", "{", "tag", ",", "err", ":=", "taglib", ".", "Decode", "(", "r", ",", "r", ".", "Size", "(", ")", ")", "\n",...
// indexMusic adds mutations to index the wholeRef by attached metadata and other properties.
[ "indexMusic", "adds", "mutations", "to", "index", "the", "wholeRef", "by", "attached", "metadata", "and", "other", "properties", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L707-L773
train
perkeep/perkeep
pkg/index/receive.go
populateDeleteClaim
func (ix *Index) populateDeleteClaim(ctx context.Context, cl schema.Claim, vr *jsonsign.VerifyRequest, mm *mutationMap) error { br := cl.Blob().BlobRef() target := cl.Target() if !target.Valid() { log.Print(fmt.Errorf("no valid target for delete claim %v", br)) return nil } meta, err := ix.GetBlobMeta(ctx, tar...
go
func (ix *Index) populateDeleteClaim(ctx context.Context, cl schema.Claim, vr *jsonsign.VerifyRequest, mm *mutationMap) error { br := cl.Blob().BlobRef() target := cl.Target() if !target.Valid() { log.Print(fmt.Errorf("no valid target for delete claim %v", br)) return nil } meta, err := ix.GetBlobMeta(ctx, tar...
[ "func", "(", "ix", "*", "Index", ")", "populateDeleteClaim", "(", "ctx", "context", ".", "Context", ",", "cl", "schema", ".", "Claim", ",", "vr", "*", "jsonsign", ".", "VerifyRequest", ",", "mm", "*", "mutationMap", ")", "error", "{", "br", ":=", "cl",...
// populateDeleteClaim adds to mm the entries resulting from the delete claim cl. // It is assumed cl is a valid claim, and vr has already been verified.
[ "populateDeleteClaim", "adds", "to", "mm", "the", "entries", "resulting", "from", "the", "delete", "claim", "cl", ".", "It", "is", "assumed", "cl", "is", "a", "valid", "claim", "and", "vr", "has", "already", "been", "verified", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L811-L846
train
perkeep/perkeep
pkg/index/receive.go
updateDeletesCache
func (ix *Index) updateDeletesCache(deleteClaim schema.Claim) error { target := deleteClaim.Target() deleter := deleteClaim.Blob() when, err := deleter.ClaimDate() if err != nil { return fmt.Errorf("Could not get date of delete claim %v: %v", deleteClaim, err) } targetDeletions := append(ix.deletes.m[target], ...
go
func (ix *Index) updateDeletesCache(deleteClaim schema.Claim) error { target := deleteClaim.Target() deleter := deleteClaim.Blob() when, err := deleter.ClaimDate() if err != nil { return fmt.Errorf("Could not get date of delete claim %v: %v", deleteClaim, err) } targetDeletions := append(ix.deletes.m[target], ...
[ "func", "(", "ix", "*", "Index", ")", "updateDeletesCache", "(", "deleteClaim", "schema", ".", "Claim", ")", "error", "{", "target", ":=", "deleteClaim", ".", "Target", "(", ")", "\n", "deleter", ":=", "deleteClaim", ".", "Blob", "(", ")", "\n", "when", ...
// updateDeletesCache updates the index deletes cache with the cl delete claim. // deleteClaim is trusted to be a valid delete Claim.
[ "updateDeletesCache", "updates", "the", "index", "deletes", "cache", "with", "the", "cl", "delete", "claim", ".", "deleteClaim", "is", "trusted", "to", "be", "a", "valid", "delete", "Claim", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/receive.go#L937-L952
train
perkeep/perkeep
cmd/pk-devimport/devimport.go
getCredentials
func getCredentials(sh search.QueryDescriber, importerType string) (string, string, error) { var clientID, clientSecret string res, err := sh.Query(context.TODO(), &search.SearchQuery{ Expression: "attr:camliNodeType:importer and attr:importerType:" + importerType, Describe: &search.DescribeRequest{ Depth: 1, ...
go
func getCredentials(sh search.QueryDescriber, importerType string) (string, string, error) { var clientID, clientSecret string res, err := sh.Query(context.TODO(), &search.SearchQuery{ Expression: "attr:camliNodeType:importer and attr:importerType:" + importerType, Describe: &search.DescribeRequest{ Depth: 1, ...
[ "func", "getCredentials", "(", "sh", "search", ".", "QueryDescriber", ",", "importerType", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "var", "clientID", ",", "clientSecret", "string", "\n", "res", ",", "err", ":=", "sh", ".", "Q...
// getCredentials returns the OAuth clientID and clientSecret found in the // importer node of the given importerType.
[ "getCredentials", "returns", "the", "OAuth", "clientID", "and", "clientSecret", "found", "in", "the", "importer", "node", "of", "the", "given", "importerType", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk-devimport/devimport.go#L112-L154
train
perkeep/perkeep
pkg/schema/filewriter.go
WriteFileFromReaderWithModTime
func WriteFileFromReaderWithModTime(ctx context.Context, bs blobserver.StatReceiver, filename string, modTime time.Time, r io.Reader) (blob.Ref, error) { if strings.Contains(filename, "/") { return blob.Ref{}, fmt.Errorf("schema.WriteFileFromReader: filename %q shouldn't contain a slash", filename) } m := NewFile...
go
func WriteFileFromReaderWithModTime(ctx context.Context, bs blobserver.StatReceiver, filename string, modTime time.Time, r io.Reader) (blob.Ref, error) { if strings.Contains(filename, "/") { return blob.Ref{}, fmt.Errorf("schema.WriteFileFromReader: filename %q shouldn't contain a slash", filename) } m := NewFile...
[ "func", "WriteFileFromReaderWithModTime", "(", "ctx", "context", ".", "Context", ",", "bs", "blobserver", ".", "StatReceiver", ",", "filename", "string", ",", "modTime", "time", ".", "Time", ",", "r", "io", ".", "Reader", ")", "(", "blob", ".", "Ref", ",",...
// WriteFileFromReaderWithModTime creates and uploads a "file" JSON schema // composed of chunks of r, also uploading the chunks. The returned // BlobRef is of the JSON file schema blob. // Both filename and modTime are optional.
[ "WriteFileFromReaderWithModTime", "creates", "and", "uploads", "a", "file", "JSON", "schema", "composed", "of", "chunks", "of", "r", "also", "uploading", "the", "chunks", ".", "The", "returned", "BlobRef", "is", "of", "the", "JSON", "file", "schema", "blob", "...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/filewriter.go#L69-L79
train
perkeep/perkeep
pkg/schema/filewriter.go
WriteFileFromReader
func WriteFileFromReader(ctx context.Context, bs blobserver.StatReceiver, filename string, r io.Reader) (blob.Ref, error) { return WriteFileFromReaderWithModTime(ctx, bs, filename, time.Time{}, r) }
go
func WriteFileFromReader(ctx context.Context, bs blobserver.StatReceiver, filename string, r io.Reader) (blob.Ref, error) { return WriteFileFromReaderWithModTime(ctx, bs, filename, time.Time{}, r) }
[ "func", "WriteFileFromReader", "(", "ctx", "context", ".", "Context", ",", "bs", "blobserver", ".", "StatReceiver", ",", "filename", "string", ",", "r", "io", ".", "Reader", ")", "(", "blob", ".", "Ref", ",", "error", ")", "{", "return", "WriteFileFromRead...
// WriteFileFromReader creates and uploads a "file" JSON schema // composed of chunks of r, also uploading the chunks. The returned // BlobRef is of the JSON file schema blob. // The filename is optional.
[ "WriteFileFromReader", "creates", "and", "uploads", "a", "file", "JSON", "schema", "composed", "of", "chunks", "of", "r", "also", "uploading", "the", "chunks", ".", "The", "returned", "BlobRef", "is", "of", "the", "JSON", "file", "schema", "blob", ".", "The"...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/filewriter.go#L85-L87
train
perkeep/perkeep
pkg/schema/filewriter.go
WriteFileMap
func WriteFileMap(ctx context.Context, bs blobserver.StatReceiver, file *Builder, r io.Reader) (blob.Ref, error) { return writeFileMapRolling(ctx, bs, file, r) }
go
func WriteFileMap(ctx context.Context, bs blobserver.StatReceiver, file *Builder, r io.Reader) (blob.Ref, error) { return writeFileMapRolling(ctx, bs, file, r) }
[ "func", "WriteFileMap", "(", "ctx", "context", ".", "Context", ",", "bs", "blobserver", ".", "StatReceiver", ",", "file", "*", "Builder", ",", "r", "io", ".", "Reader", ")", "(", "blob", ".", "Ref", ",", "error", ")", "{", "return", "writeFileMapRolling"...
// WriteFileMap uploads chunks of r to bs while populating file and // finally uploading file's Blob. The returned blobref is of file's // JSON blob.
[ "WriteFileMap", "uploads", "chunks", "of", "r", "to", "bs", "while", "populating", "file", "and", "finally", "uploading", "file", "s", "Blob", ".", "The", "returned", "blobref", "is", "of", "file", "s", "JSON", "blob", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/filewriter.go#L92-L94
train
perkeep/perkeep
pkg/schema/filewriter.go
Get
func (f *uploadBytesFuture) Get() (blob.Ref, error) { for _, f := range f.children { if _, err := f.Get(); err != nil { return blob.Ref{}, err } } return f.br, <-f.errc }
go
func (f *uploadBytesFuture) Get() (blob.Ref, error) { for _, f := range f.children { if _, err := f.Get(); err != nil { return blob.Ref{}, err } } return f.br, <-f.errc }
[ "func", "(", "f", "*", "uploadBytesFuture", ")", "Get", "(", ")", "(", "blob", ".", "Ref", ",", "error", ")", "{", "for", "_", ",", "f", ":=", "range", "f", ".", "children", "{", "if", "_", ",", "err", ":=", "f", ".", "Get", "(", ")", ";", ...
// Get blocks for all children and returns any final error.
[ "Get", "blocks", "for", "all", "children", "and", "returns", "any", "final", "error", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/filewriter.go#L216-L223
train
perkeep/perkeep
pkg/schema/filewriter.go
writeFileMapRolling
func writeFileMapRolling(ctx context.Context, bs blobserver.StatReceiver, file *Builder, r io.Reader) (blob.Ref, error) { n, spans, err := writeFileChunks(ctx, bs, file, r) if err != nil { return blob.Ref{}, err } // The top-level content parts return uploadBytes(ctx, bs, file, n, spans).Get() }
go
func writeFileMapRolling(ctx context.Context, bs blobserver.StatReceiver, file *Builder, r io.Reader) (blob.Ref, error) { n, spans, err := writeFileChunks(ctx, bs, file, r) if err != nil { return blob.Ref{}, err } // The top-level content parts return uploadBytes(ctx, bs, file, n, spans).Get() }
[ "func", "writeFileMapRolling", "(", "ctx", "context", ".", "Context", ",", "bs", "blobserver", ".", "StatReceiver", ",", "file", "*", "Builder", ",", "r", "io", ".", "Reader", ")", "(", "blob", ".", "Ref", ",", "error", ")", "{", "n", ",", "spans", "...
// writeFileMap uploads chunks of r to bs while populating fileMap and // finally uploading fileMap. The returned blobref is of fileMap's // JSON blob. It uses rolling checksum for the chunks sizes.
[ "writeFileMap", "uploads", "chunks", "of", "r", "to", "bs", "while", "populating", "fileMap", "and", "finally", "uploading", "fileMap", ".", "The", "returned", "blobref", "is", "of", "fileMap", "s", "JSON", "blob", ".", "It", "uses", "rolling", "checksum", "...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/filewriter.go#L265-L272
train
perkeep/perkeep
pkg/schema/filewriter.go
WriteFileChunks
func WriteFileChunks(ctx context.Context, bs blobserver.StatReceiver, file *Builder, r io.Reader) error { size, spans, err := writeFileChunks(ctx, bs, file, r) if err != nil { return err } parts := []BytesPart{} future := newUploadBytesFuture() addBytesParts(ctx, bs, &parts, spans, future) future.errc <- nil /...
go
func WriteFileChunks(ctx context.Context, bs blobserver.StatReceiver, file *Builder, r io.Reader) error { size, spans, err := writeFileChunks(ctx, bs, file, r) if err != nil { return err } parts := []BytesPart{} future := newUploadBytesFuture() addBytesParts(ctx, bs, &parts, spans, future) future.errc <- nil /...
[ "func", "WriteFileChunks", "(", "ctx", "context", ".", "Context", ",", "bs", "blobserver", ".", "StatReceiver", ",", "file", "*", "Builder", ",", "r", "io", ".", "Reader", ")", "error", "{", "size", ",", "spans", ",", "err", ":=", "writeFileChunks", "(",...
// WriteFileChunks uploads chunks of r to bs while populating file. // It does not upload file.
[ "WriteFileChunks", "uploads", "chunks", "of", "r", "to", "bs", "while", "populating", "file", ".", "It", "does", "not", "upload", "file", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/filewriter.go#L276-L289
train
perkeep/perkeep
internal/pools/pools.go
BytesBuffer
func BytesBuffer() *bytes.Buffer { buf := bytesBuffer.Get().(*bytes.Buffer) buf.Reset() return buf }
go
func BytesBuffer() *bytes.Buffer { buf := bytesBuffer.Get().(*bytes.Buffer) buf.Reset() return buf }
[ "func", "BytesBuffer", "(", ")", "*", "bytes", ".", "Buffer", "{", "buf", ":=", "bytesBuffer", ".", "Get", "(", ")", ".", "(", "*", "bytes", ".", "Buffer", ")", "\n", "buf", ".", "Reset", "(", ")", "\n", "return", "buf", "\n", "}" ]
// BytesBuffer returns an empty bytes.Buffer. // It should be returned with PutBuffer.
[ "BytesBuffer", "returns", "an", "empty", "bytes", ".", "Buffer", ".", "It", "should", "be", "returned", "with", "PutBuffer", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/pools/pools.go#L32-L36
train
perkeep/perkeep
pkg/auth/auth.go
RegisterAuth
func RegisterAuth(name string, ctor AuthConfigParser) { if _, dup := authConstructor[name]; dup { panic("Dup registration of auth mode " + name) } authConstructor[name] = ctor }
go
func RegisterAuth(name string, ctor AuthConfigParser) { if _, dup := authConstructor[name]; dup { panic("Dup registration of auth mode " + name) } authConstructor[name] = ctor }
[ "func", "RegisterAuth", "(", "name", "string", ",", "ctor", "AuthConfigParser", ")", "{", "if", "_", ",", "dup", ":=", "authConstructor", "[", "name", "]", ";", "dup", "{", "panic", "(", "\"", "\"", "+", "name", ")", "\n", "}", "\n", "authConstructor",...
// RegisterAuth registers a new authentication scheme.
[ "RegisterAuth", "registers", "a", "new", "authentication", "scheme", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L100-L105
train
perkeep/perkeep
pkg/auth/auth.go
NewBasicAuth
func NewBasicAuth(username, password string) AuthMode { return &UserPass{ Username: username, Password: password, } }
go
func NewBasicAuth(username, password string) AuthMode { return &UserPass{ Username: username, Password: password, } }
[ "func", "NewBasicAuth", "(", "username", ",", "password", "string", ")", "AuthMode", "{", "return", "&", "UserPass", "{", "Username", ":", "username", ",", "Password", ":", "password", ",", "}", "\n", "}" ]
// NewBasicAuth returns a UserPass Authmode, adequate to support HTTP // basic authentication.
[ "NewBasicAuth", "returns", "a", "UserPass", "Authmode", "adequate", "to", "support", "HTTP", "basic", "authentication", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L157-L162
train
perkeep/perkeep
pkg/auth/auth.go
AllowedWithAuth
func AllowedWithAuth(am AuthMode, req *http.Request, op Operation) bool { if op&OpUpload != 0 { // upload (at least from pk-put) requires stat and get too op = op | OpVivify } return am.AllowedAccess(req)&op == op }
go
func AllowedWithAuth(am AuthMode, req *http.Request, op Operation) bool { if op&OpUpload != 0 { // upload (at least from pk-put) requires stat and get too op = op | OpVivify } return am.AllowedAccess(req)&op == op }
[ "func", "AllowedWithAuth", "(", "am", "AuthMode", ",", "req", "*", "http", ".", "Request", ",", "op", "Operation", ")", "bool", "{", "if", "op", "&", "OpUpload", "!=", "0", "{", "// upload (at least from pk-put) requires stat and get too", "op", "=", "op", "|"...
// AllowedWithAuth returns whether the given request // has access to perform all the operations in op // against am.
[ "AllowedWithAuth", "returns", "whether", "the", "given", "request", "has", "access", "to", "perform", "all", "the", "operations", "in", "op", "against", "am", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L341-L347
train
perkeep/perkeep
pkg/auth/auth.go
Allowed
func Allowed(req *http.Request, op Operation) bool { for _, m := range modes { if AllowedWithAuth(m, req, op) { return true } } return false }
go
func Allowed(req *http.Request, op Operation) bool { for _, m := range modes { if AllowedWithAuth(m, req, op) { return true } } return false }
[ "func", "Allowed", "(", "req", "*", "http", ".", "Request", ",", "op", "Operation", ")", "bool", "{", "for", "_", ",", "m", ":=", "range", "modes", "{", "if", "AllowedWithAuth", "(", "m", ",", "req", ",", "op", ")", "{", "return", "true", "\n", "...
// Allowed returns whether the given request // has access to perform all the operations in op.
[ "Allowed", "returns", "whether", "the", "given", "request", "has", "access", "to", "perform", "all", "the", "operations", "in", "op", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L351-L358
train
perkeep/perkeep
pkg/auth/auth.go
ServeHTTP
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.serveHTTPForOp(w, r, OpAll) }
go
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.serveHTTPForOp(w, r, OpAll) }
[ "func", "(", "h", "Handler", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "h", ".", "serveHTTPForOp", "(", "w", ",", "r", ",", "OpAll", ")", "\n", "}" ]
// ServeHTTP serves only if this request and auth mode are allowed all Operations.
[ "ServeHTTP", "serves", "only", "if", "this", "request", "and", "auth", "mode", "are", "allowed", "all", "Operations", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L418-L420
train
perkeep/perkeep
pkg/auth/auth.go
serveHTTPForOp
func (h Handler) serveHTTPForOp(w http.ResponseWriter, r *http.Request, op Operation) { if Allowed(r, op) { h.Handler.ServeHTTP(w, r) } else { SendUnauthorized(w, r) } }
go
func (h Handler) serveHTTPForOp(w http.ResponseWriter, r *http.Request, op Operation) { if Allowed(r, op) { h.Handler.ServeHTTP(w, r) } else { SendUnauthorized(w, r) } }
[ "func", "(", "h", "Handler", ")", "serveHTTPForOp", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "op", "Operation", ")", "{", "if", "Allowed", "(", "r", ",", "op", ")", "{", "h", ".", "Handler", ".", "ServeHT...
// serveHTTPForOp serves only if op is allowed for this request and auth mode.
[ "serveHTTPForOp", "serves", "only", "if", "op", "is", "allowed", "for", "this", "request", "and", "auth", "mode", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L423-L429
train
perkeep/perkeep
pkg/auth/auth.go
RequireAuth
func RequireAuth(h http.Handler, op Operation) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { if Allowed(req, op) { h.ServeHTTP(rw, req) } else { SendUnauthorized(rw, req) } }) }
go
func RequireAuth(h http.Handler, op Operation) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { if Allowed(req, op) { h.ServeHTTP(rw, req) } else { SendUnauthorized(rw, req) } }) }
[ "func", "RequireAuth", "(", "h", "http", ".", "Handler", ",", "op", "Operation", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")"...
// RequireAuth wraps a function with another function that enforces // HTTP Basic Auth and checks if the operations in op are all permitted.
[ "RequireAuth", "wraps", "a", "function", "with", "another", "function", "that", "enforces", "HTTP", "Basic", "Auth", "and", "checks", "if", "the", "operations", "in", "op", "are", "all", "permitted", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L433-L441
train
perkeep/perkeep
pkg/auth/auth.go
TokenOrNone
func TokenOrNone(token string) (AuthMode, error) { if token == OmitAuthToken { return None{}, nil } return NewTokenAuth(token) }
go
func TokenOrNone(token string) (AuthMode, error) { if token == OmitAuthToken { return None{}, nil } return NewTokenAuth(token) }
[ "func", "TokenOrNone", "(", "token", "string", ")", "(", "AuthMode", ",", "error", ")", "{", "if", "token", "==", "OmitAuthToken", "{", "return", "None", "{", "}", ",", "nil", "\n", "}", "\n", "return", "NewTokenAuth", "(", "token", ")", "\n", "}" ]
// TokenOrNone returns a token auth mode if token is not OmitAuthToken, and // otherwise a None auth mode.
[ "TokenOrNone", "returns", "a", "token", "auth", "mode", "if", "token", "is", "not", "OmitAuthToken", "and", "otherwise", "a", "None", "auth", "mode", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/auth/auth.go#L470-L475
train
perkeep/perkeep
pkg/index/corpus.go
blobMatches
func (srs SignerRefSet) blobMatches(br blob.Ref) bool { for _, v := range srs { if br.EqualString(v) { return true } } return false }
go
func (srs SignerRefSet) blobMatches(br blob.Ref) bool { for _, v := range srs { if br.EqualString(v) { return true } } return false }
[ "func", "(", "srs", "SignerRefSet", ")", "blobMatches", "(", "br", "blob", ".", "Ref", ")", "bool", "{", "for", "_", ",", "v", ":=", "range", "srs", "{", "if", "br", ".", "EqualString", "(", "v", ")", "{", "return", "true", "\n", "}", "\n", "}", ...
// blobMatches reports whether br is in the set.
[ "blobMatches", "reports", "whether", "br", "is", "in", "the", "set", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L127-L134
train
perkeep/perkeep
pkg/index/corpus.go
cacheAttrClaim
func (m attrValues) cacheAttrClaim(cl *camtypes.Claim) { switch cl.Type { case string(schema.SetAttributeClaim): m[cl.Attr] = []string{cl.Value} case string(schema.AddAttributeClaim): m[cl.Attr] = append(m[cl.Attr], cl.Value) case string(schema.DelAttributeClaim): if cl.Value == "" { delete(m, cl.Attr) }...
go
func (m attrValues) cacheAttrClaim(cl *camtypes.Claim) { switch cl.Type { case string(schema.SetAttributeClaim): m[cl.Attr] = []string{cl.Value} case string(schema.AddAttributeClaim): m[cl.Attr] = append(m[cl.Attr], cl.Value) case string(schema.DelAttributeClaim): if cl.Value == "" { delete(m, cl.Attr) }...
[ "func", "(", "m", "attrValues", ")", "cacheAttrClaim", "(", "cl", "*", "camtypes", ".", "Claim", ")", "{", "switch", "cl", ".", "Type", "{", "case", "string", "(", "schema", ".", "SetAttributeClaim", ")", ":", "m", "[", "cl", ".", "Attr", "]", "=", ...
// cacheAttrClaim applies attribute changes from cl.
[ "cacheAttrClaim", "applies", "attribute", "changes", "from", "cl", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L172-L192
train
perkeep/perkeep
pkg/index/corpus.go
restoreInvariants
func (pm *PermanodeMeta) restoreInvariants(signers signerFromBlobrefMap) error { sort.Sort(camtypes.ClaimPtrsByDate(pm.Claims)) pm.attr = make(attrValues) pm.signer = make(map[string]attrValues) for _, cl := range pm.Claims { if err := pm.appendAttrClaim(cl, signers); err != nil { return err } } return nil...
go
func (pm *PermanodeMeta) restoreInvariants(signers signerFromBlobrefMap) error { sort.Sort(camtypes.ClaimPtrsByDate(pm.Claims)) pm.attr = make(attrValues) pm.signer = make(map[string]attrValues) for _, cl := range pm.Claims { if err := pm.appendAttrClaim(cl, signers); err != nil { return err } } return nil...
[ "func", "(", "pm", "*", "PermanodeMeta", ")", "restoreInvariants", "(", "signers", "signerFromBlobrefMap", ")", "error", "{", "sort", ".", "Sort", "(", "camtypes", ".", "ClaimPtrsByDate", "(", "pm", ".", "Claims", ")", ")", "\n", "pm", ".", "attr", "=", ...
// restoreInvariants sorts claims by date and // recalculates latest attributes.
[ "restoreInvariants", "sorts", "claims", "by", "date", "and", "recalculates", "latest", "attributes", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L196-L206
train
perkeep/perkeep
pkg/index/corpus.go
fixupLastClaim
func (pm *PermanodeMeta) fixupLastClaim(signers signerFromBlobrefMap) error { if pm.attr != nil { n := len(pm.Claims) if n < 2 || camtypes.ClaimPtrsByDate(pm.Claims).Less(n-2, n-1) { // already sorted, update Attrs from new Claim return pm.appendAttrClaim(pm.Claims[n-1], signers) } } return pm.restoreInv...
go
func (pm *PermanodeMeta) fixupLastClaim(signers signerFromBlobrefMap) error { if pm.attr != nil { n := len(pm.Claims) if n < 2 || camtypes.ClaimPtrsByDate(pm.Claims).Less(n-2, n-1) { // already sorted, update Attrs from new Claim return pm.appendAttrClaim(pm.Claims[n-1], signers) } } return pm.restoreInv...
[ "func", "(", "pm", "*", "PermanodeMeta", ")", "fixupLastClaim", "(", "signers", "signerFromBlobrefMap", ")", "error", "{", "if", "pm", ".", "attr", "!=", "nil", "{", "n", ":=", "len", "(", "pm", ".", "Claims", ")", "\n", "if", "n", "<", "2", "||", ...
// fixupLastClaim fixes invariants on the assumption // that the all but the last element in Claims are sorted by date // and the last element is the only one not yet included in Attrs.
[ "fixupLastClaim", "fixes", "invariants", "on", "the", "assumption", "that", "the", "all", "but", "the", "last", "element", "in", "Claims", "are", "sorted", "by", "date", "and", "the", "last", "element", "is", "the", "only", "one", "not", "yet", "included", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L211-L220
train
perkeep/perkeep
pkg/index/corpus.go
initDeletes
func (c *Corpus) initDeletes(s sorted.KeyValue) (err error) { it := queryPrefix(s, keyDeleted) defer closeIterator(it, &err) for it.Next() { cl, ok := kvDeleted(it.Key()) if !ok { return fmt.Errorf("Bogus keyDeleted entry key: want |\"deleted\"|<deleted blobref>|<reverse claimdate>|<deleter claim>|, got %q", ...
go
func (c *Corpus) initDeletes(s sorted.KeyValue) (err error) { it := queryPrefix(s, keyDeleted) defer closeIterator(it, &err) for it.Next() { cl, ok := kvDeleted(it.Key()) if !ok { return fmt.Errorf("Bogus keyDeleted entry key: want |\"deleted\"|<deleted blobref>|<reverse claimdate>|<deleter claim>|, got %q", ...
[ "func", "(", "c", "*", "Corpus", ")", "initDeletes", "(", "s", "sorted", ".", "KeyValue", ")", "(", "err", "error", ")", "{", "it", ":=", "queryPrefix", "(", "s", ",", "keyDeleted", ")", "\n", "defer", "closeIterator", "(", "it", ",", "&", "err", "...
// initDeletes populates the corpus deletes from the delete entries in s.
[ "initDeletes", "populates", "the", "corpus", "deletes", "from", "the", "delete", "entries", "in", "s", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L528-L545
train
perkeep/perkeep
pkg/index/corpus.go
updateDeletes
func (c *Corpus) updateDeletes(deleteClaim schema.Claim) error { target := c.br(deleteClaim.Target()) deleter := deleteClaim.Blob() when, err := deleter.ClaimDate() if err != nil { return fmt.Errorf("Could not get date of delete claim %v: %v", deleteClaim, err) } del := deletion{ deleter: c.br(deleter.BlobRef...
go
func (c *Corpus) updateDeletes(deleteClaim schema.Claim) error { target := c.br(deleteClaim.Target()) deleter := deleteClaim.Blob() when, err := deleter.ClaimDate() if err != nil { return fmt.Errorf("Could not get date of delete claim %v: %v", deleteClaim, err) } del := deletion{ deleter: c.br(deleter.BlobRef...
[ "func", "(", "c", "*", "Corpus", ")", "updateDeletes", "(", "deleteClaim", "schema", ".", "Claim", ")", "error", "{", "target", ":=", "c", ".", "br", "(", "deleteClaim", ".", "Target", "(", ")", ")", "\n", "deleter", ":=", "deleteClaim", ".", "Blob", ...
// updateDeletes updates the corpus deletes with the delete claim deleteClaim. // deleteClaim is trusted to be a valid delete Claim.
[ "updateDeletes", "updates", "the", "corpus", "deletes", "with", "the", "delete", "claim", "deleteClaim", ".", "deleteClaim", "is", "trusted", "to", "be", "a", "valid", "delete", "Claim", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L644-L664
train
perkeep/perkeep
pkg/index/corpus.go
mergeWholeToFileRow
func (c *Corpus) mergeWholeToFileRow(k, v []byte) error { pair := k[len("wholetofile|"):] pipe := bytes.IndexByte(pair, '|') if pipe < 0 { return fmt.Errorf("bogus row %q = %q", k, v) } wholeRef, ok1 := blob.ParseBytes(pair[:pipe]) fileRef, ok2 := blob.ParseBytes(pair[pipe+1:]) if !ok1 || !ok2 { return fmt.E...
go
func (c *Corpus) mergeWholeToFileRow(k, v []byte) error { pair := k[len("wholetofile|"):] pipe := bytes.IndexByte(pair, '|') if pipe < 0 { return fmt.Errorf("bogus row %q = %q", k, v) } wholeRef, ok1 := blob.ParseBytes(pair[:pipe]) fileRef, ok2 := blob.ParseBytes(pair[pipe+1:]) if !ok1 || !ok2 { return fmt.E...
[ "func", "(", "c", "*", "Corpus", ")", "mergeWholeToFileRow", "(", "k", ",", "v", "[", "]", "byte", ")", "error", "{", "pair", ":=", "k", "[", "len", "(", "\"", "\"", ")", ":", "]", "\n", "pipe", ":=", "bytes", ".", "IndexByte", "(", "pair", ","...
// "wholetofile|sha1-17b53c7c3e664d3613dfdce50ef1f2a09e8f04b5|sha1-fb88f3eab3acfcf3cfc8cd77ae4366f6f975d227" -> "1"
[ "wholetofile|sha1", "-", "17b53c7c3e664d3613dfdce50ef1f2a09e8f04b5|sha1", "-", "fb88f3eab3acfcf3cfc8cd77ae4366f6f975d227", "-", ">", "1" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L854-L872
train
perkeep/perkeep
pkg/index/corpus.go
mergeMediaTag
func (c *Corpus) mergeMediaTag(k, v []byte) error { f := strings.Split(string(k), "|") if len(f) != 3 { return fmt.Errorf("unexpected key %q", k) } wholeRef, ok := blob.Parse(f[1]) if !ok { return fmt.Errorf("failed to parse wholeref from key %q", k) } tm, ok := c.mediaTags[wholeRef] if !ok { tm = make(ma...
go
func (c *Corpus) mergeMediaTag(k, v []byte) error { f := strings.Split(string(k), "|") if len(f) != 3 { return fmt.Errorf("unexpected key %q", k) } wholeRef, ok := blob.Parse(f[1]) if !ok { return fmt.Errorf("failed to parse wholeref from key %q", k) } tm, ok := c.mediaTags[wholeRef] if !ok { tm = make(ma...
[ "func", "(", "c", "*", "Corpus", ")", "mergeMediaTag", "(", "k", ",", "v", "[", "]", "byte", ")", "error", "{", "f", ":=", "strings", ".", "Split", "(", "string", "(", "k", ")", ",", "\"", "\"", ")", "\n", "if", "len", "(", "f", ")", "!=", ...
// "mediatag|sha1-2b219be9d9691b4f8090e7ee2690098097f59566|album" = "Some+Album+Name"
[ "mediatag|sha1", "-", "2b219be9d9691b4f8090e7ee2690098097f59566|album", "=", "Some", "+", "Album", "+", "Name" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L875-L891
train
perkeep/perkeep
pkg/index/corpus.go
mergeEXIFGPSRow
func (c *Corpus) mergeEXIFGPSRow(k, v []byte) error { wholeRef, ok := blob.ParseBytes(k[len("exifgps|"):]) pipe := bytes.IndexByte(v, '|') if pipe < 0 || !ok { return fmt.Errorf("bogus row %q = %q", k, v) } lat, err := strconv.ParseFloat(string(v[:pipe]), 64) long, err1 := strconv.ParseFloat(string(v[pipe+1:]),...
go
func (c *Corpus) mergeEXIFGPSRow(k, v []byte) error { wholeRef, ok := blob.ParseBytes(k[len("exifgps|"):]) pipe := bytes.IndexByte(v, '|') if pipe < 0 || !ok { return fmt.Errorf("bogus row %q = %q", k, v) } lat, err := strconv.ParseFloat(string(v[:pipe]), 64) long, err1 := strconv.ParseFloat(string(v[pipe+1:]),...
[ "func", "(", "c", "*", "Corpus", ")", "mergeEXIFGPSRow", "(", "k", ",", "v", "[", "]", "byte", ")", "error", "{", "wholeRef", ",", "ok", ":=", "blob", ".", "ParseBytes", "(", "k", "[", "len", "(", "\"", "\"", ")", ":", "]", ")", "\n", "pipe", ...
// "exifgps|sha1-17b53c7c3e664d3613dfdce50ef1f2a09e8f04b5" -> "-122.39897155555556|37.61952208333334"
[ "exifgps|sha1", "-", "17b53c7c3e664d3613dfdce50ef1f2a09e8f04b5", "-", ">", "-", "122", ".", "39897155555556|37", ".", "61952208333334" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/corpus.go#L894-L912
train