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
pkg/sorted/mysql/mysqlkv.go
CreateDB
func CreateDB(db *sql.DB, dbname string) error { if dbname == "" { return errors.New("can not create database: database name is missing") } if _, err := db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", dbname)); err != nil { return fmt.Errorf("error creating database %v: %v", dbname, err) } return nil }
go
func CreateDB(db *sql.DB, dbname string) error { if dbname == "" { return errors.New("can not create database: database name is missing") } if _, err := db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", dbname)); err != nil { return fmt.Errorf("error creating database %v: %v", dbname, err) } return nil }
[ "func", "CreateDB", "(", "db", "*", "sql", ".", "DB", ",", "dbname", "string", ")", "error", "{", "if", "dbname", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "_", ",", "err", ":=", "db", ...
// CreateDB creates the named database if it does not already exist.
[ "CreateDB", "creates", "the", "named", "database", "if", "it", "does", "not", "already", "exist", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mysql/mysqlkv.go#L164-L172
train
perkeep/perkeep
pkg/sorted/mysql/mysqlkv.go
Close
func (kv *keyValue) Close() error { dbsmu.Lock() defer dbsmu.Unlock() delete(dbs, kv.dsn) return kv.DB.Close() }
go
func (kv *keyValue) Close() error { dbsmu.Lock() defer dbsmu.Unlock() delete(dbs, kv.dsn) return kv.DB.Close() }
[ "func", "(", "kv", "*", "keyValue", ")", "Close", "(", ")", "error", "{", "dbsmu", ".", "Lock", "(", ")", "\n", "defer", "dbsmu", ".", "Unlock", "(", ")", "\n", "delete", "(", "dbs", ",", "kv", ".", "dsn", ")", "\n", "return", "kv", ".", "DB", ...
// Close overrides KeyValue.Close because we need to remove the DB from the pool // when closing.
[ "Close", "overrides", "KeyValue", ".", "Close", "because", "we", "need", "to", "remove", "the", "DB", "from", "the", "pool", "when", "closing", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mysql/mysqlkv.go#L223-L228
train
perkeep/perkeep
website/pk-web/email.go
emailOnTimeout
func emailOnTimeout(fnName string, d time.Duration, fn func() error) error { c := make(chan error, 1) go func() { c <- fn() }() select { case <-time.After(d): log.Printf("timeout for %s, sending e-mail about it", fnName) m := mailGun.NewMessage( "noreply@perkeep.org", "timeout for docker on pk-web", ...
go
func emailOnTimeout(fnName string, d time.Duration, fn func() error) error { c := make(chan error, 1) go func() { c <- fn() }() select { case <-time.After(d): log.Printf("timeout for %s, sending e-mail about it", fnName) m := mailGun.NewMessage( "noreply@perkeep.org", "timeout for docker on pk-web", ...
[ "func", "emailOnTimeout", "(", "fnName", "string", ",", "d", "time", ".", "Duration", ",", "fn", "func", "(", ")", "error", ")", "error", "{", "c", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n", "go", "func", "(", ")", "{", "c", "<-", ...
// emailOnTimeout runs fn in a goroutine. If fn is not done after d, // a message about fnName is logged, and an e-mail about it is sent.
[ "emailOnTimeout", "runs", "fn", "in", "a", "goroutine", ".", "If", "fn", "is", "not", "done", "after", "d", "a", "message", "about", "fnName", "is", "logged", "and", "an", "e", "-", "mail", "about", "it", "is", "sent", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/email.go#L207-L228
train
perkeep/perkeep
pkg/blobserver/files/files.go
u32
func u32(n int64) uint32 { if n < 0 || n > math.MaxUint32 { panic("bad size " + fmt.Sprint(n)) } return uint32(n) }
go
func u32(n int64) uint32 { if n < 0 || n > math.MaxUint32 { panic("bad size " + fmt.Sprint(n)) } return uint32(n) }
[ "func", "u32", "(", "n", "int64", ")", "uint32", "{", "if", "n", "<", "0", "||", "n", ">", "math", ".", "MaxUint32", "{", "panic", "(", "\"", "\"", "+", "fmt", ".", "Sprint", "(", "n", ")", ")", "\n", "}", "\n", "return", "uint32", "(", "n", ...
// u32 converts n to an uint32, or panics if n is out of range
[ "u32", "converts", "n", "to", "an", "uint32", "or", "panics", "if", "n", "is", "out", "of", "range" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/files/files.go#L131-L136
train
perkeep/perkeep
pkg/blobserver/files/files.go
fetch
func (ds *Storage) fetch(ctx context.Context, br blob.Ref, offset, length int64) (rc io.ReadCloser, size uint32, err error) { // TODO: use ctx, if the os package ever supports that. fileName := ds.blobPath(br) stat, err := ds.fs.Stat(fileName) if os.IsNotExist(err) { return nil, 0, os.ErrNotExist } size = u32(s...
go
func (ds *Storage) fetch(ctx context.Context, br blob.Ref, offset, length int64) (rc io.ReadCloser, size uint32, err error) { // TODO: use ctx, if the os package ever supports that. fileName := ds.blobPath(br) stat, err := ds.fs.Stat(fileName) if os.IsNotExist(err) { return nil, 0, os.ErrNotExist } size = u32(s...
[ "func", "(", "ds", "*", "Storage", ")", "fetch", "(", "ctx", "context", ".", "Context", ",", "br", "blob", ".", "Ref", ",", "offset", ",", "length", "int64", ")", "(", "rc", "io", ".", "ReadCloser", ",", "size", "uint32", ",", "err", "error", ")", ...
// length -1 means entire file
[ "length", "-", "1", "means", "entire", "file" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/files/files.go#L139-L178
train
perkeep/perkeep
pkg/client/config.go
AddFlags
func AddFlags() { defaultPath := "/x/y/z/we're/in-a-test" if !buildinfo.TestingLinked() { defaultPath = osutil.UserClientConfigPath() } flag.StringVar(&flagServer, "server", "", "Perkeep server prefix. If blank, the default from the \"server\" field of "+defaultPath+" is used. Acceptable forms: https://you.exampl...
go
func AddFlags() { defaultPath := "/x/y/z/we're/in-a-test" if !buildinfo.TestingLinked() { defaultPath = osutil.UserClientConfigPath() } flag.StringVar(&flagServer, "server", "", "Perkeep server prefix. If blank, the default from the \"server\" field of "+defaultPath+" is used. Acceptable forms: https://you.exampl...
[ "func", "AddFlags", "(", ")", "{", "defaultPath", ":=", "\"", "\"", "\n", "if", "!", "buildinfo", ".", "TestingLinked", "(", ")", "{", "defaultPath", "=", "osutil", ".", "UserClientConfigPath", "(", ")", "\n", "}", "\n", "flag", ".", "StringVar", "(", ...
// AddFlags registers the "server" and "secret-keyring" string flags.
[ "AddFlags", "registers", "the", "server", "and", "secret", "-", "keyring", "string", "flags", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L52-L59
train
perkeep/perkeep
pkg/client/config.go
parseConfig
func (c *Client) parseConfig() { if android.OnAndroid() { panic("parseConfig should never have been called on Android") } if configDisabled { panic("parseConfig should never have been called with CAMLI_DISABLE_CLIENT_CONFIG_FILE set") } configPath := osutil.UserClientConfigPath() if _, err := wkfs.Stat(config...
go
func (c *Client) parseConfig() { if android.OnAndroid() { panic("parseConfig should never have been called on Android") } if configDisabled { panic("parseConfig should never have been called with CAMLI_DISABLE_CLIENT_CONFIG_FILE set") } configPath := osutil.UserClientConfigPath() if _, err := wkfs.Stat(config...
[ "func", "(", "c", "*", "Client", ")", "parseConfig", "(", ")", "{", "if", "android", ".", "OnAndroid", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "configDisabled", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "...
// lazy config parsing when there's a known client already. // The client c may be nil.
[ "lazy", "config", "parsing", "when", "there", "s", "a", "known", "client", "already", ".", "The", "client", "c", "may", "be", "nil", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L84-L162
train
perkeep/perkeep
pkg/client/config.go
convertToMultiServers
func convertToMultiServers(conf jsonconfig.Obj) (jsonconfig.Obj, error) { server := conf.OptionalString("server", "") if server == "" { return nil, errors.New("could not convert config to multi-servers style: no \"server\" key found") } newConf := jsonconfig.Obj{ "servers": map[string]interface{}{ "server": ...
go
func convertToMultiServers(conf jsonconfig.Obj) (jsonconfig.Obj, error) { server := conf.OptionalString("server", "") if server == "" { return nil, errors.New("could not convert config to multi-servers style: no \"server\" key found") } newConf := jsonconfig.Obj{ "servers": map[string]interface{}{ "server": ...
[ "func", "convertToMultiServers", "(", "conf", "jsonconfig", ".", "Obj", ")", "(", "jsonconfig", ".", "Obj", ",", "error", ")", "{", "server", ":=", "conf", ".", "OptionalString", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "server", "==", "\"", ...
// convertToMultiServers takes an old style single-server client configuration and maps it to new a multi-servers configuration that is returned.
[ "convertToMultiServers", "takes", "an", "old", "style", "single", "-", "server", "client", "configuration", "and", "maps", "it", "to", "new", "a", "multi", "-", "servers", "configuration", "that", "is", "returned", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L172-L196
train
perkeep/perkeep
pkg/client/config.go
printConfigChangeHelp
func printConfigChangeHelp(conf jsonconfig.Obj) { // rename maps from old key names to the new ones. // If there is no new one, the value is the empty string. rename := map[string]string{ "keyId": "identity", "publicKeyBlobref": "", "selfPubKeyDir": "", "secretRing": "identitySecretRing",...
go
func printConfigChangeHelp(conf jsonconfig.Obj) { // rename maps from old key names to the new ones. // If there is no new one, the value is the empty string. rename := map[string]string{ "keyId": "identity", "publicKeyBlobref": "", "selfPubKeyDir": "", "secretRing": "identitySecretRing",...
[ "func", "printConfigChangeHelp", "(", "conf", "jsonconfig", ".", "Obj", ")", "{", "// rename maps from old key names to the new ones.", "// If there is no new one, the value is the empty string.", "rename", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", ...
// printConfigChangeHelp checks if conf contains obsolete keys, // and prints additional help in this case.
[ "printConfigChangeHelp", "checks", "if", "conf", "contains", "obsolete", "keys", "and", "prints", "additional", "help", "in", "this", "case", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L200-L226
train
perkeep/perkeep
pkg/client/config.go
getServer
func getServer() (string, error) { if s := os.Getenv("CAMLI_SERVER"); s != "" { return cleanServer(s) } if flagServer != "" { if !isURLOrHostPort(flagServer) { configOnce.Do(parseConfig) serverConf, ok := config.Servers[flagServer] if ok { return serverConf.Server, nil } log.Printf("%q looks l...
go
func getServer() (string, error) { if s := os.Getenv("CAMLI_SERVER"); s != "" { return cleanServer(s) } if flagServer != "" { if !isURLOrHostPort(flagServer) { configOnce.Do(parseConfig) serverConf, ok := config.Servers[flagServer] if ok { return serverConf.Server, nil } log.Printf("%q looks l...
[ "func", "getServer", "(", ")", "(", "string", ",", "error", ")", "{", "if", "s", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", ";", "s", "!=", "\"", "\"", "{", "return", "cleanServer", "(", "s", ")", "\n", "}", "\n", "if", "flagServer", "!="...
// getServer returns the server's URL found either as a command-line flag, // or as the default server in the config file.
[ "getServer", "returns", "the", "server", "s", "URL", "found", "either", "as", "a", "command", "-", "line", "flag", "or", "as", "the", "default", "server", "in", "the", "config", "file", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L269-L293
train
perkeep/perkeep
pkg/client/config.go
SetupAuth
func (c *Client) SetupAuth() error { if c.noExtConfig { if c.authMode != nil { if _, ok := c.authMode.(*auth.None); !ok { return nil } } return errors.New("client: noExtConfig set; auth should not be configured from config or env vars") } // env var takes precedence, but only if we're in dev mode or ...
go
func (c *Client) SetupAuth() error { if c.noExtConfig { if c.authMode != nil { if _, ok := c.authMode.(*auth.None); !ok { return nil } } return errors.New("client: noExtConfig set; auth should not be configured from config or env vars") } // env var takes precedence, but only if we're in dev mode or ...
[ "func", "(", "c", "*", "Client", ")", "SetupAuth", "(", ")", "error", "{", "if", "c", ".", "noExtConfig", "{", "if", "c", ".", "authMode", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "c", ".", "authMode", ".", "(", "*", "auth", ".", "None", ...
// SetupAuth sets the client's authMode. It tries from the environment first if we're on android or in dev mode, and then from the client configuration.
[ "SetupAuth", "sets", "the", "client", "s", "authMode", ".", "It", "tries", "from", "the", "environment", "first", "if", "we", "re", "on", "android", "or", "in", "dev", "mode", "and", "then", "from", "the", "client", "configuration", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L311-L346
train
perkeep/perkeep
pkg/client/config.go
serverAuth
func serverAuth(server string) string { configOnce.Do(parseConfig) alias := config.Alias(server) if alias == "" { return "" } return config.Servers[alias].Auth }
go
func serverAuth(server string) string { configOnce.Do(parseConfig) alias := config.Alias(server) if alias == "" { return "" } return config.Servers[alias].Auth }
[ "func", "serverAuth", "(", "server", "string", ")", "string", "{", "configOnce", ".", "Do", "(", "parseConfig", ")", "\n", "alias", ":=", "config", ".", "Alias", "(", "server", ")", "\n", "if", "alias", "==", "\"", "\"", "{", "return", "\"", "\"", "\...
// serverAuth returns the auth scheme for server from the config, or the empty string if the server was not found in the config.
[ "serverAuth", "returns", "the", "auth", "scheme", "for", "server", "from", "the", "config", "or", "the", "empty", "string", "if", "the", "server", "was", "not", "found", "in", "the", "config", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L349-L356
train
perkeep/perkeep
pkg/client/config.go
SetupAuthFromString
func (c *Client) SetupAuthFromString(a string) error { // TODO(mpl): review the one using that (pkg/blobserver/remote/remote.go) var err error c.authMode, err = auth.FromConfig(a) return err }
go
func (c *Client) SetupAuthFromString(a string) error { // TODO(mpl): review the one using that (pkg/blobserver/remote/remote.go) var err error c.authMode, err = auth.FromConfig(a) return err }
[ "func", "(", "c", "*", "Client", ")", "SetupAuthFromString", "(", "a", "string", ")", "error", "{", "// TODO(mpl): review the one using that (pkg/blobserver/remote/remote.go)", "var", "err", "error", "\n", "c", ".", "authMode", ",", "err", "=", "auth", ".", "FromC...
// SetupAuthFromString configures the clients authentication mode from // an explicit auth string.
[ "SetupAuthFromString", "configures", "the", "clients", "authentication", "mode", "from", "an", "explicit", "auth", "string", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L360-L365
train
perkeep/perkeep
pkg/client/config.go
serverTrustedCerts
func (c *Client) serverTrustedCerts(server string) []string { configOnce.Do(c.parseConfig) if config == nil { return nil } alias := config.Alias(server) if alias == "" { return nil } return config.Servers[alias].TrustedCerts }
go
func (c *Client) serverTrustedCerts(server string) []string { configOnce.Do(c.parseConfig) if config == nil { return nil } alias := config.Alias(server) if alias == "" { return nil } return config.Servers[alias].TrustedCerts }
[ "func", "(", "c", "*", "Client", ")", "serverTrustedCerts", "(", "server", "string", ")", "[", "]", "string", "{", "configOnce", ".", "Do", "(", "c", ".", "parseConfig", ")", "\n", "if", "config", "==", "nil", "{", "return", "nil", "\n", "}", "\n", ...
// serverTrustedCerts returns the trusted certs for server from the config.
[ "serverTrustedCerts", "returns", "the", "trusted", "certs", "for", "server", "from", "the", "config", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L463-L473
train
perkeep/perkeep
pkg/client/config.go
newIgnoreChecker
func newIgnoreChecker(ignoredFiles []string) func(path string) (shouldIgnore bool) { var fns []func(string) bool // copy of ignoredFiles for us to mutate ignFiles := append([]string(nil), ignoredFiles...) for k, v := range ignFiles { if strings.HasPrefix(v, filepath.FromSlash("~/")) { ignFiles[k] = filepath.J...
go
func newIgnoreChecker(ignoredFiles []string) func(path string) (shouldIgnore bool) { var fns []func(string) bool // copy of ignoredFiles for us to mutate ignFiles := append([]string(nil), ignoredFiles...) for k, v := range ignFiles { if strings.HasPrefix(v, filepath.FromSlash("~/")) { ignFiles[k] = filepath.J...
[ "func", "newIgnoreChecker", "(", "ignoredFiles", "[", "]", "string", ")", "func", "(", "path", "string", ")", "(", "shouldIgnore", "bool", ")", "{", "var", "fns", "[", "]", "func", "(", "string", ")", "bool", "\n\n", "// copy of ignoredFiles for us to mutate",...
// newIgnoreChecker uses ignoredFiles to build and return a func that returns whether the file path argument should be ignored. See IsIgnoredFile for the ignore rules.
[ "newIgnoreChecker", "uses", "ignoredFiles", "to", "build", "and", "return", "a", "func", "that", "returns", "whether", "the", "file", "path", "argument", "should", "be", "ignored", ".", "See", "IsIgnoredFile", "for", "the", "ignore", "rules", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L502-L540
train
perkeep/perkeep
pkg/client/config.go
hasDirPrefix
func hasDirPrefix(dirPrefix, fullpath string) bool { if !strings.HasPrefix(fullpath, dirPrefix) { return false } if len(fullpath) == len(dirPrefix) { return true } if fullpath[len(dirPrefix)] == filepath.Separator { return true } return false }
go
func hasDirPrefix(dirPrefix, fullpath string) bool { if !strings.HasPrefix(fullpath, dirPrefix) { return false } if len(fullpath) == len(dirPrefix) { return true } if fullpath[len(dirPrefix)] == filepath.Separator { return true } return false }
[ "func", "hasDirPrefix", "(", "dirPrefix", ",", "fullpath", "string", ")", "bool", "{", "if", "!", "strings", ".", "HasPrefix", "(", "fullpath", ",", "dirPrefix", ")", "{", "return", "false", "\n", "}", "\n", "if", "len", "(", "fullpath", ")", "==", "le...
// hasDirPrefix reports whether the path has the provided directory prefix. // Both should be absolute paths.
[ "hasDirPrefix", "reports", "whether", "the", "path", "has", "the", "provided", "directory", "prefix", ".", "Both", "should", "be", "absolute", "paths", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L561-L572
train
perkeep/perkeep
pkg/client/config.go
hasComponent
func hasComponent(component, fullpath string) bool { // trim Windows volume name fullpath = strings.TrimPrefix(fullpath, filepath.VolumeName(fullpath)) for { i := strings.Index(fullpath, component) if i == -1 { return false } if i != 0 && fullpath[i-1] == filepath.Separator { componentEnd := i + len(co...
go
func hasComponent(component, fullpath string) bool { // trim Windows volume name fullpath = strings.TrimPrefix(fullpath, filepath.VolumeName(fullpath)) for { i := strings.Index(fullpath, component) if i == -1 { return false } if i != 0 && fullpath[i-1] == filepath.Separator { componentEnd := i + len(co...
[ "func", "hasComponent", "(", "component", ",", "fullpath", "string", ")", "bool", "{", "// trim Windows volume name", "fullpath", "=", "strings", ".", "TrimPrefix", "(", "fullpath", ",", "filepath", ".", "VolumeName", "(", "fullpath", ")", ")", "\n", "for", "{...
// hasComponent returns whether the pathComponent is a path component of // fullpath. i.e it is a part of fullpath that fits exactly between two path // separators.
[ "hasComponent", "returns", "whether", "the", "pathComponent", "is", "a", "path", "component", "of", "fullpath", ".", "i", ".", "e", "it", "is", "a", "part", "of", "fullpath", "that", "fits", "exactly", "between", "two", "path", "separators", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L577-L597
train
perkeep/perkeep
misc/release/make-release.go
genAll
func genAll() ([]string, error) { zipSource() for _, platform := range []string{"linux", "darwin", "windows"} { genBinaries(platform) packBinaries(platform) } getVersions() return []string{ "perkeep-darwin.tar.gz", "perkeep-linux.tar.gz", "perkeep-src.zip", "perkeep-windows.zip", }, nil }
go
func genAll() ([]string, error) { zipSource() for _, platform := range []string{"linux", "darwin", "windows"} { genBinaries(platform) packBinaries(platform) } getVersions() return []string{ "perkeep-darwin.tar.gz", "perkeep-linux.tar.gz", "perkeep-src.zip", "perkeep-windows.zip", }, nil }
[ "func", "genAll", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "zipSource", "(", ")", "\n", "for", "_", ",", "platform", ":=", "range", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "{", "genBinaries"...
// genAll creates all the zips and tarballs, and returns their filenames.
[ "genAll", "creates", "all", "the", "zips", "and", "tarballs", "and", "returns", "their", "filenames", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L196-L209
train
perkeep/perkeep
misc/release/make-release.go
getVersions
func getVersions() { pkBin := filepath.Join(workDir, runtime.GOOS, "bin", "perkeepd") cmd := exec.Command(pkBin, "-version") var buf bytes.Buffer cmd.Stderr = &buf if err := cmd.Run(); err != nil { log.Fatalf("Error getting version from perkeepd: %v, %v", err, buf.String()) } sc := bufio.NewScanner(&buf) for ...
go
func getVersions() { pkBin := filepath.Join(workDir, runtime.GOOS, "bin", "perkeepd") cmd := exec.Command(pkBin, "-version") var buf bytes.Buffer cmd.Stderr = &buf if err := cmd.Run(); err != nil { log.Fatalf("Error getting version from perkeepd: %v, %v", err, buf.String()) } sc := bufio.NewScanner(&buf) for ...
[ "func", "getVersions", "(", ")", "{", "pkBin", ":=", "filepath", ".", "Join", "(", "workDir", ",", "runtime", ".", "GOOS", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "cmd", ":=", "exec", ".", "Command", "(", "pkBin", ",", "\"", "\"", ")", "\n",...
// getVersions uses the freshly built perkeepd binary to get the Perkeep and Go // versions used to build the release.
[ "getVersions", "uses", "the", "freshly", "built", "perkeepd", "binary", "to", "get", "the", "Perkeep", "and", "Go", "versions", "used", "to", "build", "the", "release", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L213-L241
train
perkeep/perkeep
misc/release/make-release.go
zipSource
func zipSource() string { cwd := filepath.Join(workDir, "src") check(os.MkdirAll(cwd, 0755)) image := goDockerImage args := []string{ "run", "--rm", "--volume=" + cwd + ":/OUT", "--volume=" + path.Join(releaseDir, "zip-source.go") + ":" + zipSourceProgram + ":ro", } if isWIP() { args = append(args, "--v...
go
func zipSource() string { cwd := filepath.Join(workDir, "src") check(os.MkdirAll(cwd, 0755)) image := goDockerImage args := []string{ "run", "--rm", "--volume=" + cwd + ":/OUT", "--volume=" + path.Join(releaseDir, "zip-source.go") + ":" + zipSourceProgram + ":ro", } if isWIP() { args = append(args, "--v...
[ "func", "zipSource", "(", ")", "string", "{", "cwd", ":=", "filepath", ".", "Join", "(", "workDir", ",", "\"", "\"", ")", "\n", "check", "(", "os", ".", "MkdirAll", "(", "cwd", ",", "0755", ")", ")", "\n", "image", ":=", "goDockerImage", "\n", "arg...
// zipSource builds the zip archive that contains the source code of Perkeep.
[ "zipSource", "builds", "the", "zip", "archive", "that", "contains", "the", "source", "code", "of", "Perkeep", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L378-L410
train
perkeep/perkeep
misc/release/make-release.go
committers
func committers() (map[string]string, error) { cmd := exec.Command("git", "shortlog", "-n", "-e", "-s", *flagStatsFrom+".."+revOrHEAD()) out, err := cmd.CombinedOutput() if err != nil { return nil, fmt.Errorf("%v; %v", err, string(out)) } rxp := regexp.MustCompile(`^\s+(\d+)\s+(.*)<(.*)>.*$`) sc := bufio.NewSca...
go
func committers() (map[string]string, error) { cmd := exec.Command("git", "shortlog", "-n", "-e", "-s", *flagStatsFrom+".."+revOrHEAD()) out, err := cmd.CombinedOutput() if err != nil { return nil, fmt.Errorf("%v; %v", err, string(out)) } rxp := regexp.MustCompile(`^\s+(\d+)\s+(.*)<(.*)>.*$`) sc := bufio.NewSca...
[ "func", "committers", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "*", "flagStatsFrom...
// returns commiters names mapped by e-mail, uniqued first by e-mail, then by name. // When uniquing, higher count of commits wins.
[ "returns", "commiters", "names", "mapped", "by", "e", "-", "mail", "uniqued", "first", "by", "e", "-", "mail", "then", "by", "name", ".", "When", "uniquing", "higher", "count", "of", "commits", "wins", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L690-L739
train
perkeep/perkeep
misc/release/make-release.go
ProjectTokenSource
func ProjectTokenSource(proj string, scopes ...string) (oauth2.TokenSource, error) { // TODO(bradfitz): try different strategies too, like // three-legged flow if the service account doesn't exist, and // then cache the token file on disk somewhere. Or maybe that should be an // option, for environments without std...
go
func ProjectTokenSource(proj string, scopes ...string) (oauth2.TokenSource, error) { // TODO(bradfitz): try different strategies too, like // three-legged flow if the service account doesn't exist, and // then cache the token file on disk somewhere. Or maybe that should be an // option, for environments without std...
[ "func", "ProjectTokenSource", "(", "proj", "string", ",", "scopes", "...", "string", ")", "(", "oauth2", ".", "TokenSource", ",", "error", ")", "{", "// TODO(bradfitz): try different strategies too, like", "// three-legged flow if the service account doesn't exist, and", "// ...
// ProjectTokenSource returns an OAuth2 TokenSource for the given Google Project ID.
[ "ProjectTokenSource", "returns", "an", "OAuth2", "TokenSource", "for", "the", "given", "Google", "Project", "ID", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L907-L926
train
perkeep/perkeep
internal/hashutil/hashutil.go
SHA256Prefix
func SHA256Prefix(data []byte) string { h := sha256.New() h.Write(data) return fmt.Sprintf("%x", h.Sum(nil))[:20] }
go
func SHA256Prefix(data []byte) string { h := sha256.New() h.Write(data) return fmt.Sprintf("%x", h.Sum(nil))[:20] }
[ "func", "SHA256Prefix", "(", "data", "[", "]", "byte", ")", "string", "{", "h", ":=", "sha256", ".", "New", "(", ")", "\n", "h", ".", "Write", "(", "data", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "h", ".", "Sum", "(", ...
// SHA256Prefix computes the SHA-256 digest of data and returns // its first twenty lowercase hex digits.
[ "SHA256Prefix", "computes", "the", "SHA", "-", "256", "digest", "of", "data", "and", "returns", "its", "first", "twenty", "lowercase", "hex", "digits", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/hashutil/hashutil.go#L32-L36
train
perkeep/perkeep
internal/hashutil/hashutil.go
SHA1Prefix
func SHA1Prefix(data []byte) string { h := sha1.New() h.Write(data) return fmt.Sprintf("%x", h.Sum(nil))[:20] }
go
func SHA1Prefix(data []byte) string { h := sha1.New() h.Write(data) return fmt.Sprintf("%x", h.Sum(nil))[:20] }
[ "func", "SHA1Prefix", "(", "data", "[", "]", "byte", ")", "string", "{", "h", ":=", "sha1", ".", "New", "(", ")", "\n", "h", ".", "Write", "(", "data", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "h", ".", "Sum", "(", "n...
// SHA1Prefix computes the SHA-1 digest of data and returns // its first twenty lowercase hex digits.
[ "SHA1Prefix", "computes", "the", "SHA", "-", "1", "digest", "of", "data", "and", "returns", "its", "first", "twenty", "lowercase", "hex", "digits", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/hashutil/hashutil.go#L40-L44
train
perkeep/perkeep
internal/osutil/paths.go
HomeDir
func HomeDir() string { failInTests() if runtime.GOOS == "windows" { return os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") } return os.Getenv("HOME") }
go
func HomeDir() string { failInTests() if runtime.GOOS == "windows" { return os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") } return os.Getenv("HOME") }
[ "func", "HomeDir", "(", ")", "string", "{", "failInTests", "(", ")", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "return", "os", ".", "Getenv", "(", "\"", "\"", ")", "+", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "}", "\n"...
// HomeDir returns the path to the user's home directory. // It returns the empty string if the value isn't known.
[ "HomeDir", "returns", "the", "path", "to", "the", "user", "s", "home", "directory", ".", "It", "returns", "the", "empty", "string", "if", "the", "value", "isn", "t", "known", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/paths.go#L37-L43
train
perkeep/perkeep
internal/osutil/paths.go
NewJSONConfigParser
func NewJSONConfigParser() *jsonconfig.ConfigParser { var cp jsonconfig.ConfigParser dir, err := PerkeepConfigDir() if err != nil { log.Fatalf("NewJSONConfigParser error: %v", err) } cp.IncludeDirs = append([]string{dir}, filepath.SplitList(os.Getenv("CAMLI_INCLUDE_PATH"))...) return &cp }
go
func NewJSONConfigParser() *jsonconfig.ConfigParser { var cp jsonconfig.ConfigParser dir, err := PerkeepConfigDir() if err != nil { log.Fatalf("NewJSONConfigParser error: %v", err) } cp.IncludeDirs = append([]string{dir}, filepath.SplitList(os.Getenv("CAMLI_INCLUDE_PATH"))...) return &cp }
[ "func", "NewJSONConfigParser", "(", ")", "*", "jsonconfig", ".", "ConfigParser", "{", "var", "cp", "jsonconfig", ".", "ConfigParser", "\n", "dir", ",", "err", ":=", "PerkeepConfigDir", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf", ...
// NewJSONConfigParser returns a jsonconfig.ConfigParser with its IncludeDirs // set with PerkeepConfigDir and the contents of CAMLI_INCLUDE_PATH.
[ "NewJSONConfigParser", "returns", "a", "jsonconfig", ".", "ConfigParser", "with", "its", "IncludeDirs", "set", "with", "PerkeepConfigDir", "and", "the", "contents", "of", "CAMLI_INCLUDE_PATH", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/osutil/paths.go#L332-L340
train
perkeep/perkeep
pkg/sorted/mem.go
NewMemoryKeyValue
func NewMemoryKeyValue() KeyValue { db := memdb.New(comparer.DefaultComparer, 128) return &memKeys{db: db} }
go
func NewMemoryKeyValue() KeyValue { db := memdb.New(comparer.DefaultComparer, 128) return &memKeys{db: db} }
[ "func", "NewMemoryKeyValue", "(", ")", "KeyValue", "{", "db", ":=", "memdb", ".", "New", "(", "comparer", ".", "DefaultComparer", ",", "128", ")", "\n", "return", "&", "memKeys", "{", "db", ":", "db", "}", "\n", "}" ]
// NewMemoryKeyValue returns a KeyValue implementation that's backed only // by memory. It's mostly useful for tests and development.
[ "NewMemoryKeyValue", "returns", "a", "KeyValue", "implementation", "that", "s", "backed", "only", "by", "memory", ".", "It", "s", "mostly", "useful", "for", "tests", "and", "development", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mem.go#L33-L36
train
perkeep/perkeep
app/publisher/zip.go
blobsFromDir
func (zh *zipHandler) blobsFromDir(dirPath string, dirBlob blob.Ref) ([]*blobFile, error) { var list []*blobFile dr, err := schema.NewDirReader(context.TODO(), zh.fetcher, dirBlob) if err != nil { return nil, fmt.Errorf("Could not read dir blob %v: %v", dirBlob, err) } ent, err := dr.Readdir(context.TODO(), -1) ...
go
func (zh *zipHandler) blobsFromDir(dirPath string, dirBlob blob.Ref) ([]*blobFile, error) { var list []*blobFile dr, err := schema.NewDirReader(context.TODO(), zh.fetcher, dirBlob) if err != nil { return nil, fmt.Errorf("Could not read dir blob %v: %v", dirBlob, err) } ent, err := dr.Readdir(context.TODO(), -1) ...
[ "func", "(", "zh", "*", "zipHandler", ")", "blobsFromDir", "(", "dirPath", "string", ",", "dirBlob", "blob", ".", "Ref", ")", "(", "[", "]", "*", "blobFile", ",", "error", ")", "{", "var", "list", "[", "]", "*", "blobFile", "\n", "dr", ",", "err", ...
// blobsFromDir returns the list of file blobs in directory dirBlob. // It only traverses permanode directories.
[ "blobsFromDir", "returns", "the", "list", "of", "file", "blobs", "in", "directory", "dirBlob", ".", "It", "only", "traverses", "permanode", "directories", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/zip.go#L159-L183
train
perkeep/perkeep
app/publisher/zip.go
renameDuplicates
func renameDuplicates(bf []*blobFile) sortedFiles { noDup := make(map[string]blob.Ref) // use a map to detect duplicates and rename them for _, file := range bf { if _, ok := noDup[file.path]; ok { // path already exists, so rename suffix := 0 var newname string for { suffix++ ext := path.Ext(f...
go
func renameDuplicates(bf []*blobFile) sortedFiles { noDup := make(map[string]blob.Ref) // use a map to detect duplicates and rename them for _, file := range bf { if _, ok := noDup[file.path]; ok { // path already exists, so rename suffix := 0 var newname string for { suffix++ ext := path.Ext(f...
[ "func", "renameDuplicates", "(", "bf", "[", "]", "*", "blobFile", ")", "sortedFiles", "{", "noDup", ":=", "make", "(", "map", "[", "string", "]", "blob", ".", "Ref", ")", "\n", "// use a map to detect duplicates and rename them", "for", "_", ",", "file", ":=...
// renameDuplicates goes through bf to check for duplicate filepaths. // It renames duplicate filepaths and returns a new slice, sorted by // file path.
[ "renameDuplicates", "goes", "through", "bf", "to", "check", "for", "duplicate", "filepaths", ".", "It", "renames", "duplicate", "filepaths", "and", "returns", "a", "new", "slice", "sorted", "by", "file", "path", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/zip.go#L188-L218
train
perkeep/perkeep
app/publisher/zip.go
ServeHTTP
func (zh *zipHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { // TODO: use http.ServeContent, so Range requests work and downloads can be resumed. // Will require calculating the zip length once first (ideally as cheaply as possible, // with dummy counting writer and dummy all-zero-byte-files of a fix...
go
func (zh *zipHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { // TODO: use http.ServeContent, so Range requests work and downloads can be resumed. // Will require calculating the zip length once first (ideally as cheaply as possible, // with dummy counting writer and dummy all-zero-byte-files of a fix...
[ "func", "(", "zh", "*", "zipHandler", ")", "ServeHTTP", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "// TODO: use http.ServeContent, so Range requests work and downloads can be resumed.", "// Will require calculating the zip ...
// ServeHTTP streams a zip archive of all the files "under" // zh.root. That is, all the files pointed by file permanodes, // which are directly members of zh.root or recursively down // directory permanodes and permanodes members. // To build the fullpath of a file in a collection, it uses // the collection title if p...
[ "ServeHTTP", "streams", "a", "zip", "archive", "of", "all", "the", "files", "under", "zh", ".", "root", ".", "That", "is", "all", "the", "files", "pointed", "by", "file", "permanodes", "which", "are", "directly", "members", "of", "zh", ".", "root", "or",...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/zip.go#L227-L292
train
perkeep/perkeep
server/perkeepd/ui/goui/sharebutton/gen_ShareItemsBtn_reactGen.go
Props
func (s ShareItemsBtnDef) Props() ShareItemsBtnProps { uprops := s.ComponentDef.Props() return uprops.(ShareItemsBtnProps) }
go
func (s ShareItemsBtnDef) Props() ShareItemsBtnProps { uprops := s.ComponentDef.Props() return uprops.(ShareItemsBtnProps) }
[ "func", "(", "s", "ShareItemsBtnDef", ")", "Props", "(", ")", "ShareItemsBtnProps", "{", "uprops", ":=", "s", ".", "ComponentDef", ".", "Props", "(", ")", "\n", "return", "uprops", ".", "(", "ShareItemsBtnProps", ")", "\n", "}" ]
// Props is an auto-generated proxy to the current props of ShareItemsBtn
[ "Props", "is", "an", "auto", "-", "generated", "proxy", "to", "the", "current", "props", "of", "ShareItemsBtn" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/sharebutton/gen_ShareItemsBtn_reactGen.go#L30-L33
train
perkeep/perkeep
app/publisher/main.go
appConfig
func appConfig() (*config, error) { configURL := os.Getenv("CAMLI_APP_CONFIG_URL") if configURL == "" { return nil, fmt.Errorf("Publisher application needs a CAMLI_APP_CONFIG_URL env var") } cl, err := app.Client() if err != nil { return nil, fmt.Errorf("could not get a client to fetch extra config: %v", err) ...
go
func appConfig() (*config, error) { configURL := os.Getenv("CAMLI_APP_CONFIG_URL") if configURL == "" { return nil, fmt.Errorf("Publisher application needs a CAMLI_APP_CONFIG_URL env var") } cl, err := app.Client() if err != nil { return nil, fmt.Errorf("could not get a client to fetch extra config: %v", err) ...
[ "func", "appConfig", "(", ")", "(", "*", "config", ",", "error", ")", "{", "configURL", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "configURL", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// appConfig keeps on trying to fetch the extra config from the app handler. If // it doesn't succed after an hour has passed, the program exits.
[ "appConfig", "keeps", "on", "trying", "to", "fetch", "the", "extra", "config", "from", "the", "app", "handler", ".", "If", "it", "doesn", "t", "succed", "after", "an", "hour", "has", "passed", "the", "program", "exits", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L93-L118
train
perkeep/perkeep
app/publisher/main.go
setMasterQuery
func (ph *publishHandler) setMasterQuery(topNode blob.Ref) error { query := &search.SearchQuery{ Sort: search.CreatedDesc, Limit: -1, Constraint: &search.Constraint{ Permanode: &search.PermanodeConstraint{ Relation: &search.RelationConstraint{ Relation: "parent", Any: &search.Constraint{ ...
go
func (ph *publishHandler) setMasterQuery(topNode blob.Ref) error { query := &search.SearchQuery{ Sort: search.CreatedDesc, Limit: -1, Constraint: &search.Constraint{ Permanode: &search.PermanodeConstraint{ Relation: &search.RelationConstraint{ Relation: "parent", Any: &search.Constraint{ ...
[ "func", "(", "ph", "*", "publishHandler", ")", "setMasterQuery", "(", "topNode", "blob", ".", "Ref", ")", "error", "{", "query", ":=", "&", "search", ".", "SearchQuery", "{", "Sort", ":", "search", ".", "CreatedDesc", ",", "Limit", ":", "-", "1", ",", ...
// setMasterQuery registers with the app handler a master query that includes // topNode and all its descendants as the search response.
[ "setMasterQuery", "registers", "with", "the", "app", "handler", "a", "master", "query", "that", "includes", "topNode", "and", "all", "its", "descendants", "as", "the", "search", "response", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L122-L169
train
perkeep/perkeep
app/publisher/main.go
resolvePrefixHop
func (ph *publishHandler) resolvePrefixHop(parent blob.Ref, prefix string) (child blob.Ref, err error) { // TODO: this is a linear scan right now. this should be // optimized to use a new database table of members so this is // a quick lookup. in the meantime it should be in memcached // at least. if len(prefix) ...
go
func (ph *publishHandler) resolvePrefixHop(parent blob.Ref, prefix string) (child blob.Ref, err error) { // TODO: this is a linear scan right now. this should be // optimized to use a new database table of members so this is // a quick lookup. in the meantime it should be in memcached // at least. if len(prefix) ...
[ "func", "(", "ph", "*", "publishHandler", ")", "resolvePrefixHop", "(", "parent", "blob", ".", "Ref", ",", "prefix", "string", ")", "(", "child", "blob", ".", "Ref", ",", "err", "error", ")", "{", "// TODO: this is a linear scan right now. this should be", "// o...
// Given a blobref and a few hex characters of the digest of the next hop, return the complete // blobref of the prefix, if that's a valid next hop.
[ "Given", "a", "blobref", "and", "a", "few", "hex", "characters", "of", "the", "digest", "of", "the", "next", "hop", "return", "the", "complete", "blobref", "of", "the", "prefix", "if", "that", "s", "a", "valid", "next", "hop", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L565-L602
train
perkeep/perkeep
app/publisher/main.go
serveSubjectTemplate
func (pr *publishRequest) serveSubjectTemplate() { res, err := pr.ph.deepDescribe(pr.subject) if err != nil { httputil.ServeError(pr.rw, pr.req, err) return } pr.ph.cacheDescribed(res.Meta) subdes := res.Meta[pr.subject.String()] if subdes.CamliType == "file" { pr.serveFileDownload(subdes) return } he...
go
func (pr *publishRequest) serveSubjectTemplate() { res, err := pr.ph.deepDescribe(pr.subject) if err != nil { httputil.ServeError(pr.rw, pr.req, err) return } pr.ph.cacheDescribed(res.Meta) subdes := res.Meta[pr.subject.String()] if subdes.CamliType == "file" { pr.serveFileDownload(subdes) return } he...
[ "func", "(", "pr", "*", "publishRequest", ")", "serveSubjectTemplate", "(", ")", "{", "res", ",", "err", ":=", "pr", ".", "ph", ".", "deepDescribe", "(", "pr", ".", "subject", ")", "\n", "if", "err", "!=", "nil", "{", "httputil", ".", "ServeError", "...
// serveSubjectTemplate creates the funcs to generate the PageHeader, PageFile, // and pageMembers that can be used by the subject template, and serves the template.
[ "serveSubjectTemplate", "creates", "the", "funcs", "to", "generate", "the", "PageHeader", "PageFile", "and", "pageMembers", "that", "can", "be", "used", "by", "the", "subject", "template", "and", "serves", "the", "template", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L863-L908
train
perkeep/perkeep
app/publisher/main.go
subjectHeader
func (pr *publishRequest) subjectHeader(described map[string]*search.DescribedBlob) *publish.PageHeader { subdes := described[pr.subject.String()] header := &publish.PageHeader{ Title: html.EscapeString(getTitle(subdes.BlobRef, described)), CSSFiles: pr.cssFiles(), JSDeps: pr.jsDeps(),...
go
func (pr *publishRequest) subjectHeader(described map[string]*search.DescribedBlob) *publish.PageHeader { subdes := described[pr.subject.String()] header := &publish.PageHeader{ Title: html.EscapeString(getTitle(subdes.BlobRef, described)), CSSFiles: pr.cssFiles(), JSDeps: pr.jsDeps(),...
[ "func", "(", "pr", "*", "publishRequest", ")", "subjectHeader", "(", "described", "map", "[", "string", "]", "*", "search", ".", "DescribedBlob", ")", "*", "publish", ".", "PageHeader", "{", "subdes", ":=", "described", "[", "pr", ".", "subject", ".", "S...
// subjectHeader returns the PageHeader corresponding to the described subject.
[ "subjectHeader", "returns", "the", "PageHeader", "corresponding", "to", "the", "described", "subject", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L977-L990
train
perkeep/perkeep
app/publisher/main.go
subjectFile
func (pr *publishRequest) subjectFile(described map[string]*search.DescribedBlob) (*publish.PageFile, error) { subdes := described[pr.subject.String()] contentRef, ok := subdes.ContentRef() if !ok { return nil, nil } fileDes, err := pr.ph.describe(contentRef) if err != nil { return nil, err } if fileDes.Fil...
go
func (pr *publishRequest) subjectFile(described map[string]*search.DescribedBlob) (*publish.PageFile, error) { subdes := described[pr.subject.String()] contentRef, ok := subdes.ContentRef() if !ok { return nil, nil } fileDes, err := pr.ph.describe(contentRef) if err != nil { return nil, err } if fileDes.Fil...
[ "func", "(", "pr", "*", "publishRequest", ")", "subjectFile", "(", "described", "map", "[", "string", "]", "*", "search", ".", "DescribedBlob", ")", "(", "*", "publish", ".", "PageFile", ",", "error", ")", "{", "subdes", ":=", "described", "[", "pr", "...
// subjectFile returns the relevant PageFile if the described subject is a file permanode.
[ "subjectFile", "returns", "the", "relevant", "PageFile", "if", "the", "described", "subject", "is", "a", "file", "permanode", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L1037-L1071
train
perkeep/perkeep
app/publisher/main.go
subjectMembers
func (pr *publishRequest) subjectMembers(resMap map[string]*search.DescribedBlob) (*publish.PageMembers, error) { subdes := resMap[pr.subject.String()] res, err := pr.ph.describeMembers(pr.subject) if err != nil { return nil, err } members := []*search.DescribedBlob{} for _, v := range res.Blobs { members = a...
go
func (pr *publishRequest) subjectMembers(resMap map[string]*search.DescribedBlob) (*publish.PageMembers, error) { subdes := resMap[pr.subject.String()] res, err := pr.ph.describeMembers(pr.subject) if err != nil { return nil, err } members := []*search.DescribedBlob{} for _, v := range res.Blobs { members = a...
[ "func", "(", "pr", "*", "publishRequest", ")", "subjectMembers", "(", "resMap", "map", "[", "string", "]", "*", "search", ".", "DescribedBlob", ")", "(", "*", "publish", ".", "PageMembers", ",", "error", ")", "{", "subdes", ":=", "resMap", "[", "pr", "...
// subjectMembers returns the relevant PageMembers if the described subject is a permanode with members.
[ "subjectMembers", "returns", "the", "relevant", "PageMembers", "if", "the", "described", "subject", "is", "a", "permanode", "with", "members", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L1102-L1166
train
perkeep/perkeep
app/publisher/main.go
serveZip
func (pr *publishRequest) serveZip() { filename := "" if len(pr.subres) > len("/=z/") { filename = pr.subres[4:] } zh := &zipHandler{ fetcher: pr.ph.cl, cl: pr.ph.cl, root: pr.subject, filename: filename, } zh.ServeHTTP(pr.rw, pr.req) }
go
func (pr *publishRequest) serveZip() { filename := "" if len(pr.subres) > len("/=z/") { filename = pr.subres[4:] } zh := &zipHandler{ fetcher: pr.ph.cl, cl: pr.ph.cl, root: pr.subject, filename: filename, } zh.ServeHTTP(pr.rw, pr.req) }
[ "func", "(", "pr", "*", "publishRequest", ")", "serveZip", "(", ")", "{", "filename", ":=", "\"", "\"", "\n", "if", "len", "(", "pr", ".", "subres", ")", ">", "len", "(", "\"", "\"", ")", "{", "filename", "=", "pr", ".", "subres", "[", "4", ":"...
// serveZip streams a zip archive of all the files "under" // pr.subject. That is, all the files pointed by file permanodes, // which are directly members of pr.subject or recursively down // directory permanodes and permanodes members.
[ "serveZip", "streams", "a", "zip", "archive", "of", "all", "the", "files", "under", "pr", ".", "subject", ".", "That", "is", "all", "the", "files", "pointed", "by", "file", "permanodes", "which", "are", "directly", "members", "of", "pr", ".", "subject", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/publisher/main.go#L1244-L1256
train
perkeep/perkeep
pkg/blobserver/blobpacked/subfetch.go
SubFetch
func (s *storage) SubFetch(ctx context.Context, ref blob.Ref, offset, length int64) (io.ReadCloser, error) { // TODO: pass ctx to more calls within this method. m, err := s.getMetaRow(ref) if err != nil { return nil, err } if m.isPacked() { length, err = capOffsetLength(m.size, offset, length) if err != nil ...
go
func (s *storage) SubFetch(ctx context.Context, ref blob.Ref, offset, length int64) (io.ReadCloser, error) { // TODO: pass ctx to more calls within this method. m, err := s.getMetaRow(ref) if err != nil { return nil, err } if m.isPacked() { length, err = capOffsetLength(m.size, offset, length) if err != nil ...
[ "func", "(", "s", "*", "storage", ")", "SubFetch", "(", "ctx", "context", ".", "Context", ",", "ref", "blob", ".", "Ref", ",", "offset", ",", "length", "int64", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "// TODO: pass ctx to more calls w...
// SubFetch returns part of a blob. // The caller must close the returned io.ReadCloser. // The Reader may return fewer than 'length' bytes. Callers should // check. The returned error should be os.ErrNotExist if the blob // doesn't exist.
[ "SubFetch", "returns", "part", "of", "a", "blob", ".", "The", "caller", "must", "close", "the", "returned", "io", ".", "ReadCloser", ".", "The", "Reader", "may", "return", "fewer", "than", "length", "bytes", ".", "Callers", "should", "check", ".", "The", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/blobpacked/subfetch.go#L35-L74
train
perkeep/perkeep
pkg/deploy/gce/handler.go
NewDeployHandlerFromConfig
func NewDeployHandlerFromConfig(host, prefix string, cfg *Config) (*DeployHandler, error) { if cfg == nil { panic("NewDeployHandlerFromConfig: nil config") } if cfg.ClientID == "" { return nil, errors.New("oauth2 clientID required in config") } if cfg.ClientSecret == "" { return nil, errors.New("oauth2 clien...
go
func NewDeployHandlerFromConfig(host, prefix string, cfg *Config) (*DeployHandler, error) { if cfg == nil { panic("NewDeployHandlerFromConfig: nil config") } if cfg.ClientID == "" { return nil, errors.New("oauth2 clientID required in config") } if cfg.ClientSecret == "" { return nil, errors.New("oauth2 clien...
[ "func", "NewDeployHandlerFromConfig", "(", "host", ",", "prefix", "string", ",", "cfg", "*", "Config", ")", "(", "*", "DeployHandler", ",", "error", ")", "{", "if", "cfg", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "cfg",...
// NewDeployHandlerFromConfig initializes a DeployHandler from cfg. // Host and prefix have the same meaning as for NewDeployHandler. cfg should not be nil.
[ "NewDeployHandlerFromConfig", "initializes", "a", "DeployHandler", "from", "cfg", ".", "Host", "and", "prefix", "have", "the", "same", "meaning", "as", "for", "NewDeployHandler", ".", "cfg", "should", "not", "be", "nil", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L128-L144
train
perkeep/perkeep
pkg/deploy/gce/handler.go
serveRoot
func (h *DeployHandler) serveRoot(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { h.serveSetup(w, r) return } _, err := r.Cookie("user") if err != nil { http.SetCookie(w, newCookie()) } camliRev := h.camliRev() if r.FormValue("WIP") == "1" { camliRev = "WORKINPROGRESS" } h.tplMu.RLoc...
go
func (h *DeployHandler) serveRoot(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { h.serveSetup(w, r) return } _, err := r.Cookie("user") if err != nil { http.SetCookie(w, newCookie()) } camliRev := h.camliRev() if r.FormValue("WIP") == "1" { camliRev = "WORKINPROGRESS" } h.tplMu.RLoc...
[ "func", "(", "h", "*", "DeployHandler", ")", "serveRoot", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "r", ".", "Method", "==", "\"", "\"", "{", "h", ".", "serveSetup", "(", "w", ",", "r", ")", ...
// if there's project as a query parameter, it means we've just created a // project for them and we're redirecting them to the form, but with the projectID // field pre-filled for them this time.
[ "if", "there", "s", "project", "as", "a", "query", "parameter", "it", "means", "we", "ve", "just", "created", "a", "project", "for", "them", "and", "we", "re", "redirecting", "them", "to", "the", "form", "but", "with", "the", "projectID", "field", "pre",...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L351-L377
train
perkeep/perkeep
pkg/deploy/gce/handler.go
serveOldInstance
func (h *DeployHandler) serveOldInstance(w http.ResponseWriter, br blob.Ref, depl *Deployer) (found bool) { inst, err := depl.Get() if err != nil { // TODO(mpl,bradfitz): log or do something more // drastic if the error is something other than // instance not found. return false } h.logger.Printf("Reusing e...
go
func (h *DeployHandler) serveOldInstance(w http.ResponseWriter, br blob.Ref, depl *Deployer) (found bool) { inst, err := depl.Get() if err != nil { // TODO(mpl,bradfitz): log or do something more // drastic if the error is something other than // instance not found. return false } h.logger.Printf("Reusing e...
[ "func", "(", "h", "*", "DeployHandler", ")", "serveOldInstance", "(", "w", "http", ".", "ResponseWriter", ",", "br", "blob", ".", "Ref", ",", "depl", "*", "Deployer", ")", "(", "found", "bool", ")", "{", "inst", ",", "err", ":=", "depl", ".", "Get", ...
// serveOldInstance looks on GCE for an instance such as defined in depl.Conf, and if // found, serves the appropriate page depending on whether the instance is usable. It does // not serve anything if the instance is not found.
[ "serveOldInstance", "looks", "on", "GCE", "for", "an", "instance", "such", "as", "defined", "in", "depl", ".", "Conf", "and", "if", "found", "serves", "the", "appropriate", "page", "depending", "on", "whether", "the", "instance", "is", "usable", ".", "It", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L564-L585
train
perkeep/perkeep
pkg/deploy/gce/handler.go
serveInstanceState
func (h *DeployHandler) serveInstanceState(w http.ResponseWriter, r *http.Request) { ctx := r.Context() if r.Method != "GET" { h.serveError(w, r, fmt.Errorf("Wrong method: %v", r.Method)) return } br := r.URL.Query().Get("instancekey") stateValue, err := h.instState.Get(br) if err != nil { http.Error(w, "un...
go
func (h *DeployHandler) serveInstanceState(w http.ResponseWriter, r *http.Request) { ctx := r.Context() if r.Method != "GET" { h.serveError(w, r, fmt.Errorf("Wrong method: %v", r.Method)) return } br := r.URL.Query().Get("instancekey") stateValue, err := h.instState.Get(br) if err != nil { http.Error(w, "un...
[ "func", "(", "h", "*", "DeployHandler", ")", "serveInstanceState", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "ctx", ":=", "r", ".", "Context", "(", ")", "\n", "if", "r", ".", "Method", "!=", "\"", "\"...
// serveInstanceState serves the state of the requested Google Cloud Engine VM creation // process. If the operation was successful, it serves a success page. If it failed, it // serves an error page. If it isn't finished yet, it replies with "running".
[ "serveInstanceState", "serves", "the", "state", "of", "the", "requested", "Google", "Cloud", "Engine", "VM", "creation", "process", ".", "If", "the", "operation", "was", "successful", "it", "serves", "a", "success", "page", ".", "If", "it", "failed", "it", "...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L612-L661
train
perkeep/perkeep
pkg/deploy/gce/handler.go
serveProgress
func (h *DeployHandler) serveProgress(w http.ResponseWriter, instanceKey blob.Ref) { h.tplMu.RLock() defer h.tplMu.RUnlock() if err := h.tpl.ExecuteTemplate(w, "withform", &TemplateData{ Prefix: h.prefix, InstanceKey: instanceKey.String(), PiggyGIF: h.piggyGIF, }); err != nil { h.logger.Printf("Coul...
go
func (h *DeployHandler) serveProgress(w http.ResponseWriter, instanceKey blob.Ref) { h.tplMu.RLock() defer h.tplMu.RUnlock() if err := h.tpl.ExecuteTemplate(w, "withform", &TemplateData{ Prefix: h.prefix, InstanceKey: instanceKey.String(), PiggyGIF: h.piggyGIF, }); err != nil { h.logger.Printf("Coul...
[ "func", "(", "h", "*", "DeployHandler", ")", "serveProgress", "(", "w", "http", ".", "ResponseWriter", ",", "instanceKey", "blob", ".", "Ref", ")", "{", "h", ".", "tplMu", ".", "RLock", "(", ")", "\n", "defer", "h", ".", "tplMu", ".", "RUnlock", "(",...
// serveProgress serves a page with some javascript code that regularly queries // the server about the progress of the requested Google Cloud Engine VM creation. // The server replies through serveInstanceState.
[ "serveProgress", "serves", "a", "page", "with", "some", "javascript", "code", "that", "regularly", "queries", "the", "server", "about", "the", "progress", "of", "the", "requested", "Google", "Cloud", "Engine", "VM", "creation", ".", "The", "server", "replies", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L666-L676
train
perkeep/perkeep
pkg/deploy/gce/handler.go
randomZone
func (h *DeployHandler) randomZone(region string) string { h.zonesMu.RLock() defer h.zonesMu.RUnlock() zones, ok := h.zones[region] if !ok { return fallbackZone } return region + zones[rand.Intn(len(zones))] }
go
func (h *DeployHandler) randomZone(region string) string { h.zonesMu.RLock() defer h.zonesMu.RUnlock() zones, ok := h.zones[region] if !ok { return fallbackZone } return region + zones[rand.Intn(len(zones))] }
[ "func", "(", "h", "*", "DeployHandler", ")", "randomZone", "(", "region", "string", ")", "string", "{", "h", ".", "zonesMu", ".", "RLock", "(", ")", "\n", "defer", "h", ".", "zonesMu", ".", "RUnlock", "(", ")", "\n", "zones", ",", "ok", ":=", "h", ...
// randomZone picks one of the zone suffixes for region and returns it // appended to region, as a fully-qualified zone name. // If the given region is invalid, the default Zone is returned instead.
[ "randomZone", "picks", "one", "of", "the", "zone", "suffixes", "for", "region", "and", "returns", "it", "appended", "to", "region", "as", "a", "fully", "-", "qualified", "zone", "name", ".", "If", "the", "given", "region", "is", "invalid", "the", "default"...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L770-L778
train
perkeep/perkeep
pkg/deploy/gce/handler.go
fromState
func fromState(r *http.Request) (br blob.Ref, xsrfToken string, err error) { params := strings.Split(r.FormValue("state"), ":") if len(params) != 2 { return br, "", fmt.Errorf("Invalid format for state parameter: %q, wanted blobRef:xsrfToken", r.FormValue("state")) } br, ok := blob.Parse(params[0]) if !ok { re...
go
func fromState(r *http.Request) (br blob.Ref, xsrfToken string, err error) { params := strings.Split(r.FormValue("state"), ":") if len(params) != 2 { return br, "", fmt.Errorf("Invalid format for state parameter: %q, wanted blobRef:xsrfToken", r.FormValue("state")) } br, ok := blob.Parse(params[0]) if !ok { re...
[ "func", "fromState", "(", "r", "*", "http", ".", "Request", ")", "(", "br", "blob", ".", "Ref", ",", "xsrfToken", "string", ",", "err", "error", ")", "{", "params", ":=", "strings", ".", "Split", "(", "r", ".", "FormValue", "(", "\"", "\"", ")", ...
// fromState parses the oauth state parameter from r to extract the blobRef of the // instance configuration and the xsrftoken that were stored during serveSetup.
[ "fromState", "parses", "the", "oauth", "state", "parameter", "from", "r", "to", "extract", "the", "blobRef", "of", "the", "instance", "configuration", "and", "the", "xsrftoken", "that", "were", "stored", "during", "serveSetup", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L799-L813
train
perkeep/perkeep
pkg/deploy/gce/handler.go
dataStores
func dataStores() (blobserver.Storage, sorted.KeyValue, error) { dataDir := os.Getenv("CAMLI_GCE_DATA") if dataDir == "" { var err error dataDir, err = ioutil.TempDir("", "camli-gcedeployer-data") if err != nil { return nil, nil, err } log.Printf("data dir not provided as env var CAMLI_GCE_DATA, so defau...
go
func dataStores() (blobserver.Storage, sorted.KeyValue, error) { dataDir := os.Getenv("CAMLI_GCE_DATA") if dataDir == "" { var err error dataDir, err = ioutil.TempDir("", "camli-gcedeployer-data") if err != nil { return nil, nil, err } log.Printf("data dir not provided as env var CAMLI_GCE_DATA, so defau...
[ "func", "dataStores", "(", ")", "(", "blobserver", ".", "Storage", ",", "sorted", ".", "KeyValue", ",", "error", ")", "{", "dataDir", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "dataDir", "==", "\"", "\"", "{", "var", "err", "erro...
// dataStores returns the blobserver that stores the instances configurations, and the kv // store for the instances states.
[ "dataStores", "returns", "the", "blobserver", "that", "stores", "the", "instances", "configurations", "and", "the", "kv", "store", "for", "the", "instances", "states", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/deploy/gce/handler.go#L886-L909
train
perkeep/perkeep
pkg/server/app/app.go
handleMasterQuery
func (a *Handler) handleMasterQuery(w http.ResponseWriter, r *http.Request) { if !(a.auth.AllowedAccess(r)&auth.OpAll == auth.OpAll) { auth.SendUnauthorized(w, r) return } if r.Method != http.MethodPost { http.Error(w, "not a POST", http.StatusMethodNotAllowed) return } if a.sh == nil { http.Error(w, "ap...
go
func (a *Handler) handleMasterQuery(w http.ResponseWriter, r *http.Request) { if !(a.auth.AllowedAccess(r)&auth.OpAll == auth.OpAll) { auth.SendUnauthorized(w, r) return } if r.Method != http.MethodPost { http.Error(w, "not a POST", http.StatusMethodNotAllowed) return } if a.sh == nil { http.Error(w, "ap...
[ "func", "(", "a", "*", "Handler", ")", "handleMasterQuery", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "!", "(", "a", ".", "auth", ".", "AllowedAccess", "(", "r", ")", "&", "auth", ".", "OpAll", ...
// handleMasterQuery allows an app to register the master query that defines the // domain limiting all subsequent search queries.
[ "handleMasterQuery", "allows", "an", "app", "to", "register", "the", "master", "query", "that", "defines", "the", "domain", "limiting", "all", "subsequent", "search", "queries", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L111-L158
train
perkeep/perkeep
pkg/server/app/app.go
handleSearch
func (a *Handler) handleSearch(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { camhttputil.BadRequestError(w, camhttputil.InvalidMethodError{}.Error()) return } if a.sh == nil { http.Error(w, "app proxy has no search handler", 500) return } a.masterQueryMu.RLock() if a.masterQue...
go
func (a *Handler) handleSearch(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { camhttputil.BadRequestError(w, camhttputil.InvalidMethodError{}.Error()) return } if a.sh == nil { http.Error(w, "app proxy has no search handler", 500) return } a.masterQueryMu.RLock() if a.masterQue...
[ "func", "(", "a", "*", "Handler", ")", "handleSearch", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "r", ".", "Method", "!=", "http", ".", "MethodPost", "{", "camhttputil", ".", "BadRequestError", "(",...
// handleSearch runs the requested search query against the search handler, and // if the results are within the domain allowed by the master query, forwards them // back to the client.
[ "handleSearch", "runs", "the", "requested", "search", "query", "against", "the", "search", "handler", "and", "if", "the", "results", "are", "within", "the", "domain", "allowed", "by", "the", "master", "query", "forwards", "them", "back", "to", "the", "client",...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L190-L230
train
perkeep/perkeep
pkg/server/app/app.go
allowProxySearchResponse
func (a *Handler) allowProxySearchResponse(sr *search.SearchResult) bool { a.masterQueryMu.RLock() defer a.masterQueryMu.RUnlock() for _, v := range sr.Blobs { if _, ok := a.domainBlobs[v.Blob]; !ok { return false } } return true }
go
func (a *Handler) allowProxySearchResponse(sr *search.SearchResult) bool { a.masterQueryMu.RLock() defer a.masterQueryMu.RUnlock() for _, v := range sr.Blobs { if _, ok := a.domainBlobs[v.Blob]; !ok { return false } } return true }
[ "func", "(", "a", "*", "Handler", ")", "allowProxySearchResponse", "(", "sr", "*", "search", ".", "SearchResult", ")", "bool", "{", "a", ".", "masterQueryMu", ".", "RLock", "(", ")", "\n", "defer", "a", ".", "masterQueryMu", ".", "RUnlock", "(", ")", "...
// allowProxySearchResponse checks whether the blobs in sr are within the domain // defined by the masterQuery, and hence if the client is allowed to get that // response.
[ "allowProxySearchResponse", "checks", "whether", "the", "blobs", "in", "sr", "are", "within", "the", "domain", "defined", "by", "the", "masterQuery", "and", "hence", "if", "the", "client", "is", "allowed", "to", "get", "that", "response", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L235-L244
train
perkeep/perkeep
pkg/server/app/app.go
randListenFn
func randListenFn(listenAddr string, randPortFn func() (int, error)) (string, error) { portIdx := strings.LastIndex(listenAddr, ":") + 1 if portIdx <= 0 || portIdx >= len(listenAddr) { return "", errors.New("invalid listen addr, no port found") } port, err := randPortFn() if err != nil { return "", err } ret...
go
func randListenFn(listenAddr string, randPortFn func() (int, error)) (string, error) { portIdx := strings.LastIndex(listenAddr, ":") + 1 if portIdx <= 0 || portIdx >= len(listenAddr) { return "", errors.New("invalid listen addr, no port found") } port, err := randPortFn() if err != nil { return "", err } ret...
[ "func", "randListenFn", "(", "listenAddr", "string", ",", "randPortFn", "func", "(", ")", "(", "int", ",", "error", ")", ")", "(", "string", ",", "error", ")", "{", "portIdx", ":=", "strings", ".", "LastIndex", "(", "listenAddr", ",", "\"", "\"", ")", ...
// randListenFn only exists to allow testing of randListen, by letting the caller // replace randPort with a func that actually has a predictable result.
[ "randListenFn", "only", "exists", "to", "allow", "testing", "of", "randListen", "by", "letting", "the", "caller", "replace", "randPort", "with", "a", "func", "that", "actually", "has", "a", "predictable", "result", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L253-L263
train
perkeep/perkeep
pkg/server/app/app.go
baseURL
func baseURL(serverBaseURL, listenAddr string) (string, error) { backendURL, err := url.Parse(serverBaseURL) if err != nil { return "", fmt.Errorf("invalid baseURL %q: %v", serverBaseURL, err) } scheme := backendURL.Scheme host := backendURL.Host if netutil.HasPort(host) { host = host[:strings.LastIndex(host,...
go
func baseURL(serverBaseURL, listenAddr string) (string, error) { backendURL, err := url.Parse(serverBaseURL) if err != nil { return "", fmt.Errorf("invalid baseURL %q: %v", serverBaseURL, err) } scheme := backendURL.Scheme host := backendURL.Host if netutil.HasPort(host) { host = host[:strings.LastIndex(host,...
[ "func", "baseURL", "(", "serverBaseURL", ",", "listenAddr", "string", ")", "(", "string", ",", "error", ")", "{", "backendURL", ",", "err", ":=", "url", ".", "Parse", "(", "serverBaseURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"",...
// baseURL returns the concatenation of the scheme and host parts of // serverBaseURL with the port of listenAddr.
[ "baseURL", "returns", "the", "concatenation", "of", "the", "scheme", "and", "host", "parts", "of", "serverBaseURL", "with", "the", "port", "of", "listenAddr", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L272-L287
train
perkeep/perkeep
pkg/server/app/app.go
FromJSONConfig
func FromJSONConfig(config jsonconfig.Obj, prefix, serverBaseURL string) (HandlerConfig, error) { hc := HandlerConfig{ Program: config.RequiredString("program"), Prefix: config.OptionalString("prefix", prefix), BackendURL: config.OptionalString("backendURL", ""), Listen: config.OptionalS...
go
func FromJSONConfig(config jsonconfig.Obj, prefix, serverBaseURL string) (HandlerConfig, error) { hc := HandlerConfig{ Program: config.RequiredString("program"), Prefix: config.OptionalString("prefix", prefix), BackendURL: config.OptionalString("backendURL", ""), Listen: config.OptionalS...
[ "func", "FromJSONConfig", "(", "config", "jsonconfig", ".", "Obj", ",", "prefix", ",", "serverBaseURL", "string", ")", "(", "HandlerConfig", ",", "error", ")", "{", "hc", ":=", "HandlerConfig", "{", "Program", ":", "config", ".", "RequiredString", "(", "\"",...
// FromJSONConfig creates an HandlerConfig from the contents of config. // prefix and serverBaseURL are used if not found in config.
[ "FromJSONConfig", "creates", "an", "HandlerConfig", "from", "the", "contents", "of", "config", ".", "prefix", "and", "serverBaseURL", "are", "used", "if", "not", "found", "in", "config", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L340-L355
train
perkeep/perkeep
pkg/server/app/app.go
InitHandler
func (a *Handler) InitHandler(hl blobserver.FindHandlerByTyper) error { apName := a.ProgramName() searchPrefix, _, err := hl.FindHandlerByType("search") if err != nil { return fmt.Errorf("No search handler configured, which is necessary for the %v app handler", apName) } var sh *search.Handler _, hi := hl.AllHa...
go
func (a *Handler) InitHandler(hl blobserver.FindHandlerByTyper) error { apName := a.ProgramName() searchPrefix, _, err := hl.FindHandlerByType("search") if err != nil { return fmt.Errorf("No search handler configured, which is necessary for the %v app handler", apName) } var sh *search.Handler _, hi := hl.AllHa...
[ "func", "(", "a", "*", "Handler", ")", "InitHandler", "(", "hl", "blobserver", ".", "FindHandlerByTyper", ")", "error", "{", "apName", ":=", "a", ".", "ProgramName", "(", ")", "\n", "searchPrefix", ",", "_", ",", "err", ":=", "hl", ".", "FindHandlerByTyp...
// InitHandler sets the app handler's search handler, if the app handler was configured // to have one with HasSearch.
[ "InitHandler", "sets", "the", "app", "handler", "s", "search", "handler", "if", "the", "app", "handler", "was", "configured", "to", "have", "one", "with", "HasSearch", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L442-L457
train
perkeep/perkeep
pkg/server/app/app.go
Quit
func (a *Handler) Quit() error { err := a.process.Signal(os.Interrupt) if err != nil { return err } c := make(chan error) go func() { _, err := a.process.Wait() c <- err }() select { case err = <-c: case <-time.After(5 * time.Second): // TODO Do we want to SIGKILL here or just leave the app alone? e...
go
func (a *Handler) Quit() error { err := a.process.Signal(os.Interrupt) if err != nil { return err } c := make(chan error) go func() { _, err := a.process.Wait() c <- err }() select { case err = <-c: case <-time.After(5 * time.Second): // TODO Do we want to SIGKILL here or just leave the app alone? e...
[ "func", "(", "a", "*", "Handler", ")", "Quit", "(", ")", "error", "{", "err", ":=", "a", ".", "process", ".", "Signal", "(", "os", ".", "Interrupt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "c", ":=", "make"...
// Quit sends the app's process a SIGINT, and waits up to 5 seconds for it // to exit, returning an error if it doesn't.
[ "Quit", "sends", "the", "app", "s", "process", "a", "SIGINT", "and", "waits", "up", "to", "5", "seconds", "for", "it", "to", "exit", "returning", "an", "error", "if", "it", "doesn", "t", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/server/app/app.go#L536-L554
train
perkeep/perkeep
pkg/cacher/cacher.go
NewCachingFetcher
func NewCachingFetcher(cache blobserver.Cache, fetcher blob.Fetcher) *CachingFetcher { return &CachingFetcher{c: cache, sf: fetcher} }
go
func NewCachingFetcher(cache blobserver.Cache, fetcher blob.Fetcher) *CachingFetcher { return &CachingFetcher{c: cache, sf: fetcher} }
[ "func", "NewCachingFetcher", "(", "cache", "blobserver", ".", "Cache", ",", "fetcher", "blob", ".", "Fetcher", ")", "*", "CachingFetcher", "{", "return", "&", "CachingFetcher", "{", "c", ":", "cache", ",", "sf", ":", "fetcher", "}", "\n", "}" ]
// NewCachingFetcher returns a CachingFetcher that fetches from // fetcher and writes to and serves from cache.
[ "NewCachingFetcher", "returns", "a", "CachingFetcher", "that", "fetches", "from", "fetcher", "and", "writes", "to", "and", "serves", "from", "cache", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/cacher/cacher.go#L38-L40
train
perkeep/perkeep
pkg/cacher/cacher.go
SetCacheHitHook
func (cf *CachingFetcher) SetCacheHitHook(fn func(br blob.Ref, rc io.ReadCloser) (io.ReadCloser, error)) { cf.cacheHitHook = fn }
go
func (cf *CachingFetcher) SetCacheHitHook(fn func(br blob.Ref, rc io.ReadCloser) (io.ReadCloser, error)) { cf.cacheHitHook = fn }
[ "func", "(", "cf", "*", "CachingFetcher", ")", "SetCacheHitHook", "(", "fn", "func", "(", "br", "blob", ".", "Ref", ",", "rc", "io", ".", "ReadCloser", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", ")", "{", "cf", ".", "cacheHitHook", "=", ...
// SetCacheHitHook sets a function that will modify the return values from Fetch // in the case of a cache hit. // Its purpose is to add potential side-effects from calling the Fetcher that would // have happened if we had had a cache miss. It is the responsibility of fn to // return a ReadCloser equivalent to the stat...
[ "SetCacheHitHook", "sets", "a", "function", "that", "will", "modify", "the", "return", "values", "from", "Fetch", "in", "the", "case", "of", "a", "cache", "hit", ".", "Its", "purpose", "is", "to", "add", "potential", "side", "-", "effects", "from", "callin...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/cacher/cacher.go#L60-L62
train
perkeep/perkeep
pkg/fs/mut.go
maybeAddChild
func (n *mutDir) maybeAddChild(name string, permanode *search.DescribedPermanode, child mutFileOrDir) { if current, ok := n.children[name]; !ok || current.permanodeString() != child.permanodeString() { child.xattr().load(permanode) n.children[name] = child } }
go
func (n *mutDir) maybeAddChild(name string, permanode *search.DescribedPermanode, child mutFileOrDir) { if current, ok := n.children[name]; !ok || current.permanodeString() != child.permanodeString() { child.xattr().load(permanode) n.children[name] = child } }
[ "func", "(", "n", "*", "mutDir", ")", "maybeAddChild", "(", "name", "string", ",", "permanode", "*", "search", ".", "DescribedPermanode", ",", "child", "mutFileOrDir", ")", "{", "if", "current", ",", "ok", ":=", "n", ".", "children", "[", "name", "]", ...
// maybeAddChild adds a child directory to this mutable directory // unless it already has one with this name and permanode.
[ "maybeAddChild", "adds", "a", "child", "directory", "to", "this", "mutable", "directory", "unless", "it", "already", "has", "one", "with", "this", "name", "and", "permanode", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/mut.go#L233-L241
train
perkeep/perkeep
pkg/fs/mut.go
Release
func (h *mutFileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) error { h.tmp.Close() os.Remove(h.tmp.Name()) h.tmp = nil return nil }
go
func (h *mutFileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) error { h.tmp.Close() os.Remove(h.tmp.Name()) h.tmp = nil return nil }
[ "func", "(", "h", "*", "mutFileHandle", ")", "Release", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "ReleaseRequest", ")", "error", "{", "h", ".", "tmp", ".", "Close", "(", ")", "\n", "os", ".", "Remove", "(", "h", ".", "...
// Release is called when a file handle is no longer needed. This is // called asynchronously after the last handle to a file is closed.
[ "Release", "is", "called", "when", "a", "file", "handle", "is", "no", "longer", "needed", ".", "This", "is", "called", "asynchronously", "after", "the", "last", "handle", "to", "a", "file", "is", "closed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/mut.go#L871-L877
train
perkeep/perkeep
pkg/fs/time.go
parseCanonicalTime
func parseCanonicalTime(in string) (time.Time, error) { if len(in) < 20 || in[len(in)-1] != 'Z' { return time.Time{}, errUnparseableTimestamp } if !(in[4] == '-' && in[7] == '-' && in[10] == 'T' && in[13] == ':' && in[16] == ':' && (in[19] == '.' || in[19] == 'Z')) { return time.Time{}, fmt.Errorf("positional...
go
func parseCanonicalTime(in string) (time.Time, error) { if len(in) < 20 || in[len(in)-1] != 'Z' { return time.Time{}, errUnparseableTimestamp } if !(in[4] == '-' && in[7] == '-' && in[10] == 'T' && in[13] == ':' && in[16] == ':' && (in[19] == '.' || in[19] == 'Z')) { return time.Time{}, fmt.Errorf("positional...
[ "func", "parseCanonicalTime", "(", "in", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "if", "len", "(", "in", ")", "<", "20", "||", "in", "[", "len", "(", "in", ")", "-", "1", "]", "!=", "'Z'", "{", "return", "time", ".", ...
// Hand crafted this parser since it's a really common path.
[ "Hand", "crafted", "this", "parser", "since", "it", "s", "a", "really", "common", "path", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/time.go#L60-L122
train
perkeep/perkeep
pkg/index/memindex.go
NewMemoryIndex
func NewMemoryIndex() *Index { ix, err := New(sorted.NewMemoryKeyValue()) if err != nil { // Nothing to fail in memory, so worth panicing about // if we ever see something. panic(err) } return ix }
go
func NewMemoryIndex() *Index { ix, err := New(sorted.NewMemoryKeyValue()) if err != nil { // Nothing to fail in memory, so worth panicing about // if we ever see something. panic(err) } return ix }
[ "func", "NewMemoryIndex", "(", ")", "*", "Index", "{", "ix", ",", "err", ":=", "New", "(", "sorted", ".", "NewMemoryKeyValue", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "// Nothing to fail in memory, so worth panicing about", "// if we ever see something...
// NewMemoryIndex returns an Index backed only by memory, for use in tests.
[ "NewMemoryIndex", "returns", "an", "Index", "backed", "only", "by", "memory", "for", "use", "in", "tests", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/memindex.go#L31-L39
train
perkeep/perkeep
app/scanningcabinet/scancab/pdf.go
pageCountPoppler
func pageCountPoppler(filename string) (cnt int, err error) { cmd := exec.Command("pdfinfo", filename) out, err := cmd.CombinedOutput() if err != nil { return cnt, fmt.Errorf("could not get page count with pdfinfo: %v, %v", err, string(out)) } sc := bufio.NewScanner(bytes.NewReader(out)) for sc.Scan() { l := ...
go
func pageCountPoppler(filename string) (cnt int, err error) { cmd := exec.Command("pdfinfo", filename) out, err := cmd.CombinedOutput() if err != nil { return cnt, fmt.Errorf("could not get page count with pdfinfo: %v, %v", err, string(out)) } sc := bufio.NewScanner(bytes.NewReader(out)) for sc.Scan() { l := ...
[ "func", "pageCountPoppler", "(", "filename", "string", ")", "(", "cnt", "int", ",", "err", "error", ")", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "filename", ")", "\n", "out", ",", "err", ":=", "cmd", ".", "CombinedOutput", "("...
// pageCountPoppler calls the tool pdfinfo from the Poppler project for // filename and parses the output for the page count which is then returned. If // any error occurs or the pages count information is not found, an error is // returned.
[ "pageCountPoppler", "calls", "the", "tool", "pdfinfo", "from", "the", "Poppler", "project", "for", "filename", "and", "parses", "the", "output", "for", "the", "page", "count", "which", "is", "then", "returned", ".", "If", "any", "error", "occurs", "or", "the...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/scancab/pdf.go#L37-L55
train
perkeep/perkeep
app/scanningcabinet/scancab/pdf.go
pageCountNative
func pageCountNative(filename string) (int, error) { f, err := os.Open(filename) if err != nil { return 0, err } defer f.Close() fi, err := f.Stat() if err != nil { return 0, err } p, err := pdf.NewReader(f, fi.Size()) if err != nil { return 0, err } c := p.NumPage() if c < 1 { return 0, errors.New(...
go
func pageCountNative(filename string) (int, error) { f, err := os.Open(filename) if err != nil { return 0, err } defer f.Close() fi, err := f.Stat() if err != nil { return 0, err } p, err := pdf.NewReader(f, fi.Size()) if err != nil { return 0, err } c := p.NumPage() if c < 1 { return 0, errors.New(...
[ "func", "pageCountNative", "(", "filename", "string", ")", "(", "int", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "defer...
// pageCountNative uses a native Go library to extract and return the number of // pages in the PDF document. It returns an error if the filename is not of a // PDF file, or if it failed to decode the PDF.
[ "pageCountNative", "uses", "a", "native", "Go", "library", "to", "extract", "and", "return", "the", "number", "of", "pages", "in", "the", "PDF", "document", ".", "It", "returns", "an", "error", "if", "the", "filename", "is", "not", "of", "a", "PDF", "fil...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/scancab/pdf.go#L60-L79
train
perkeep/perkeep
app/scanningcabinet/scancab/pdf.go
pageCount
func pageCount(filename string) (int, error) { n, err := pageCountNative(filename) if err != nil { // fallback to using pdfinfo when internal count failed n, err = pageCountPoppler(filename) } return n, err }
go
func pageCount(filename string) (int, error) { n, err := pageCountNative(filename) if err != nil { // fallback to using pdfinfo when internal count failed n, err = pageCountPoppler(filename) } return n, err }
[ "func", "pageCount", "(", "filename", "string", ")", "(", "int", ",", "error", ")", "{", "n", ",", "err", ":=", "pageCountNative", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "// fallback to using pdfinfo when internal count failed", "n", ",", ...
// pageCount returns the number of pages in the given PDF file, or an error if // it could not be determined. The function may trigger calls to external tools // to achieve a valid count after native counting has been tried without // success.
[ "pageCount", "returns", "the", "number", "of", "pages", "in", "the", "given", "PDF", "file", "or", "an", "error", "if", "it", "could", "not", "be", "determined", ".", "The", "function", "may", "trigger", "calls", "to", "external", "tools", "to", "achieve",...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/scancab/pdf.go#L85-L92
train
perkeep/perkeep
pkg/search/predicate.go
SearchHelp
func SearchHelp() string { type help struct{ Name, Description string } h := []help{} for _, p := range keywords { h = append(h, help{p.Name(), p.Description()}) } b, err := json.MarshalIndent(h, "", " ") if err != nil { return "Error marshalling" } return string(b) }
go
func SearchHelp() string { type help struct{ Name, Description string } h := []help{} for _, p := range keywords { h = append(h, help{p.Name(), p.Description()}) } b, err := json.MarshalIndent(h, "", " ") if err != nil { return "Error marshalling" } return string(b) }
[ "func", "SearchHelp", "(", ")", "string", "{", "type", "help", "struct", "{", "Name", ",", "Description", "string", "}", "\n", "h", ":=", "[", "]", "help", "{", "}", "\n", "for", "_", ",", "p", ":=", "range", "keywords", "{", "h", "=", "append", ...
// SearchHelp returns JSON of an array of predicate names and descriptions.
[ "SearchHelp", "returns", "JSON", "of", "an", "array", "of", "predicate", "names", "and", "descriptions", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/search/predicate.go#L91-L102
train
perkeep/perkeep
pkg/blobserver/receive.go
ReceiveString
func ReceiveString(ctx context.Context, dst BlobReceiver, s string) (blob.SizedRef, error) { return Receive(ctx, dst, blob.RefFromString(s), strings.NewReader(s)) }
go
func ReceiveString(ctx context.Context, dst BlobReceiver, s string) (blob.SizedRef, error) { return Receive(ctx, dst, blob.RefFromString(s), strings.NewReader(s)) }
[ "func", "ReceiveString", "(", "ctx", "context", ".", "Context", ",", "dst", "BlobReceiver", ",", "s", "string", ")", "(", "blob", ".", "SizedRef", ",", "error", ")", "{", "return", "Receive", "(", "ctx", ",", "dst", ",", "blob", ".", "RefFromString", "...
// ReceiveString uploads the blob given by the string s to dst // and returns its blobref and size.
[ "ReceiveString", "uploads", "the", "blob", "given", "by", "the", "string", "s", "to", "dst", "and", "returns", "its", "blobref", "and", "size", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/receive.go#L35-L37
train
perkeep/perkeep
pkg/blobserver/receive.go
Receive
func Receive(ctx context.Context, dst BlobReceiver, br blob.Ref, src io.Reader) (blob.SizedRef, error) { return receive(ctx, dst, br, src, true) }
go
func Receive(ctx context.Context, dst BlobReceiver, br blob.Ref, src io.Reader) (blob.SizedRef, error) { return receive(ctx, dst, br, src, true) }
[ "func", "Receive", "(", "ctx", "context", ".", "Context", ",", "dst", "BlobReceiver", ",", "br", "blob", ".", "Ref", ",", "src", "io", ".", "Reader", ")", "(", "blob", ".", "SizedRef", ",", "error", ")", "{", "return", "receive", "(", "ctx", ",", "...
// Receive wraps calling a BlobReceiver's ReceiveBlob method, // additionally providing verification of the src digest, and also // notifying the blob hub on success. // The error will be ErrCorruptBlob if the blobref didn't match.
[ "Receive", "wraps", "calling", "a", "BlobReceiver", "s", "ReceiveBlob", "method", "additionally", "providing", "verification", "of", "the", "src", "digest", "and", "also", "notifying", "the", "blob", "hub", "on", "success", ".", "The", "error", "will", "be", "...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/receive.go#L43-L45
train
perkeep/perkeep
pkg/importer/importer.go
Register
func Register(name string, im Importer) { if _, dup := importers[name]; dup { panic("Dup registration of importer " + name) } if _, dup := reservedImporterKey[name]; dup { panic("Dup registration of importer " + name) } if pt := im.Properties().PermanodeImporterType; pt != "" { if _, dup := importers[pt]; du...
go
func Register(name string, im Importer) { if _, dup := importers[name]; dup { panic("Dup registration of importer " + name) } if _, dup := reservedImporterKey[name]; dup { panic("Dup registration of importer " + name) } if pt := im.Properties().PermanodeImporterType; pt != "" { if _, dup := importers[pt]; du...
[ "func", "Register", "(", "name", "string", ",", "im", "Importer", ")", "{", "if", "_", ",", "dup", ":=", "importers", "[", "name", "]", ";", "dup", "{", "panic", "(", "\"", "\"", "+", "name", ")", "\n", "}", "\n", "if", "_", ",", "dup", ":=", ...
// Register registers a site-specific importer. It should only be called from init, // and not from concurrent goroutines.
[ "Register", "registers", "a", "site", "-", "specific", "importer", ".", "It", "should", "only", "be", "called", "from", "init", "and", "not", "from", "concurrent", "goroutines", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L171-L188
train
perkeep/perkeep
pkg/importer/importer.go
Context
func (rc *RunContext) Context() context.Context { if rc.ctx != nil { return rc.ctx } return context.Background() }
go
func (rc *RunContext) Context() context.Context { if rc.ctx != nil { return rc.ctx } return context.Background() }
[ "func", "(", "rc", "*", "RunContext", ")", "Context", "(", ")", "context", ".", "Context", "{", "if", "rc", ".", "ctx", "!=", "nil", "{", "return", "rc", ".", "ctx", "\n", "}", "\n", "return", "context", ".", "Background", "(", ")", "\n", "}" ]
// Context returns the run's context. It is always non-nil.
[ "Context", "returns", "the", "run", "s", "context", ".", "It", "is", "always", "non", "-", "nil", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L345-L350
train
perkeep/perkeep
pkg/importer/importer.go
CreateAccount
func CreateAccount(h *Host, impl string) (*RunContext, error) { imp, ok := h.imp[impl] if !ok { return nil, fmt.Errorf("host does not have a %v importer", impl) } ia, err := imp.newAccount() if err != nil { return nil, fmt.Errorf("could not create new account for importer %v: %v", impl, err) } rc := &RunCont...
go
func CreateAccount(h *Host, impl string) (*RunContext, error) { imp, ok := h.imp[impl] if !ok { return nil, fmt.Errorf("host does not have a %v importer", impl) } ia, err := imp.newAccount() if err != nil { return nil, fmt.Errorf("could not create new account for importer %v: %v", impl, err) } rc := &RunCont...
[ "func", "CreateAccount", "(", "h", "*", "Host", ",", "impl", "string", ")", "(", "*", "RunContext", ",", "error", ")", "{", "imp", ",", "ok", ":=", "h", ".", "imp", "[", "impl", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".",...
// CreateAccount creates a new importer account for the Host h, and the importer // implementation named impl. It returns a RunContext setup with that account.
[ "CreateAccount", "creates", "a", "new", "importer", "account", "for", "the", "Host", "h", "and", "the", "importer", "implementation", "named", "impl", ".", "It", "returns", "a", "RunContext", "setup", "with", "that", "account", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L354-L370
train
perkeep/perkeep
pkg/importer/importer.go
AccountsStatus
func (h *Host) AccountsStatus() (interface{}, []camtypes.StatusError) { h.didInit.Wait() var s []accountStatus var errs []camtypes.StatusError for _, impName := range h.importers { imp := h.imp[impName] accts, _ := imp.Accounts() for _, ia := range accts { as := accountStatus{ Type: impName, Href: ...
go
func (h *Host) AccountsStatus() (interface{}, []camtypes.StatusError) { h.didInit.Wait() var s []accountStatus var errs []camtypes.StatusError for _, impName := range h.importers { imp := h.imp[impName] accts, _ := imp.Accounts() for _, ia := range accts { as := accountStatus{ Type: impName, Href: ...
[ "func", "(", "h", "*", "Host", ")", "AccountsStatus", "(", ")", "(", "interface", "{", "}", ",", "[", "]", "camtypes", ".", "StatusError", ")", "{", "h", ".", "didInit", ".", "Wait", "(", ")", "\n", "var", "s", "[", "]", "accountStatus", "\n", "v...
// AccountsStatus returns the currently configured accounts and their status for // inclusion in the status.json document, as rendered by the web UI.
[ "AccountsStatus", "returns", "the", "currently", "configured", "accounts", "and", "their", "status", "for", "inclusion", "in", "the", "status", ".", "json", "document", "as", "rendered", "by", "the", "web", "UI", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L439-L471
train
perkeep/perkeep
pkg/importer/importer.go
RunImporterAccount
func (h *Host) RunImporterAccount(importerType string, accountNode blob.Ref) error { h.didInit.Wait() imp, ok := h.imp[importerType] if !ok { return fmt.Errorf("no %q importer for this account", importerType) } accounts, err := imp.Accounts() if err != nil { return err } for _, ia := range accounts { if i...
go
func (h *Host) RunImporterAccount(importerType string, accountNode blob.Ref) error { h.didInit.Wait() imp, ok := h.imp[importerType] if !ok { return fmt.Errorf("no %q importer for this account", importerType) } accounts, err := imp.Accounts() if err != nil { return err } for _, ia := range accounts { if i...
[ "func", "(", "h", "*", "Host", ")", "RunImporterAccount", "(", "importerType", "string", ",", "accountNode", "blob", ".", "Ref", ")", "error", "{", "h", ".", "didInit", ".", "Wait", "(", ")", "\n", "imp", ",", "ok", ":=", "h", ".", "imp", "[", "imp...
// RunImporterAccount runs the importerType importer on the account described in // accountNode.
[ "RunImporterAccount", "runs", "the", "importerType", "importer", "on", "the", "account", "described", "in", "accountNode", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L475-L492
train
perkeep/perkeep
pkg/importer/importer.go
HTTPClient
func (h *Host) HTTPClient() *http.Client { if h.client == nil { return http.DefaultClient } return h.client }
go
func (h *Host) HTTPClient() *http.Client { if h.client == nil { return http.DefaultClient } return h.client }
[ "func", "(", "h", "*", "Host", ")", "HTTPClient", "(", ")", "*", "http", ".", "Client", "{", "if", "h", ".", "client", "==", "nil", "{", "return", "http", ".", "DefaultClient", "\n", "}", "\n", "return", "h", ".", "client", "\n", "}" ]
// HTTPClient returns the HTTP client to use.
[ "HTTPClient", "returns", "the", "HTTP", "client", "to", "use", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1333-L1338
train
perkeep/perkeep
pkg/importer/importer.go
HTTPTransport
func (h *Host) HTTPTransport() http.RoundTripper { if h.transport == nil { return http.DefaultTransport } return h.transport }
go
func (h *Host) HTTPTransport() http.RoundTripper { if h.transport == nil { return http.DefaultTransport } return h.transport }
[ "func", "(", "h", "*", "Host", ")", "HTTPTransport", "(", ")", "http", ".", "RoundTripper", "{", "if", "h", ".", "transport", "==", "nil", "{", "return", "http", ".", "DefaultTransport", "\n", "}", "\n", "return", "h", ".", "transport", "\n", "}" ]
// HTTPTransport returns the HTTP transport to use.
[ "HTTPTransport", "returns", "the", "HTTP", "transport", "to", "use", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1341-L1346
train
perkeep/perkeep
pkg/importer/importer.go
NewObject
func (h *Host) NewObject() (*Object, error) { ctx := context.TODO() // TODO: move the NewObject method to some "ImportRun" type with a context field? pn, err := h.upload(ctx, schema.NewUnsignedPermanode()) if err != nil { return nil, err } // No need to do a describe query against it: we know it's // empty (has...
go
func (h *Host) NewObject() (*Object, error) { ctx := context.TODO() // TODO: move the NewObject method to some "ImportRun" type with a context field? pn, err := h.upload(ctx, schema.NewUnsignedPermanode()) if err != nil { return nil, err } // No need to do a describe query against it: we know it's // empty (has...
[ "func", "(", "h", "*", "Host", ")", "NewObject", "(", ")", "(", "*", "Object", ",", "error", ")", "{", "ctx", ":=", "context", ".", "TODO", "(", ")", "// TODO: move the NewObject method to some \"ImportRun\" type with a context field?", "\n", "pn", ",", "err", ...
// NewObject creates a new permanode and returns its Object wrapper.
[ "NewObject", "creates", "a", "new", "permanode", "and", "returns", "its", "Object", "wrapper", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1366-L1375
train
perkeep/perkeep
pkg/importer/importer.go
Attr
func (o *Object) Attr(attr string) string { o.mu.RLock() defer o.mu.RUnlock() if v := o.attr[attr]; len(v) > 0 { return v[0] } return "" }
go
func (o *Object) Attr(attr string) string { o.mu.RLock() defer o.mu.RUnlock() if v := o.attr[attr]; len(v) > 0 { return v[0] } return "" }
[ "func", "(", "o", "*", "Object", ")", "Attr", "(", "attr", "string", ")", "string", "{", "o", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "o", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "v", ":=", "o", ".", "attr", "[", "attr", ...
// Attr returns the object's attribute value for the provided attr, // or the empty string if unset. To distinguish between unset, // an empty string, or multiple attribute values, use Attrs.
[ "Attr", "returns", "the", "object", "s", "attribute", "value", "for", "the", "provided", "attr", "or", "the", "empty", "string", "if", "unset", ".", "To", "distinguish", "between", "unset", "an", "empty", "string", "or", "multiple", "attribute", "values", "u...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1396-L1403
train
perkeep/perkeep
pkg/importer/importer.go
Attrs
func (o *Object) Attrs(attr string) []string { o.mu.RLock() defer o.mu.RUnlock() return o.attr[attr] }
go
func (o *Object) Attrs(attr string) []string { o.mu.RLock() defer o.mu.RUnlock() return o.attr[attr] }
[ "func", "(", "o", "*", "Object", ")", "Attrs", "(", "attr", "string", ")", "[", "]", "string", "{", "o", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "o", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "o", ".", "attr", "[", "attr"...
// Attrs returns the attribute values for the provided attr.
[ "Attrs", "returns", "the", "attribute", "values", "for", "the", "provided", "attr", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1406-L1410
train
perkeep/perkeep
pkg/importer/importer.go
ForeachAttr
func (o *Object) ForeachAttr(fn func(key, value string)) { o.mu.RLock() defer o.mu.RUnlock() for k, vv := range o.attr { for _, v := range vv { fn(k, v) } } }
go
func (o *Object) ForeachAttr(fn func(key, value string)) { o.mu.RLock() defer o.mu.RUnlock() for k, vv := range o.attr { for _, v := range vv { fn(k, v) } } }
[ "func", "(", "o", "*", "Object", ")", "ForeachAttr", "(", "fn", "func", "(", "key", ",", "value", "string", ")", ")", "{", "o", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "o", ".", "mu", ".", "RUnlock", "(", ")", "\n", "for", "k", ",",...
// ForeachAttr runs fn for each of the object's attributes & values. // There might be multiple values for the same attribute. // The internal lock is held while running, so no mutations should be // made or it will deadlock.
[ "ForeachAttr", "runs", "fn", "for", "each", "of", "the", "object", "s", "attributes", "&", "values", ".", "There", "might", "be", "multiple", "values", "for", "the", "same", "attribute", ".", "The", "internal", "lock", "is", "held", "while", "running", "so...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1416-L1424
train
perkeep/perkeep
pkg/importer/importer.go
DelAttr
func (o *Object) DelAttr(key, value string) error { ctx := context.TODO() o.mu.Lock() defer o.mu.Unlock() _, err := o.h.upload(ctx, schema.NewDelAttributeClaim(o.pn, key, value)) if err != nil { return err } if o.attr == nil { o.attr = make(map[string][]string) return nil } if value == "" { delete(o.at...
go
func (o *Object) DelAttr(key, value string) error { ctx := context.TODO() o.mu.Lock() defer o.mu.Unlock() _, err := o.h.upload(ctx, schema.NewDelAttributeClaim(o.pn, key, value)) if err != nil { return err } if o.attr == nil { o.attr = make(map[string][]string) return nil } if value == "" { delete(o.at...
[ "func", "(", "o", "*", "Object", ")", "DelAttr", "(", "key", ",", "value", "string", ")", "error", "{", "ctx", ":=", "context", ".", "TODO", "(", ")", "\n", "o", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "mu", ".", "Unlock", ...
// DelAttr removes value from the values set for the attribute attr of // permaNode. If value is empty then all the values for attribute are cleared.
[ "DelAttr", "removes", "value", "from", "the", "values", "set", "for", "the", "attribute", "attr", "of", "permaNode", ".", "If", "value", "is", "empty", "then", "all", "the", "values", "for", "attribute", "are", "cleared", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1428-L1452
train
perkeep/perkeep
pkg/importer/importer.go
SetAttr
func (o *Object) SetAttr(key, value string) error { ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field? if o.Attr(key) == value { return nil } _, err := o.h.upload(ctx, schema.NewSetAttributeClaim(o.pn, key, value)) if err != nil {...
go
func (o *Object) SetAttr(key, value string) error { ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field? if o.Attr(key) == value { return nil } _, err := o.h.upload(ctx, schema.NewSetAttributeClaim(o.pn, key, value)) if err != nil {...
[ "func", "(", "o", "*", "Object", ")", "SetAttr", "(", "key", ",", "value", "string", ")", "error", "{", "ctx", ":=", "context", ".", "TODO", "(", ")", "// TODO: make it possible to get a context via Object; either new context field, or via some \"ImportRun\" field?", "\...
// SetAttr sets the attribute key to value.
[ "SetAttr", "sets", "the", "attribute", "key", "to", "value", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1455-L1471
train
perkeep/perkeep
pkg/importer/importer.go
SetAttrValues
func (o *Object) SetAttrValues(key string, attrs []string) error { ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field? exists := asSet(o.Attrs(key)) actual := asSet(attrs) o.mu.Lock() defer o.mu.Unlock() // add new values for v :=...
go
func (o *Object) SetAttrValues(key string, attrs []string) error { ctx := context.TODO() // TODO: make it possible to get a context via Object; either new context field, or via some "ImportRun" field? exists := asSet(o.Attrs(key)) actual := asSet(attrs) o.mu.Lock() defer o.mu.Unlock() // add new values for v :=...
[ "func", "(", "o", "*", "Object", ")", "SetAttrValues", "(", "key", "string", ",", "attrs", "[", "]", "string", ")", "error", "{", "ctx", ":=", "context", ".", "TODO", "(", ")", "// TODO: make it possible to get a context via Object; either new context field, or via ...
// SetAttrValues sets multi-valued attribute.
[ "SetAttrValues", "sets", "multi", "-", "valued", "attribute", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1502-L1532
train
perkeep/perkeep
pkg/importer/importer.go
ObjectFromRef
func (h *Host) ObjectFromRef(permanodeRef blob.Ref) (*Object, error) { ctx := context.TODO() res, err := h.search.Describe(ctx, &search.DescribeRequest{ BlobRef: permanodeRef, Depth: 1, }) if err != nil { return nil, err } db, ok := res.Meta[permanodeRef.String()] if !ok { return nil, fmt.Errorf("perma...
go
func (h *Host) ObjectFromRef(permanodeRef blob.Ref) (*Object, error) { ctx := context.TODO() res, err := h.search.Describe(ctx, &search.DescribeRequest{ BlobRef: permanodeRef, Depth: 1, }) if err != nil { return nil, err } db, ok := res.Meta[permanodeRef.String()] if !ok { return nil, fmt.Errorf("perma...
[ "func", "(", "h", "*", "Host", ")", "ObjectFromRef", "(", "permanodeRef", "blob", ".", "Ref", ")", "(", "*", "Object", ",", "error", ")", "{", "ctx", ":=", "context", ".", "TODO", "(", ")", "\n", "res", ",", "err", ":=", "h", ".", "search", ".", ...
// ObjectFromRef returns the object given by the named permanode
[ "ObjectFromRef", "returns", "the", "object", "given", "by", "the", "named", "permanode" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/importer.go#L1577-L1599
train
perkeep/perkeep
pkg/blobserver/memory/mem.go
NewCache
func NewCache(size int64) *Storage { return &Storage{ maxSize: size, lru: lru.New(0), // infinite items; we evict by size, not count } }
go
func NewCache(size int64) *Storage { return &Storage{ maxSize: size, lru: lru.New(0), // infinite items; we evict by size, not count } }
[ "func", "NewCache", "(", "size", "int64", ")", "*", "Storage", "{", "return", "&", "Storage", "{", "maxSize", ":", "size", ",", "lru", ":", "lru", ".", "New", "(", "0", ")", ",", "// infinite items; we evict by size, not count", "}", "\n", "}" ]
// NewCache returns a cache that won't store more than size bytes. // Blobs are evicted in LRU order.
[ "NewCache", "returns", "a", "cache", "that", "won", "t", "store", "more", "than", "size", "bytes", ".", "Blobs", "are", "evicted", "in", "LRU", "order", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L75-L80
train
perkeep/perkeep
pkg/blobserver/memory/mem.go
NumBlobs
func (s *Storage) NumBlobs() int { s.mu.RLock() defer s.mu.RUnlock() return len(s.m) }
go
func (s *Storage) NumBlobs() int { s.mu.RLock() defer s.mu.RUnlock() return len(s.m) }
[ "func", "(", "s", "*", "Storage", ")", "NumBlobs", "(", ")", "int", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "len", "(", "s", ".", "m", ")", "\n", "}" ]
// NumBlobs returns the number of blobs stored in s.
[ "NumBlobs", "returns", "the", "number", "of", "blobs", "stored", "in", "s", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L287-L291
train
perkeep/perkeep
pkg/blobserver/memory/mem.go
SumBlobSize
func (s *Storage) SumBlobSize() int64 { s.mu.RLock() defer s.mu.RUnlock() return s.size }
go
func (s *Storage) SumBlobSize() int64 { s.mu.RLock() defer s.mu.RUnlock() return s.size }
[ "func", "(", "s", "*", "Storage", ")", "SumBlobSize", "(", ")", "int64", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "size", "\n", "}" ]
// SumBlobSize returns the total size in bytes of all the blobs in s.
[ "SumBlobSize", "returns", "the", "total", "size", "in", "bytes", "of", "all", "the", "blobs", "in", "s", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L294-L298
train
perkeep/perkeep
pkg/blobserver/memory/mem.go
BlobrefStrings
func (s *Storage) BlobrefStrings() []string { s.mu.RLock() defer s.mu.RUnlock() sorted := make([]string, 0, len(s.m)) for br := range s.m { sorted = append(sorted, br.String()) } sort.Strings(sorted) return sorted }
go
func (s *Storage) BlobrefStrings() []string { s.mu.RLock() defer s.mu.RUnlock() sorted := make([]string, 0, len(s.m)) for br := range s.m { sorted = append(sorted, br.String()) } sort.Strings(sorted) return sorted }
[ "func", "(", "s", "*", "Storage", ")", "BlobrefStrings", "(", ")", "[", "]", "string", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n", "sorted", ":=", "make", "(", "[", "]", "string", ...
// BlobrefStrings returns the sorted stringified blobrefs stored in s.
[ "BlobrefStrings", "returns", "the", "sorted", "stringified", "blobrefs", "stored", "in", "s", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L301-L310
train
perkeep/perkeep
pkg/blobserver/memory/mem.go
Stats
func (s *Storage) Stats() (blobsFetched, bytesFetched int64) { return atomic.LoadInt64(&s.blobsFetched), atomic.LoadInt64(&s.bytesFetched) }
go
func (s *Storage) Stats() (blobsFetched, bytesFetched int64) { return atomic.LoadInt64(&s.blobsFetched), atomic.LoadInt64(&s.bytesFetched) }
[ "func", "(", "s", "*", "Storage", ")", "Stats", "(", ")", "(", "blobsFetched", ",", "bytesFetched", "int64", ")", "{", "return", "atomic", ".", "LoadInt64", "(", "&", "s", ".", "blobsFetched", ")", ",", "atomic", ".", "LoadInt64", "(", "&", "s", ".",...
// Stats returns the number of blobs and number of bytes that were fetched from s.
[ "Stats", "returns", "the", "number", "of", "blobs", "and", "number", "of", "bytes", "that", "were", "fetched", "from", "s", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/memory/mem.go#L313-L315
train
perkeep/perkeep
internal/netutil/ident.go
ConnUserid
func ConnUserid(conn net.Conn) (uid int, err error) { return AddrPairUserid(conn.LocalAddr(), conn.RemoteAddr()) }
go
func ConnUserid(conn net.Conn) (uid int, err error) { return AddrPairUserid(conn.LocalAddr(), conn.RemoteAddr()) }
[ "func", "ConnUserid", "(", "conn", "net", ".", "Conn", ")", "(", "uid", "int", ",", "err", "error", ")", "{", "return", "AddrPairUserid", "(", "conn", ".", "LocalAddr", "(", ")", ",", "conn", ".", "RemoteAddr", "(", ")", ")", "\n", "}" ]
// ConnUserid returns the uid that owns the given localhost connection. // The returned error is ErrNotFound if the connection wasn't found.
[ "ConnUserid", "returns", "the", "uid", "that", "owns", "the", "given", "localhost", "connection", ".", "The", "returned", "error", "is", "ErrNotFound", "if", "the", "connection", "wasn", "t", "found", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/netutil/ident.go#L44-L46
train
perkeep/perkeep
website/pk-web/godoc.go
writeNode
func writeNode(w io.Writer, fset *token.FileSet, x interface{}) { // convert trailing tabs into spaces using a tconv filter // to ensure a good outcome in most browsers (there may still // be tabs in comments and strings, but converting those into // the right number of spaces is much harder) // // TODO(gri) reth...
go
func writeNode(w io.Writer, fset *token.FileSet, x interface{}) { // convert trailing tabs into spaces using a tconv filter // to ensure a good outcome in most browsers (there may still // be tabs in comments and strings, but converting those into // the right number of spaces is much harder) // // TODO(gri) reth...
[ "func", "writeNode", "(", "w", "io", ".", "Writer", ",", "fset", "*", "token", ".", "FileSet", ",", "x", "interface", "{", "}", ")", "{", "// convert trailing tabs into spaces using a tconv filter", "// to ensure a good outcome in most browsers (there may still", "// be t...
// Write an AST node to w.
[ "Write", "an", "AST", "node", "to", "w", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/godoc.go#L138-L152
train
perkeep/perkeep
server/perkeepd/ui/goui/selectallbutton/selectall.go
getQuery
func (d SelectAllBtnDef) getQuery() *search.SearchQuery { predicate := d.Props().callbacks.GetQuery() if !strings.HasPrefix(predicate, "ref:") { return &search.SearchQuery{ Limit: -1, Expression: predicate, } } // If we've got a ref: predicate, assume the given blobRef is a container, and // find i...
go
func (d SelectAllBtnDef) getQuery() *search.SearchQuery { predicate := d.Props().callbacks.GetQuery() if !strings.HasPrefix(predicate, "ref:") { return &search.SearchQuery{ Limit: -1, Expression: predicate, } } // If we've got a ref: predicate, assume the given blobRef is a container, and // find i...
[ "func", "(", "d", "SelectAllBtnDef", ")", "getQuery", "(", ")", "*", "search", ".", "SearchQuery", "{", "predicate", ":=", "d", ".", "Props", "(", ")", ".", "callbacks", ".", "GetQuery", "(", ")", "\n", "if", "!", "strings", ".", "HasPrefix", "(", "p...
// getQuery returns the query corresponding to the current search in the web UI.
[ "getQuery", "returns", "the", "query", "corresponding", "to", "the", "current", "search", "in", "the", "web", "UI", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/selectallbutton/selectall.go#L145-L173
train
perkeep/perkeep
server/perkeepd/ui/goui/selectallbutton/selectall.go
findAll
func (d SelectAllBtnDef) findAll() (map[string]bool, error) { query := d.getQuery() if query == nil { return nil, nil } authToken := d.Props().authToken am, err := auth.TokenOrNone(authToken) if err != nil { return nil, fmt.Errorf("Error setting up auth: %v", err) } cl, err := client.New(client.OptionAuthMo...
go
func (d SelectAllBtnDef) findAll() (map[string]bool, error) { query := d.getQuery() if query == nil { return nil, nil } authToken := d.Props().authToken am, err := auth.TokenOrNone(authToken) if err != nil { return nil, fmt.Errorf("Error setting up auth: %v", err) } cl, err := client.New(client.OptionAuthMo...
[ "func", "(", "d", "SelectAllBtnDef", ")", "findAll", "(", ")", "(", "map", "[", "string", "]", "bool", ",", "error", ")", "{", "query", ":=", "d", ".", "getQuery", "(", ")", "\n", "if", "query", "==", "nil", "{", "return", "nil", ",", "nil", "\n"...
// findAll returns all the permanodes matching the current web UI search // session. The javascript UI code uses a javascript object with blobRefs as // properties to represent a user's selection of permanodes. Since gopherjs // converts a Go map to a javascript object, findAll returns such a map so it // matches direc...
[ "findAll", "returns", "all", "the", "permanodes", "matching", "the", "current", "web", "UI", "search", "session", ".", "The", "javascript", "UI", "code", "uses", "a", "javascript", "object", "with", "blobRefs", "as", "properties", "to", "represent", "a", "user...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/selectallbutton/selectall.go#L180-L203
train
perkeep/perkeep
pkg/app/app.go
Client
func Client() (*client.Client, error) { server := os.Getenv("CAMLI_API_HOST") if server == "" { return nil, errors.New("CAMLI_API_HOST var not set") } am, err := basicAuth() if err != nil { return nil, err } return client.New( client.OptionNoExternalConfig(), client.OptionServer(server), client.OptionA...
go
func Client() (*client.Client, error) { server := os.Getenv("CAMLI_API_HOST") if server == "" { return nil, errors.New("CAMLI_API_HOST var not set") } am, err := basicAuth() if err != nil { return nil, err } return client.New( client.OptionNoExternalConfig(), client.OptionServer(server), client.OptionA...
[ "func", "Client", "(", ")", "(", "*", "client", ".", "Client", ",", "error", ")", "{", "server", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "server", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\""...
// Client returns a Perkeep client as defined by environment variables // automatically supplied by the Perkeep server host.
[ "Client", "returns", "a", "Perkeep", "client", "as", "defined", "by", "environment", "variables", "automatically", "supplied", "by", "the", "Perkeep", "server", "host", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/app/app.go#L55-L69
train
perkeep/perkeep
cmd/pk/sync.go
storageFromParam
func (c *syncCmd) storageFromParam(which storageType, val string) (blobserver.Storage, error) { var httpClient *http.Client if val == "" { switch which { case storageThird: return nil, nil case storageSource: discl := c.discoClient() src, err := discl.BlobRoot() if err != nil { return nil, fmt....
go
func (c *syncCmd) storageFromParam(which storageType, val string) (blobserver.Storage, error) { var httpClient *http.Client if val == "" { switch which { case storageThird: return nil, nil case storageSource: discl := c.discoClient() src, err := discl.BlobRoot() if err != nil { return nil, fmt....
[ "func", "(", "c", "*", "syncCmd", ")", "storageFromParam", "(", "which", "storageType", ",", "val", "string", ")", "(", "blobserver", ".", "Storage", ",", "error", ")", "{", "var", "httpClient", "*", "http", ".", "Client", "\n\n", "if", "val", "==", "\...
// which is one of "src", "dest", or "thirdleg"
[ "which", "is", "one", "of", "src", "dest", "or", "thirdleg" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk/sync.go#L160-L214
train
perkeep/perkeep
pkg/client/remove.go
RemoveBlobs
func (c *Client) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error { if c.sto != nil { return c.sto.RemoveBlobs(ctx, blobs) } pfx, err := c.prefix() if err != nil { return err } url_ := fmt.Sprintf("%s/camli/remove", pfx) params := make(url.Values) // "blobN" -> BlobRefStr needsDelete := ...
go
func (c *Client) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error { if c.sto != nil { return c.sto.RemoveBlobs(ctx, blobs) } pfx, err := c.prefix() if err != nil { return err } url_ := fmt.Sprintf("%s/camli/remove", pfx) params := make(url.Values) // "blobN" -> BlobRefStr needsDelete := ...
[ "func", "(", "c", "*", "Client", ")", "RemoveBlobs", "(", "ctx", "context", ".", "Context", ",", "blobs", "[", "]", "blob", ".", "Ref", ")", "error", "{", "if", "c", ".", "sto", "!=", "nil", "{", "return", "c", ".", "sto", ".", "RemoveBlobs", "("...
// RemoveBlobs removes the list of blobs. An error is returned if the // server failed to remove a blob. Removing a non-existent blob isn't // an error.
[ "RemoveBlobs", "removes", "the", "list", "of", "blobs", ".", "An", "error", "is", "returned", "if", "the", "server", "failed", "to", "remove", "a", "blob", ".", "Removing", "a", "non", "-", "existent", "blob", "isn", "t", "an", "error", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/remove.go#L35-L87
train
perkeep/perkeep
pkg/client/remove.go
RemoveBlob
func (c *Client) RemoveBlob(ctx context.Context, b blob.Ref) error { return c.RemoveBlobs(ctx, []blob.Ref{b}) }
go
func (c *Client) RemoveBlob(ctx context.Context, b blob.Ref) error { return c.RemoveBlobs(ctx, []blob.Ref{b}) }
[ "func", "(", "c", "*", "Client", ")", "RemoveBlob", "(", "ctx", "context", ".", "Context", ",", "b", "blob", ".", "Ref", ")", "error", "{", "return", "c", ".", "RemoveBlobs", "(", "ctx", ",", "[", "]", "blob", ".", "Ref", "{", "b", "}", ")", "\...
// RemoveBlob removes the provided blob. An error is returned if the server failed to remove // the blob. Removing a non-existent blob isn't an error.
[ "RemoveBlob", "removes", "the", "provided", "blob", ".", "An", "error", "is", "returned", "if", "the", "server", "failed", "to", "remove", "the", "blob", ".", "Removing", "a", "non", "-", "existent", "blob", "isn", "t", "an", "error", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/remove.go#L91-L93
train
perkeep/perkeep
cmd/pk/list.go
setClient
func (c *listCmd) setClient() error { ss, err := c.syncCmd.storageFromParam("src", c.syncCmd.src) if err != nil { fmt.Errorf("Could not set client for describe requests: %v", err) } var ok bool c.cl, ok = ss.(*client.Client) if !ok { return fmt.Errorf("storageFromParam returned a %T, was expecting a *client.C...
go
func (c *listCmd) setClient() error { ss, err := c.syncCmd.storageFromParam("src", c.syncCmd.src) if err != nil { fmt.Errorf("Could not set client for describe requests: %v", err) } var ok bool c.cl, ok = ss.(*client.Client) if !ok { return fmt.Errorf("storageFromParam returned a %T, was expecting a *client.C...
[ "func", "(", "c", "*", "listCmd", ")", "setClient", "(", ")", "error", "{", "ss", ",", "err", ":=", "c", ".", "syncCmd", ".", "storageFromParam", "(", "\"", "\"", ",", "c", ".", "syncCmd", ".", "src", ")", "\n", "if", "err", "!=", "nil", "{", "...
// setClient configures a client for c, for the describe requests.
[ "setClient", "configures", "a", "client", "for", "c", "for", "the", "describe", "requests", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/cmd/pk/list.go#L147-L158
train
perkeep/perkeep
internal/httputil/faketransport.go
NewRegexpFakeTransport
func NewRegexpFakeTransport(allMatchers []*Matcher) (http.RoundTripper, error) { var result regexpFakeTransport = []*regexPair{} for _, matcher := range allMatchers { r, err := regexp.Compile(matcher.URLRegex) if err != nil { return nil, err } pair := regexPair{r, matcher.Fn} result = append(result, &pai...
go
func NewRegexpFakeTransport(allMatchers []*Matcher) (http.RoundTripper, error) { var result regexpFakeTransport = []*regexPair{} for _, matcher := range allMatchers { r, err := regexp.Compile(matcher.URLRegex) if err != nil { return nil, err } pair := regexPair{r, matcher.Fn} result = append(result, &pai...
[ "func", "NewRegexpFakeTransport", "(", "allMatchers", "[", "]", "*", "Matcher", ")", "(", "http", ".", "RoundTripper", ",", "error", ")", "{", "var", "result", "regexpFakeTransport", "=", "[", "]", "*", "regexPair", "{", "}", "\n", "for", "_", ",", "matc...
// NewRegexpFakeTransport takes a slice of Matchers and returns an // http.RoundTripper that will apply the function associated with the // first UrlRegex that matches.
[ "NewRegexpFakeTransport", "takes", "a", "slice", "of", "Matchers", "and", "returns", "an", "http", ".", "RoundTripper", "that", "will", "apply", "the", "function", "associated", "with", "the", "first", "UrlRegex", "that", "matches", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/faketransport.go#L57-L68
train
perkeep/perkeep
internal/httputil/faketransport.go
FileResponder
func FileResponder(filename string) func() *http.Response { return func() *http.Response { f, err := os.Open(filename) if err != nil { return &http.Response{StatusCode: 404, Status: "404 Not Found", Body: types.EmptyBody} } return &http.Response{StatusCode: 200, Status: "200 OK", Body: f} } }
go
func FileResponder(filename string) func() *http.Response { return func() *http.Response { f, err := os.Open(filename) if err != nil { return &http.Response{StatusCode: 404, Status: "404 Not Found", Body: types.EmptyBody} } return &http.Response{StatusCode: 200, Status: "200 OK", Body: f} } }
[ "func", "FileResponder", "(", "filename", "string", ")", "func", "(", ")", "*", "http", ".", "Response", "{", "return", "func", "(", ")", "*", "http", ".", "Response", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "filename", ")", "\n", "if",...
// FileResponder returns an HTTP response generator that returns the // contents of the named file.
[ "FileResponder", "returns", "an", "HTTP", "response", "generator", "that", "returns", "the", "contents", "of", "the", "named", "file", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/faketransport.go#L89-L97
train
perkeep/perkeep
internal/httputil/faketransport.go
StaticResponder
func StaticResponder(res string) func() *http.Response { _, err := http.ReadResponse(bufio.NewReader(strings.NewReader(res)), nil) if err != nil { panic("Invalid response given to StaticResponder: " + err.Error()) } return func() *http.Response { res, _ := http.ReadResponse(bufio.NewReader(strings.NewReader(res...
go
func StaticResponder(res string) func() *http.Response { _, err := http.ReadResponse(bufio.NewReader(strings.NewReader(res)), nil) if err != nil { panic("Invalid response given to StaticResponder: " + err.Error()) } return func() *http.Response { res, _ := http.ReadResponse(bufio.NewReader(strings.NewReader(res...
[ "func", "StaticResponder", "(", "res", "string", ")", "func", "(", ")", "*", "http", ".", "Response", "{", "_", ",", "err", ":=", "http", ".", "ReadResponse", "(", "bufio", ".", "NewReader", "(", "strings", ".", "NewReader", "(", "res", ")", ")", ","...
// StaticResponder returns an HTTP response generator that parses res // for an entire HTTP response, including headers and body.
[ "StaticResponder", "returns", "an", "HTTP", "response", "generator", "that", "parses", "res", "for", "an", "entire", "HTTP", "response", "including", "headers", "and", "body", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/httputil/faketransport.go#L101-L110
train