id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
161,300
keybase/client
go/kbfs/libpages/config/config_v1.go
Encode
func (c *V1) Encode(w io.Writer, prettify bool) error { encoder := json.NewEncoder(w) if prettify { encoder.SetIndent("", strings.Repeat(" ", 2)) } return encoder.Encode(c) }
go
func (c *V1) Encode(w io.Writer, prettify bool) error { encoder := json.NewEncoder(w) if prettify { encoder.SetIndent("", strings.Repeat(" ", 2)) } return encoder.Encode(c) }
[ "func", "(", "c", "*", "V1", ")", "Encode", "(", "w", "io", ".", "Writer", ",", "prettify", "bool", ")", "error", "{", "encoder", ":=", "json", ".", "NewEncoder", "(", "w", ")", "\n", "if", "prettify", "{", "encoder", ".", "SetIndent", "(", "\"", ...
// Encode implements the Config interface.
[ "Encode", "implements", "the", "Config", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/config/config_v1.go#L122-L128
161,301
keybase/client
go/kbfs/libpages/config/config_v1.go
HasBcryptPasswords
func (c *V1) HasBcryptPasswords() (bool, error) { if err := c.EnsureInit(); err != nil { return false, err } for _, pass := range c.users { if pass.passwordType() == passwordTypeBcrypt { return true, nil } } return false, nil }
go
func (c *V1) HasBcryptPasswords() (bool, error) { if err := c.EnsureInit(); err != nil { return false, err } for _, pass := range c.users { if pass.passwordType() == passwordTypeBcrypt { return true, nil } } return false, nil }
[ "func", "(", "c", "*", "V1", ")", "HasBcryptPasswords", "(", ")", "(", "bool", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "EnsureInit", "(", ")", ";", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "for", "_"...
// HasBcryptPasswords checks if any password hash in the config is a bcrypt // hash. This method is temporary for migration and will go away.
[ "HasBcryptPasswords", "checks", "if", "any", "password", "hash", "in", "the", "config", "is", "a", "bcrypt", "hash", ".", "This", "method", "is", "temporary", "for", "migration", "and", "will", "go", "away", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/config/config_v1.go#L147-L157
161,302
keybase/client
go/teams/box_audit.go
BoxAuditTeam
func (a *BoxAuditor) BoxAuditTeam(mctx libkb.MetaContext, teamID keybase1.TeamID) (attempt *keybase1.BoxAuditAttempt, err error) { mctx = a.initMctx(mctx) defer mctx.TraceTimed(fmt.Sprintf("BoxAuditTeam(%s)", teamID), func() error { return err })() if !ShouldRunBoxAudit(mctx) { mctx.Debug("Box auditor feature flagged off; not auditing...") return nil, nil } lock := a.locktab.AcquireOnName(mctx.Ctx(), mctx.G(), teamID.String()) defer lock.Release(mctx.Ctx()) return a.boxAuditTeamLocked(mctx, teamID) }
go
func (a *BoxAuditor) BoxAuditTeam(mctx libkb.MetaContext, teamID keybase1.TeamID) (attempt *keybase1.BoxAuditAttempt, err error) { mctx = a.initMctx(mctx) defer mctx.TraceTimed(fmt.Sprintf("BoxAuditTeam(%s)", teamID), func() error { return err })() if !ShouldRunBoxAudit(mctx) { mctx.Debug("Box auditor feature flagged off; not auditing...") return nil, nil } lock := a.locktab.AcquireOnName(mctx.Ctx(), mctx.G(), teamID.String()) defer lock.Release(mctx.Ctx()) return a.boxAuditTeamLocked(mctx, teamID) }
[ "func", "(", "a", "*", "BoxAuditor", ")", "BoxAuditTeam", "(", "mctx", "libkb", ".", "MetaContext", ",", "teamID", "keybase1", ".", "TeamID", ")", "(", "attempt", "*", "keybase1", ".", "BoxAuditAttempt", ",", "err", "error", ")", "{", "mctx", "=", "a", ...
// BoxAuditTeam performs one attempt of a BoxAudit. If one is in progress for // the teamid, make a new attempt. If exceeded max tries or hit a malicious // error, return a fatal error. Otherwise, make a new audit and fill it with // one attempt. If the attempt failed nonfatally, enqueue it in the retry // queue. If it failed fatally, add it to the jail. If it failed for reasons // that are purely client-side, like a disk write error, we retry it as well // but distinguish it from a failure the server could have possibly maliciously // caused.
[ "BoxAuditTeam", "performs", "one", "attempt", "of", "a", "BoxAudit", ".", "If", "one", "is", "in", "progress", "for", "the", "teamid", "make", "a", "new", "attempt", ".", "If", "exceeded", "max", "tries", "or", "hit", "a", "malicious", "error", "return", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/box_audit.go#L169-L181
161,303
keybase/client
go/teams/box_audit.go
RetryNextBoxAudit
func (a *BoxAuditor) RetryNextBoxAudit(mctx libkb.MetaContext) (attempt *keybase1.BoxAuditAttempt, err error) { mctx = a.initMctx(mctx) defer mctx.TraceTimed("RetryNextBoxAudit", func() error { return err })() if !ShouldRunBoxAudit(mctx) { mctx.Debug("Box auditor feature flagged off; not RetryNextBoxAuditing...") return nil, nil } queueItem, err := a.popRetryQueue(mctx) if err != nil { return nil, err } if queueItem == nil { mctx.Debug("Retry queue empty, succeeding vacuously") return nil, nil } return a.BoxAuditTeam(mctx, (*queueItem).TeamID) }
go
func (a *BoxAuditor) RetryNextBoxAudit(mctx libkb.MetaContext) (attempt *keybase1.BoxAuditAttempt, err error) { mctx = a.initMctx(mctx) defer mctx.TraceTimed("RetryNextBoxAudit", func() error { return err })() if !ShouldRunBoxAudit(mctx) { mctx.Debug("Box auditor feature flagged off; not RetryNextBoxAuditing...") return nil, nil } queueItem, err := a.popRetryQueue(mctx) if err != nil { return nil, err } if queueItem == nil { mctx.Debug("Retry queue empty, succeeding vacuously") return nil, nil } return a.BoxAuditTeam(mctx, (*queueItem).TeamID) }
[ "func", "(", "a", "*", "BoxAuditor", ")", "RetryNextBoxAudit", "(", "mctx", "libkb", ".", "MetaContext", ")", "(", "attempt", "*", "keybase1", ".", "BoxAuditAttempt", ",", "err", "error", ")", "{", "mctx", "=", "a", ".", "initMctx", "(", "mctx", ")", "...
// RetryNextBoxAudit selects a teamID from the box audit retry queue and performs another box audit.
[ "RetryNextBoxAudit", "selects", "a", "teamID", "from", "the", "box", "audit", "retry", "queue", "and", "performs", "another", "box", "audit", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/box_audit.go#L302-L320
161,304
keybase/client
go/teams/box_audit.go
BoxAuditRandomTeam
func (a *BoxAuditor) BoxAuditRandomTeam(mctx libkb.MetaContext) (attempt *keybase1.BoxAuditAttempt, err error) { mctx = a.initMctx(mctx) defer mctx.TraceTimed("BoxAuditRandomTeam", func() error { return err })() if !ShouldRunBoxAudit(mctx) { mctx.Debug("Box auditor feature flagged off; not BoxAuditRandomTeaming...") return nil, nil } teamID, err := randomKnownTeamID(mctx) if err != nil { return nil, err } if teamID == nil { mctx.Debug("No known teams to audit in db, skipping box audit") return nil, nil } return a.BoxAuditTeam(mctx, *teamID) }
go
func (a *BoxAuditor) BoxAuditRandomTeam(mctx libkb.MetaContext) (attempt *keybase1.BoxAuditAttempt, err error) { mctx = a.initMctx(mctx) defer mctx.TraceTimed("BoxAuditRandomTeam", func() error { return err })() if !ShouldRunBoxAudit(mctx) { mctx.Debug("Box auditor feature flagged off; not BoxAuditRandomTeaming...") return nil, nil } teamID, err := randomKnownTeamID(mctx) if err != nil { return nil, err } if teamID == nil { mctx.Debug("No known teams to audit in db, skipping box audit") return nil, nil } return a.BoxAuditTeam(mctx, *teamID) }
[ "func", "(", "a", "*", "BoxAuditor", ")", "BoxAuditRandomTeam", "(", "mctx", "libkb", ".", "MetaContext", ")", "(", "attempt", "*", "keybase1", ".", "BoxAuditAttempt", ",", "err", "error", ")", "{", "mctx", "=", "a", ".", "initMctx", "(", "mctx", ")", ...
// BoxAuditRandomTeam selects a random known team from the slow team or FTL // cache, including implicit teams, and audits it. It may succeed trivially // because, for example, user is a reader and so does not have permissions to // do a box audit or the team is an open team.
[ "BoxAuditRandomTeam", "selects", "a", "random", "known", "team", "from", "the", "slow", "team", "or", "FTL", "cache", "including", "implicit", "teams", "and", "audits", "it", ".", "It", "may", "succeed", "trivially", "because", "for", "example", "user", "is", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/box_audit.go#L326-L345
161,305
keybase/client
go/teams/box_audit.go
calculateChainSummary
func calculateChainSummary(mctx libkb.MetaContext, team *Team) (summary *boxPublicSummary, err error) { defer mctx.TraceTimed(fmt.Sprintf("calculateChainSummary(%s)", team.ID), func() error { return err })() merkleSeqno, err := merkleSeqnoAtGenerationInception(mctx, team.chain()) if err != nil { return nil, err } return calculateSummaryAtMerkleSeqno(mctx, team, merkleSeqno, true) }
go
func calculateChainSummary(mctx libkb.MetaContext, team *Team) (summary *boxPublicSummary, err error) { defer mctx.TraceTimed(fmt.Sprintf("calculateChainSummary(%s)", team.ID), func() error { return err })() merkleSeqno, err := merkleSeqnoAtGenerationInception(mctx, team.chain()) if err != nil { return nil, err } return calculateSummaryAtMerkleSeqno(mctx, team, merkleSeqno, true) }
[ "func", "calculateChainSummary", "(", "mctx", "libkb", ".", "MetaContext", ",", "team", "*", "Team", ")", "(", "summary", "*", "boxPublicSummary", ",", "err", "error", ")", "{", "defer", "mctx", ".", "TraceTimed", "(", "fmt", ".", "Sprintf", "(", "\"", "...
// calculateChainSummary calculates the box summary as implied by the team sigchain and previous links, // using the last known rotation and subsequent additions as markers for PUK freshness.
[ "calculateChainSummary", "calculates", "the", "box", "summary", "as", "implied", "by", "the", "team", "sigchain", "and", "previous", "links", "using", "the", "last", "known", "rotation", "and", "subsequent", "additions", "as", "markers", "for", "PUK", "freshness",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/box_audit.go#L842-L850
161,306
keybase/client
go/teams/box_audit.go
merkleSeqnoAtGenerationInception
func merkleSeqnoAtGenerationInception(mctx libkb.MetaContext, teamchain *TeamSigChainState) (merkleSeqno keybase1.Seqno, err error) { ptk, err := teamchain.GetLatestPerTeamKey() if err != nil { return 0, err } sigchainSeqno := ptk.Seqno root := teamchain.GetMerkleRoots()[sigchainSeqno] return root.Seqno, nil }
go
func merkleSeqnoAtGenerationInception(mctx libkb.MetaContext, teamchain *TeamSigChainState) (merkleSeqno keybase1.Seqno, err error) { ptk, err := teamchain.GetLatestPerTeamKey() if err != nil { return 0, err } sigchainSeqno := ptk.Seqno root := teamchain.GetMerkleRoots()[sigchainSeqno] return root.Seqno, nil }
[ "func", "merkleSeqnoAtGenerationInception", "(", "mctx", "libkb", ".", "MetaContext", ",", "teamchain", "*", "TeamSigChainState", ")", "(", "merkleSeqno", "keybase1", ".", "Seqno", ",", "err", "error", ")", "{", "ptk", ",", "err", ":=", "teamchain", ".", "GetL...
// merkleSeqnoAtGenerationInception assumes TeamSigChainState.MerkleRoots is populated
[ "merkleSeqnoAtGenerationInception", "assumes", "TeamSigChainState", ".", "MerkleRoots", "is", "populated" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/box_audit.go#L971-L979
161,307
keybase/client
go/client/help.go
init
func init() { cli.AppHelpTemplate = AppHelpTemplate cli.CommandHelpTemplate = CommandHelpTemplate cli.SubcommandHelpTemplate = SubcommandHelpTemplate }
go
func init() { cli.AppHelpTemplate = AppHelpTemplate cli.CommandHelpTemplate = CommandHelpTemplate cli.SubcommandHelpTemplate = SubcommandHelpTemplate }
[ "func", "init", "(", ")", "{", "cli", ".", "AppHelpTemplate", "=", "AppHelpTemplate", "\n", "cli", ".", "CommandHelpTemplate", "=", "CommandHelpTemplate", "\n", "cli", ".", "SubcommandHelpTemplate", "=", "SubcommandHelpTemplate", "\n", "}" ]
// Custom help templates for cli package
[ "Custom", "help", "templates", "for", "cli", "package" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/help.go#L169-L173
161,308
keybase/client
go/teams/chain_parse.go
ParseTeamChainLink
func ParseTeamChainLink(link string) (res SCChainLink, err error) { err = json.Unmarshal([]byte(link), &res) return res, err }
go
func ParseTeamChainLink(link string) (res SCChainLink, err error) { err = json.Unmarshal([]byte(link), &res) return res, err }
[ "func", "ParseTeamChainLink", "(", "link", "string", ")", "(", "res", "SCChainLink", ",", "err", "error", ")", "{", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "link", ")", ",", "&", "res", ")", "\n", "return", "res", ",", "er...
// Parse a chain link from a string. Just parses, does not validate.
[ "Parse", "a", "chain", "link", "from", "a", "string", ".", "Just", "parses", "does", "not", "validate", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/chain_parse.go#L213-L216
161,309
keybase/client
go/engine/common.go
findDeviceKeys
func findDeviceKeys(m libkb.MetaContext, me *libkb.User) (*libkb.DeviceWithKeys, error) { // need to be logged in to get a device key (unlocked) lin, _ := isLoggedIn(m) if !lin { return nil, libkb.LoginRequiredError{} } // Get unlocked device for decryption and signing // passing in nil SecretUI since we don't know the passphrase. m.Debug("findDeviceKeys: getting device encryption key") parg := libkb.SecretKeyPromptArg{ Ska: libkb.SecretKeyArg{ Me: me, KeyType: libkb.DeviceEncryptionKeyType, }, Reason: "change passphrase", } encKey, err := m.G().Keyrings.GetSecretKeyWithPrompt(m, parg) if err != nil { return nil, err } m.Debug("findDeviceKeys: got device encryption key") m.Debug("findDeviceKeys: getting device signing key") parg.Ska.KeyType = libkb.DeviceSigningKeyType sigKey, err := m.G().Keyrings.GetSecretKeyWithPrompt(m, parg) if err != nil { return nil, err } m.Debug("findDeviceKeys: got device signing key") return libkb.NewDeviceWithKeysOnly(sigKey, encKey), nil }
go
func findDeviceKeys(m libkb.MetaContext, me *libkb.User) (*libkb.DeviceWithKeys, error) { // need to be logged in to get a device key (unlocked) lin, _ := isLoggedIn(m) if !lin { return nil, libkb.LoginRequiredError{} } // Get unlocked device for decryption and signing // passing in nil SecretUI since we don't know the passphrase. m.Debug("findDeviceKeys: getting device encryption key") parg := libkb.SecretKeyPromptArg{ Ska: libkb.SecretKeyArg{ Me: me, KeyType: libkb.DeviceEncryptionKeyType, }, Reason: "change passphrase", } encKey, err := m.G().Keyrings.GetSecretKeyWithPrompt(m, parg) if err != nil { return nil, err } m.Debug("findDeviceKeys: got device encryption key") m.Debug("findDeviceKeys: getting device signing key") parg.Ska.KeyType = libkb.DeviceSigningKeyType sigKey, err := m.G().Keyrings.GetSecretKeyWithPrompt(m, parg) if err != nil { return nil, err } m.Debug("findDeviceKeys: got device signing key") return libkb.NewDeviceWithKeysOnly(sigKey, encKey), nil }
[ "func", "findDeviceKeys", "(", "m", "libkb", ".", "MetaContext", ",", "me", "*", "libkb", ".", "User", ")", "(", "*", "libkb", ".", "DeviceWithKeys", ",", "error", ")", "{", "// need to be logged in to get a device key (unlocked)", "lin", ",", "_", ":=", "isLo...
// findDeviceKeys looks for device keys and unlocks them.
[ "findDeviceKeys", "looks", "for", "device", "keys", "and", "unlocks", "them", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/common.go#L13-L44
161,310
keybase/client
go/engine/common.go
matchPaperKey
func matchPaperKey(m libkb.MetaContext, me *libkb.User, paper string) (*libkb.DeviceWithKeys, error) { cki := me.GetComputedKeyInfos() if cki == nil { return nil, fmt.Errorf("no computed key infos") } bdevs := cki.PaperDevices() if len(bdevs) == 0 { return nil, libkb.NoPaperKeysError{} } pc := new(libkb.PaperChecker) if err := pc.Check(m, paper); err != nil { return nil, err } // phrase has the correct version and contains valid words paperPhrase := libkb.NewPaperKeyPhrase(paper) bkarg := &PaperKeyGenArg{ Passphrase: paperPhrase, SkipPush: true, Me: me, } bkeng := NewPaperKeyGen(m.G(), bkarg) if err := RunEngine2(m, bkeng); err != nil { return nil, err } sigKey := bkeng.SigKey() encKey := bkeng.EncKey() var device *libkb.Device m.Debug("generated paper key signing kid: %s", sigKey.GetKID()) m.Debug("generated paper key encryption kid: %s", encKey.GetKID()) ckf := me.GetComputedKeyFamily() for _, bdev := range bdevs { sk, err := ckf.GetSibkeyForDevice(bdev.ID) if err != nil { m.Debug("ckf.GetSibkeyForDevice(%s) error: %s", bdev.ID, err) continue } m.Debug("paper key device %s signing kid: %s", bdev.ID, sk.GetKID()) ek, err := ckf.GetEncryptionSubkeyForDevice(bdev.ID) if err != nil { m.Debug("ckf.GetEncryptionSubkeyForDevice(%s) error: %s", bdev.ID, err) continue } m.Debug("paper key device %s encryption kid: %s", bdev.ID, ek.GetKID()) if sk.GetKID().Equal(sigKey.GetKID()) && ek.GetKID().Equal(encKey.GetKID()) { m.Debug("paper key device %s matches generated paper key", bdev.ID) device = bdev break } m.Debug("paper key device %s does not match generated paper key", bdev.ID) } if device == nil { m.Debug("no matching paper keys found") return nil, libkb.PassphraseError{Msg: "no matching paper backup keys found"} } var deviceName string if device.Description != nil { deviceName = *device.Description } return libkb.NewDeviceWithKeys(sigKey, encKey, device.ID, deviceName), nil }
go
func matchPaperKey(m libkb.MetaContext, me *libkb.User, paper string) (*libkb.DeviceWithKeys, error) { cki := me.GetComputedKeyInfos() if cki == nil { return nil, fmt.Errorf("no computed key infos") } bdevs := cki.PaperDevices() if len(bdevs) == 0 { return nil, libkb.NoPaperKeysError{} } pc := new(libkb.PaperChecker) if err := pc.Check(m, paper); err != nil { return nil, err } // phrase has the correct version and contains valid words paperPhrase := libkb.NewPaperKeyPhrase(paper) bkarg := &PaperKeyGenArg{ Passphrase: paperPhrase, SkipPush: true, Me: me, } bkeng := NewPaperKeyGen(m.G(), bkarg) if err := RunEngine2(m, bkeng); err != nil { return nil, err } sigKey := bkeng.SigKey() encKey := bkeng.EncKey() var device *libkb.Device m.Debug("generated paper key signing kid: %s", sigKey.GetKID()) m.Debug("generated paper key encryption kid: %s", encKey.GetKID()) ckf := me.GetComputedKeyFamily() for _, bdev := range bdevs { sk, err := ckf.GetSibkeyForDevice(bdev.ID) if err != nil { m.Debug("ckf.GetSibkeyForDevice(%s) error: %s", bdev.ID, err) continue } m.Debug("paper key device %s signing kid: %s", bdev.ID, sk.GetKID()) ek, err := ckf.GetEncryptionSubkeyForDevice(bdev.ID) if err != nil { m.Debug("ckf.GetEncryptionSubkeyForDevice(%s) error: %s", bdev.ID, err) continue } m.Debug("paper key device %s encryption kid: %s", bdev.ID, ek.GetKID()) if sk.GetKID().Equal(sigKey.GetKID()) && ek.GetKID().Equal(encKey.GetKID()) { m.Debug("paper key device %s matches generated paper key", bdev.ID) device = bdev break } m.Debug("paper key device %s does not match generated paper key", bdev.ID) } if device == nil { m.Debug("no matching paper keys found") return nil, libkb.PassphraseError{Msg: "no matching paper backup keys found"} } var deviceName string if device.Description != nil { deviceName = *device.Description } return libkb.NewDeviceWithKeys(sigKey, encKey, device.ID, deviceName), nil }
[ "func", "matchPaperKey", "(", "m", "libkb", ".", "MetaContext", ",", "me", "*", "libkb", ".", "User", ",", "paper", "string", ")", "(", "*", "libkb", ".", "DeviceWithKeys", ",", "error", ")", "{", "cki", ":=", "me", ".", "GetComputedKeyInfos", "(", ")"...
// matchPaperKey checks to make sure paper is a valid paper phrase and that it exists // in the user's keyfamily.
[ "matchPaperKey", "checks", "to", "make", "sure", "paper", "is", "a", "valid", "paper", "phrase", "and", "that", "it", "exists", "in", "the", "user", "s", "keyfamily", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/common.go#L70-L140
161,311
keybase/client
go/engine/common.go
fetchLKS
func fetchLKS(m libkb.MetaContext, encKey libkb.GenericKey) (libkb.PassphraseGeneration, libkb.LKSecClientHalf, error) { arg := libkb.APIArg{ Endpoint: "passphrase/recover", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "kid": encKey.GetKID(), }, } res, err := m.G().API.Get(m, arg) var dummy libkb.LKSecClientHalf if err != nil { return 0, dummy, err } ctext, err := res.Body.AtKey("ctext").GetString() if err != nil { return 0, dummy, err } ppGen, err := res.Body.AtKey("passphrase_generation").GetInt() if err != nil { return 0, dummy, err } // Now try to decrypt with the unlocked device key msg, _, err := encKey.DecryptFromString(ctext) if err != nil { return 0, dummy, err } clientHalf, err := libkb.NewLKSecClientHalfFromBytes(msg) if err != nil { return 0, dummy, err } return libkb.PassphraseGeneration(ppGen), clientHalf, nil }
go
func fetchLKS(m libkb.MetaContext, encKey libkb.GenericKey) (libkb.PassphraseGeneration, libkb.LKSecClientHalf, error) { arg := libkb.APIArg{ Endpoint: "passphrase/recover", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "kid": encKey.GetKID(), }, } res, err := m.G().API.Get(m, arg) var dummy libkb.LKSecClientHalf if err != nil { return 0, dummy, err } ctext, err := res.Body.AtKey("ctext").GetString() if err != nil { return 0, dummy, err } ppGen, err := res.Body.AtKey("passphrase_generation").GetInt() if err != nil { return 0, dummy, err } // Now try to decrypt with the unlocked device key msg, _, err := encKey.DecryptFromString(ctext) if err != nil { return 0, dummy, err } clientHalf, err := libkb.NewLKSecClientHalfFromBytes(msg) if err != nil { return 0, dummy, err } return libkb.PassphraseGeneration(ppGen), clientHalf, nil }
[ "func", "fetchLKS", "(", "m", "libkb", ".", "MetaContext", ",", "encKey", "libkb", ".", "GenericKey", ")", "(", "libkb", ".", "PassphraseGeneration", ",", "libkb", ".", "LKSecClientHalf", ",", "error", ")", "{", "arg", ":=", "libkb", ".", "APIArg", "{", ...
// fetchLKS gets the encrypted LKS client half from the server. // It uses encKey to decrypt it. It also returns the passphrase // generation.
[ "fetchLKS", "gets", "the", "encrypted", "LKS", "client", "half", "from", "the", "server", ".", "It", "uses", "encKey", "to", "decrypt", "it", ".", "It", "also", "returns", "the", "passphrase", "generation", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/common.go#L145-L178
161,312
keybase/client
go/chat/signencrypt/codec.go
NewEncodingReader
func NewEncodingReader(encKey SecretboxKey, signKey SignKey, signaturePrefix kbcrypto.SignaturePrefix, nonce Nonce, innerReader io.Reader) io.Reader { return &codecReadWrapper{ innerReader: innerReader, codec: &encoderCodecShim{NewEncoder(encKey, signKey, signaturePrefix, nonce)}, } }
go
func NewEncodingReader(encKey SecretboxKey, signKey SignKey, signaturePrefix kbcrypto.SignaturePrefix, nonce Nonce, innerReader io.Reader) io.Reader { return &codecReadWrapper{ innerReader: innerReader, codec: &encoderCodecShim{NewEncoder(encKey, signKey, signaturePrefix, nonce)}, } }
[ "func", "NewEncodingReader", "(", "encKey", "SecretboxKey", ",", "signKey", "SignKey", ",", "signaturePrefix", "kbcrypto", ".", "SignaturePrefix", ",", "nonce", "Nonce", ",", "innerReader", "io", ".", "Reader", ")", "io", ".", "Reader", "{", "return", "&", "co...
// NewEncodingReader creates a new streaming encoder. // The signaturePrefix argument must not contain the null container.
[ "NewEncodingReader", "creates", "a", "new", "streaming", "encoder", ".", "The", "signaturePrefix", "argument", "must", "not", "contain", "the", "null", "container", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/signencrypt/codec.go#L476-L481
161,313
keybase/client
go/chat/signencrypt/codec.go
SealWhole
func SealWhole(plaintext []byte, encKey SecretboxKey, signKey SignKey, signaturePrefix kbcrypto.SignaturePrefix, nonce Nonce) []byte { encoder := NewEncoder(encKey, signKey, signaturePrefix, nonce) output := encoder.Write(plaintext) output = append(output, encoder.Finish()...) return output }
go
func SealWhole(plaintext []byte, encKey SecretboxKey, signKey SignKey, signaturePrefix kbcrypto.SignaturePrefix, nonce Nonce) []byte { encoder := NewEncoder(encKey, signKey, signaturePrefix, nonce) output := encoder.Write(plaintext) output = append(output, encoder.Finish()...) return output }
[ "func", "SealWhole", "(", "plaintext", "[", "]", "byte", ",", "encKey", "SecretboxKey", ",", "signKey", "SignKey", ",", "signaturePrefix", "kbcrypto", ".", "SignaturePrefix", ",", "nonce", "Nonce", ")", "[", "]", "byte", "{", "encoder", ":=", "NewEncoder", "...
// SealWhole seals all at once using the streaming encoding.
[ "SealWhole", "seals", "all", "at", "once", "using", "the", "streaming", "encoding", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/signencrypt/codec.go#L548-L553
161,314
keybase/client
go/kbfs/kbfshash/hash.go
DoRawDefaultHash
func DoRawDefaultHash(p []byte) (HashType, RawDefaultHash) { return DefaultHashType, RawDefaultHash(sha256.Sum256(p)) }
go
func DoRawDefaultHash(p []byte) (HashType, RawDefaultHash) { return DefaultHashType, RawDefaultHash(sha256.Sum256(p)) }
[ "func", "DoRawDefaultHash", "(", "p", "[", "]", "byte", ")", "(", "HashType", ",", "RawDefaultHash", ")", "{", "return", "DefaultHashType", ",", "RawDefaultHash", "(", "sha256", ".", "Sum256", "(", "p", ")", ")", "\n", "}" ]
// DoRawDefaultHash computes the default keybase hash of the given // data, and returns the type and the raw hash bytes.
[ "DoRawDefaultHash", "computes", "the", "default", "keybase", "hash", "of", "the", "given", "data", "and", "returns", "the", "type", "and", "the", "raw", "hash", "bytes", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L97-L99
161,315
keybase/client
go/kbfs/kbfshash/hash.go
Copy
func (rdh *RawDefaultHash) Copy() *RawDefaultHash { if rdh == nil { return nil } hashCopy := RawDefaultHash{} copy(hashCopy[:], rdh[:]) return &hashCopy }
go
func (rdh *RawDefaultHash) Copy() *RawDefaultHash { if rdh == nil { return nil } hashCopy := RawDefaultHash{} copy(hashCopy[:], rdh[:]) return &hashCopy }
[ "func", "(", "rdh", "*", "RawDefaultHash", ")", "Copy", "(", ")", "*", "RawDefaultHash", "{", "if", "rdh", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "hashCopy", ":=", "RawDefaultHash", "{", "}", "\n", "copy", "(", "hashCopy", "[", ":", "]",...
// Copy returns a copied RawDefaultHash
[ "Copy", "returns", "a", "copied", "RawDefaultHash" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L102-L109
161,316
keybase/client
go/kbfs/kbfshash/hash.go
HashFromRaw
func HashFromRaw(hashType HashType, rawHash []byte) (Hash, error) { return HashFromBytes(append([]byte{byte(hashType)}, rawHash...)) }
go
func HashFromRaw(hashType HashType, rawHash []byte) (Hash, error) { return HashFromBytes(append([]byte{byte(hashType)}, rawHash...)) }
[ "func", "HashFromRaw", "(", "hashType", "HashType", ",", "rawHash", "[", "]", "byte", ")", "(", "Hash", ",", "error", ")", "{", "return", "HashFromBytes", "(", "append", "(", "[", "]", "byte", "{", "byte", "(", "hashType", ")", "}", ",", "rawHash", "...
// HashFromRaw creates a hash from a type and raw hash data. If the // returned error is nil, the returned Hash is valid.
[ "HashFromRaw", "creates", "a", "hash", "from", "a", "type", "and", "raw", "hash", "data", ".", "If", "the", "returned", "error", "is", "nil", "the", "returned", "Hash", "is", "valid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L125-L127
161,317
keybase/client
go/kbfs/kbfshash/hash.go
HashFromBytes
func HashFromBytes(data []byte) (Hash, error) { h := Hash{string(data)} if !h.IsValid() { return Hash{}, errors.WithStack(InvalidHashError{h}) } return h, nil }
go
func HashFromBytes(data []byte) (Hash, error) { h := Hash{string(data)} if !h.IsValid() { return Hash{}, errors.WithStack(InvalidHashError{h}) } return h, nil }
[ "func", "HashFromBytes", "(", "data", "[", "]", "byte", ")", "(", "Hash", ",", "error", ")", "{", "h", ":=", "Hash", "{", "string", "(", "data", ")", "}", "\n", "if", "!", "h", ".", "IsValid", "(", ")", "{", "return", "Hash", "{", "}", ",", "...
// HashFromBytes creates a hash from the given byte array. If the // returned error is nil, the returned Hash is valid.
[ "HashFromBytes", "creates", "a", "hash", "from", "the", "given", "byte", "array", ".", "If", "the", "returned", "error", "is", "nil", "the", "returned", "Hash", "is", "valid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L131-L137
161,318
keybase/client
go/kbfs/kbfshash/hash.go
HashFromString
func HashFromString(dataStr string) (Hash, error) { data, err := hex.DecodeString(dataStr) if err != nil { return Hash{}, errors.WithStack(err) } return HashFromBytes(data) }
go
func HashFromString(dataStr string) (Hash, error) { data, err := hex.DecodeString(dataStr) if err != nil { return Hash{}, errors.WithStack(err) } return HashFromBytes(data) }
[ "func", "HashFromString", "(", "dataStr", "string", ")", "(", "Hash", ",", "error", ")", "{", "data", ",", "err", ":=", "hex", ".", "DecodeString", "(", "dataStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Hash", "{", "}", ",", "errors", ...
// HashFromString creates a hash from the given string. If the // returned error is nil, the returned Hash is valid.
[ "HashFromString", "creates", "a", "hash", "from", "the", "given", "string", ".", "If", "the", "returned", "error", "is", "nil", "the", "returned", "Hash", "is", "valid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L141-L147
161,319
keybase/client
go/kbfs/kbfshash/hash.go
DefaultHash
func DefaultHash(buf []byte) (Hash, error) { hashType, rawHash := DoRawDefaultHash(buf) return HashFromRaw(hashType, rawHash[:]) }
go
func DefaultHash(buf []byte) (Hash, error) { hashType, rawHash := DoRawDefaultHash(buf) return HashFromRaw(hashType, rawHash[:]) }
[ "func", "DefaultHash", "(", "buf", "[", "]", "byte", ")", "(", "Hash", ",", "error", ")", "{", "hashType", ",", "rawHash", ":=", "DoRawDefaultHash", "(", "buf", ")", "\n", "return", "HashFromRaw", "(", "hashType", ",", "rawHash", "[", ":", "]", ")", ...
// DefaultHash computes the hash of the given data with the default // hash type.
[ "DefaultHash", "computes", "the", "hash", "of", "the", "given", "data", "with", "the", "default", "hash", "type", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L151-L154
161,320
keybase/client
go/kbfs/kbfshash/hash.go
DoHash
func DoHash(buf []byte, ht HashType) (Hash, error) { switch ht { case SHA256Hash, SHA256HashV2: default: return Hash{}, errors.WithStack(UnknownHashTypeError{ht}) } _, rawHash := DoRawDefaultHash(buf) return HashFromRaw(ht, rawHash[:]) }
go
func DoHash(buf []byte, ht HashType) (Hash, error) { switch ht { case SHA256Hash, SHA256HashV2: default: return Hash{}, errors.WithStack(UnknownHashTypeError{ht}) } _, rawHash := DoRawDefaultHash(buf) return HashFromRaw(ht, rawHash[:]) }
[ "func", "DoHash", "(", "buf", "[", "]", "byte", ",", "ht", "HashType", ")", "(", "Hash", ",", "error", ")", "{", "switch", "ht", "{", "case", "SHA256Hash", ",", "SHA256HashV2", ":", "default", ":", "return", "Hash", "{", "}", ",", "errors", ".", "W...
// DoHash computes the hash of the given data with the given hash // type.
[ "DoHash", "computes", "the", "hash", "of", "the", "given", "data", "with", "the", "given", "hash", "type", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L158-L166
161,321
keybase/client
go/kbfs/kbfshash/hash.go
IsValid
func (h Hash) IsValid() bool { if len(h.h) < MinHashByteLength { return false } if len(h.h) > MaxHashByteLength { return false } if h.hashType() == InvalidHash { return false } return true }
go
func (h Hash) IsValid() bool { if len(h.h) < MinHashByteLength { return false } if len(h.h) > MaxHashByteLength { return false } if h.hashType() == InvalidHash { return false } return true }
[ "func", "(", "h", "Hash", ")", "IsValid", "(", ")", "bool", "{", "if", "len", "(", "h", ".", "h", ")", "<", "MinHashByteLength", "{", "return", "false", "\n", "}", "\n", "if", "len", "(", "h", ".", "h", ")", ">", "MaxHashByteLength", "{", "return...
// IsValid returns whether the hash is valid. Note that a hash with an // unknown version is still valid.
[ "IsValid", "returns", "whether", "the", "hash", "is", "valid", ".", "Note", "that", "a", "hash", "with", "an", "unknown", "version", "is", "still", "valid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L183-L196
161,322
keybase/client
go/kbfs/kbfshash/hash.go
MarshalBinary
func (h Hash) MarshalBinary() (data []byte, err error) { if h == (Hash{}) { return nil, nil } if !h.IsValid() { return nil, errors.WithStack(InvalidHashError{h}) } return []byte(h.h), nil }
go
func (h Hash) MarshalBinary() (data []byte, err error) { if h == (Hash{}) { return nil, nil } if !h.IsValid() { return nil, errors.WithStack(InvalidHashError{h}) } return []byte(h.h), nil }
[ "func", "(", "h", "Hash", ")", "MarshalBinary", "(", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "h", "==", "(", "Hash", "{", "}", ")", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "if", "!", "h", ".", "...
// MarshalBinary implements the encoding.BinaryMarshaler interface for // Hash. Returns an error if the hash is invalid and not the zero // hash.
[ "MarshalBinary", "implements", "the", "encoding", ".", "BinaryMarshaler", "interface", "for", "Hash", ".", "Returns", "an", "error", "if", "the", "hash", "is", "invalid", "and", "not", "the", "zero", "hash", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L210-L220
161,323
keybase/client
go/kbfs/kbfshash/hash.go
UnmarshalBinary
func (h *Hash) UnmarshalBinary(data []byte) error { if len(data) == 0 { *h = Hash{} return nil } h.h = string(data) if !h.IsValid() { err := InvalidHashError{*h} *h = Hash{} return errors.WithStack(err) } return nil }
go
func (h *Hash) UnmarshalBinary(data []byte) error { if len(data) == 0 { *h = Hash{} return nil } h.h = string(data) if !h.IsValid() { err := InvalidHashError{*h} *h = Hash{} return errors.WithStack(err) } return nil }
[ "func", "(", "h", "*", "Hash", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "==", "0", "{", "*", "h", "=", "Hash", "{", "}", "\n", "return", "nil", "\n", "}", "\n\n", "h", ".", "h", ...
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface // for Hash. Returns an error if the given byte array is non-empty and // the hash is invalid.
[ "UnmarshalBinary", "implements", "the", "encoding", ".", "BinaryUnmarshaler", "interface", "for", "Hash", ".", "Returns", "an", "error", "if", "the", "given", "byte", "array", "is", "non", "-", "empty", "and", "the", "hash", "is", "invalid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L225-L239
161,324
keybase/client
go/kbfs/kbfshash/hash.go
Verify
func (h Hash) Verify(buf []byte) error { if !h.IsValid() { return errors.WithStack(InvalidHashError{h}) } expectedH, err := DoHash(buf, h.hashType()) if err != nil { return err } if h != expectedH { return errors.WithStack(HashMismatchError{expectedH, h}) } return nil }
go
func (h Hash) Verify(buf []byte) error { if !h.IsValid() { return errors.WithStack(InvalidHashError{h}) } expectedH, err := DoHash(buf, h.hashType()) if err != nil { return err } if h != expectedH { return errors.WithStack(HashMismatchError{expectedH, h}) } return nil }
[ "func", "(", "h", "Hash", ")", "Verify", "(", "buf", "[", "]", "byte", ")", "error", "{", "if", "!", "h", ".", "IsValid", "(", ")", "{", "return", "errors", ".", "WithStack", "(", "InvalidHashError", "{", "h", "}", ")", "\n", "}", "\n\n", "expect...
// Verify makes sure that the hash matches the given data and returns // an error otherwise.
[ "Verify", "makes", "sure", "that", "the", "hash", "matches", "the", "given", "data", "and", "returns", "an", "error", "otherwise", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L243-L257
161,325
keybase/client
go/kbfs/kbfshash/hash.go
UnmarshalText
func (h *Hash) UnmarshalText(data []byte) error { newH, err := HashFromString(string(data)) if err != nil { return err } *h = newH return nil }
go
func (h *Hash) UnmarshalText(data []byte) error { newH, err := HashFromString(string(data)) if err != nil { return err } *h = newH return nil }
[ "func", "(", "h", "*", "Hash", ")", "UnmarshalText", "(", "data", "[", "]", "byte", ")", "error", "{", "newH", ",", "err", ":=", "HashFromString", "(", "string", "(", "data", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "...
// UnmarshalText implements the encoding.TextUnmarshaler interface // for Hash.
[ "UnmarshalText", "implements", "the", "encoding", ".", "TextUnmarshaler", "interface", "for", "Hash", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L267-L274
161,326
keybase/client
go/kbfs/kbfshash/hash.go
DefaultHMAC
func DefaultHMAC(key, buf []byte) (HMAC, error) { mac := hmac.New(DefaultHashNew, key) mac.Write(buf) h, err := HashFromRaw(DefaultHashType, mac.Sum(nil)) if err != nil { return HMAC{}, err } return HMAC{h}, nil }
go
func DefaultHMAC(key, buf []byte) (HMAC, error) { mac := hmac.New(DefaultHashNew, key) mac.Write(buf) h, err := HashFromRaw(DefaultHashType, mac.Sum(nil)) if err != nil { return HMAC{}, err } return HMAC{h}, nil }
[ "func", "DefaultHMAC", "(", "key", ",", "buf", "[", "]", "byte", ")", "(", "HMAC", ",", "error", ")", "{", "mac", ":=", "hmac", ".", "New", "(", "DefaultHashNew", ",", "key", ")", "\n", "mac", ".", "Write", "(", "buf", ")", "\n", "h", ",", "err...
// DefaultHMAC computes the HMAC with the given key of the given data // using the default hash.
[ "DefaultHMAC", "computes", "the", "HMAC", "with", "the", "given", "key", "of", "the", "given", "data", "using", "the", "default", "hash", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L300-L308
161,327
keybase/client
go/kbfs/kbfshash/hash.go
MarshalBinary
func (hmac HMAC) MarshalBinary() (data []byte, err error) { return hmac.h.MarshalBinary() }
go
func (hmac HMAC) MarshalBinary() (data []byte, err error) { return hmac.h.MarshalBinary() }
[ "func", "(", "hmac", "HMAC", ")", "MarshalBinary", "(", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "return", "hmac", ".", "h", ".", "MarshalBinary", "(", ")", "\n", "}" ]
// MarshalBinary implements the encoding.BinaryMarshaler interface for // HMAC. Returns an error if the HMAC is invalid and not the zero // HMAC.
[ "MarshalBinary", "implements", "the", "encoding", ".", "BinaryMarshaler", "interface", "for", "HMAC", ".", "Returns", "an", "error", "if", "the", "HMAC", "is", "invalid", "and", "not", "the", "zero", "HMAC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L336-L338
161,328
keybase/client
go/kbfs/kbfshash/hash.go
UnmarshalBinary
func (hmac *HMAC) UnmarshalBinary(data []byte) error { return hmac.h.UnmarshalBinary(data) }
go
func (hmac *HMAC) UnmarshalBinary(data []byte) error { return hmac.h.UnmarshalBinary(data) }
[ "func", "(", "hmac", "*", "HMAC", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "return", "hmac", ".", "h", ".", "UnmarshalBinary", "(", "data", ")", "\n", "}" ]
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface // for HMAC. Returns an error if the given byte array is non-empty and // the HMAC is invalid.
[ "UnmarshalBinary", "implements", "the", "encoding", ".", "BinaryUnmarshaler", "interface", "for", "HMAC", ".", "Returns", "an", "error", "if", "the", "given", "byte", "array", "is", "non", "-", "empty", "and", "the", "HMAC", "is", "invalid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L343-L345
161,329
keybase/client
go/kbfs/kbfshash/hash.go
UnmarshalText
func (hmac *HMAC) UnmarshalText(data []byte) error { return hmac.h.UnmarshalText(data) }
go
func (hmac *HMAC) UnmarshalText(data []byte) error { return hmac.h.UnmarshalText(data) }
[ "func", "(", "hmac", "*", "HMAC", ")", "UnmarshalText", "(", "data", "[", "]", "byte", ")", "error", "{", "return", "hmac", ".", "h", ".", "UnmarshalText", "(", "data", ")", "\n", "}" ]
// UnmarshalText implements the encoding.TextUnmarshaler interface // for HMAC.
[ "UnmarshalText", "implements", "the", "encoding", ".", "TextUnmarshaler", "interface", "for", "HMAC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L355-L357
161,330
keybase/client
go/kbfs/kbfshash/hash.go
Verify
func (hmac HMAC) Verify(key, buf []byte) error { if !hmac.IsValid() { return errors.WithStack(InvalidHashError{hmac.h}) } // Once we have multiple hash types we'll need to expand this. t := hmac.hashType() if t != DefaultHashType { return errors.WithStack(UnknownHashTypeError{t}) } expectedHMAC, err := DefaultHMAC(key, buf) if err != nil { return err } if hmac != expectedHMAC { return errors.WithStack( HashMismatchError{expectedHMAC.h, hmac.h}) } return nil }
go
func (hmac HMAC) Verify(key, buf []byte) error { if !hmac.IsValid() { return errors.WithStack(InvalidHashError{hmac.h}) } // Once we have multiple hash types we'll need to expand this. t := hmac.hashType() if t != DefaultHashType { return errors.WithStack(UnknownHashTypeError{t}) } expectedHMAC, err := DefaultHMAC(key, buf) if err != nil { return err } if hmac != expectedHMAC { return errors.WithStack( HashMismatchError{expectedHMAC.h, hmac.h}) } return nil }
[ "func", "(", "hmac", "HMAC", ")", "Verify", "(", "key", ",", "buf", "[", "]", "byte", ")", "error", "{", "if", "!", "hmac", ".", "IsValid", "(", ")", "{", "return", "errors", ".", "WithStack", "(", "InvalidHashError", "{", "hmac", ".", "h", "}", ...
// Verify makes sure that the HMAC matches the given data.
[ "Verify", "makes", "sure", "that", "the", "HMAC", "matches", "the", "given", "data", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfshash/hash.go#L360-L380
161,331
keybase/client
go/kbfs/libfuse/sync_from_server_file.go
Write
func (f *SyncFromServerFile) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) (err error) { f.folder.fs.log.CDebugf(ctx, "SyncFromServerFile Write") defer func() { err = f.folder.processError(ctx, libkbfs.WriteMode, err) }() if len(req.Data) == 0 { return nil } folderBranch := f.folder.getFolderBranch() if folderBranch == (data.FolderBranch{}) { // Nothing to do. resp.Size = len(req.Data) return nil } // Use a context with a nil CtxAppIDKey value so that // notifications generated from this sync won't be discarded. syncCtx := context.WithValue(ctx, libfs.CtxAppIDKey, nil) err = f.folder.fs.config.KBFSOps().SyncFromServer( syncCtx, folderBranch, nil) if err != nil { return err } f.folder.fs.NotificationGroupWait() resp.Size = len(req.Data) return nil }
go
func (f *SyncFromServerFile) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) (err error) { f.folder.fs.log.CDebugf(ctx, "SyncFromServerFile Write") defer func() { err = f.folder.processError(ctx, libkbfs.WriteMode, err) }() if len(req.Data) == 0 { return nil } folderBranch := f.folder.getFolderBranch() if folderBranch == (data.FolderBranch{}) { // Nothing to do. resp.Size = len(req.Data) return nil } // Use a context with a nil CtxAppIDKey value so that // notifications generated from this sync won't be discarded. syncCtx := context.WithValue(ctx, libfs.CtxAppIDKey, nil) err = f.folder.fs.config.KBFSOps().SyncFromServer( syncCtx, folderBranch, nil) if err != nil { return err } f.folder.fs.NotificationGroupWait() resp.Size = len(req.Data) return nil }
[ "func", "(", "f", "*", "SyncFromServerFile", ")", "Write", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "WriteRequest", ",", "resp", "*", "fuse", ".", "WriteResponse", ")", "(", "err", "error", ")", "{", "f", ".", "folder", "....
// Write implements the fs.HandleWriter interface for SyncFromServerFile.
[ "Write", "implements", "the", "fs", ".", "HandleWriter", "interface", "for", "SyncFromServerFile", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/sync_from_server_file.go#L47-L72
161,332
keybase/client
go/protocol/keybase1/rekey_ui.go
Refresh
func (c RekeyUIClient) Refresh(ctx context.Context, __arg RefreshArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.rekeyUI.refresh", []interface{}{__arg}, nil) return }
go
func (c RekeyUIClient) Refresh(ctx context.Context, __arg RefreshArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.rekeyUI.refresh", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "RekeyUIClient", ")", "Refresh", "(", "ctx", "context", ".", "Context", ",", "__arg", "RefreshArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "inter...
// Refresh is called whenever Electron should refresh the UI, either // because a change came in, or because there was a timeout poll.
[ "Refresh", "is", "called", "whenever", "Electron", "should", "refresh", "the", "UI", "either", "because", "a", "change", "came", "in", "or", "because", "there", "was", "a", "timeout", "poll", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/rekey_ui.go#L152-L155
161,333
keybase/client
go/protocol/keybase1/rekey_ui.go
RekeySendEvent
func (c RekeyUIClient) RekeySendEvent(ctx context.Context, __arg RekeySendEventArg) (err error) { err = c.Cli.Notify(ctx, "keybase.1.rekeyUI.rekeySendEvent", []interface{}{__arg}) return }
go
func (c RekeyUIClient) RekeySendEvent(ctx context.Context, __arg RekeySendEventArg) (err error) { err = c.Cli.Notify(ctx, "keybase.1.rekeyUI.rekeySendEvent", []interface{}{__arg}) return }
[ "func", "(", "c", "RekeyUIClient", ")", "RekeySendEvent", "(", "ctx", "context", ".", "Context", ",", "__arg", "RekeySendEventArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Notify", "(", "ctx", ",", "\"", "\"", ",", "[",...
// RekeySendEvent sends updates as to what's going on in the rekey // thread. This is mainly useful in testing.
[ "RekeySendEvent", "sends", "updates", "as", "to", "what", "s", "going", "on", "in", "the", "rekey", "thread", ".", "This", "is", "mainly", "useful", "in", "testing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/rekey_ui.go#L159-L162
161,334
keybase/client
go/kbfs/libfuse/dir.go
fillAttrWithUIDAndWritePerm
func (f *Folder) fillAttrWithUIDAndWritePerm( ctx context.Context, node libkbfs.Node, ei *data.EntryInfo, a *fuse.Attr) (err error) { a.Valid = 1 * time.Minute node.FillCacheDuration(&a.Valid) a.Size = ei.Size a.Blocks = getNumBlocksFromSize(ei.Size) a.Mtime = time.Unix(0, ei.Mtime) a.Ctime = time.Unix(0, ei.Ctime) a.Uid = uint32(os.Getuid()) if a.Mode, err = f.writePermMode(ctx, node, a.Mode); err != nil { return err } return nil }
go
func (f *Folder) fillAttrWithUIDAndWritePerm( ctx context.Context, node libkbfs.Node, ei *data.EntryInfo, a *fuse.Attr) (err error) { a.Valid = 1 * time.Minute node.FillCacheDuration(&a.Valid) a.Size = ei.Size a.Blocks = getNumBlocksFromSize(ei.Size) a.Mtime = time.Unix(0, ei.Mtime) a.Ctime = time.Unix(0, ei.Ctime) a.Uid = uint32(os.Getuid()) if a.Mode, err = f.writePermMode(ctx, node, a.Mode); err != nil { return err } return nil }
[ "func", "(", "f", "*", "Folder", ")", "fillAttrWithUIDAndWritePerm", "(", "ctx", "context", ".", "Context", ",", "node", "libkbfs", ".", "Node", ",", "ei", "*", "data", ".", "EntryInfo", ",", "a", "*", "fuse", ".", "Attr", ")", "(", "err", "error", "...
// fillAttrWithUIDAndWritePerm sets attributes based on the entry info, and // pops in correct UID and write permissions. It only handles fields common to // all entryinfo types.
[ "fillAttrWithUIDAndWritePerm", "sets", "attributes", "based", "on", "the", "entry", "info", "and", "pops", "in", "correct", "UID", "and", "write", "permissions", ".", "It", "only", "handles", "fields", "common", "to", "all", "entryinfo", "types", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L374-L392
161,335
keybase/client
go/kbfs/libfuse/dir.go
Access
func (d *Dir) Access(ctx context.Context, r *fuse.AccessRequest) (err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.Access", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() return d.folder.access(ctx, r) }
go
func (d *Dir) Access(ctx context.Context, r *fuse.AccessRequest) (err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.Access", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() return d.folder.access(ctx, r) }
[ "func", "(", "d", "*", "Dir", ")", "Access", "(", "ctx", "context", ".", "Context", ",", "r", "*", "fuse", ".", "AccessRequest", ")", "(", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ".", "config", ".", "MaybeStartTrace", ...
// Access implements the fs.NodeAccesser interface for File. See comment for // File.Access for more details.
[ "Access", "implements", "the", "fs", ".", "NodeAccesser", "interface", "for", "File", ".", "See", "comment", "for", "File", ".", "Access", "for", "more", "details", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L481-L487
161,336
keybase/client
go/kbfs/libfuse/dir.go
Attr
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) (err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.Attr", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Attr") defer func() { err = d.folder.processError(ctx, libkbfs.ReadMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return err } return d.attr(ctx, a) }
go
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) (err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.Attr", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Attr") defer func() { err = d.folder.processError(ctx, libkbfs.ReadMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return err } return d.attr(ctx, a) }
[ "func", "(", "d", "*", "Dir", ")", "Attr", "(", "ctx", "context", ".", "Context", ",", "a", "*", "fuse", ".", "Attr", ")", "(", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ".", "config", ".", "MaybeStartTrace", "(", "ct...
// Attr implements the fs.Node interface for Dir.
[ "Attr", "implements", "the", "fs", ".", "Node", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L490-L506
161,337
keybase/client
go/kbfs/libfuse/dir.go
Create
func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (node fs.Node, handle fs.Handle, err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Create", fmt.Sprintf("%s %s", d.node.GetBasename(), req.Name)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Create %s", req.Name) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() isExec := (req.Mode.Perm() & 0100) != 0 excl := getEXCLFromCreateRequest(req) newNode, ei, err := d.folder.fs.config.KBFSOps().CreateFile( ctx, d.node, req.Name, isExec, excl) if err != nil { return nil, nil, err } child := d.makeFile(newNode) // Create is normally followed an Attr call. Fuse uses the same context for // them. If the context is cancelled after the Create call enters the // critical portion, and grace period has passed before Attr happens, the // Attr can result in EINTR which application does not expect. This caches // the EntryInfo for the created node and allows the subsequent Attr call to // use the cached EntryInfo instead of relying on a new Stat call. if reqID, ok := ctx.Value(CtxIDKey).(string); ok { child.eiCache.set(reqID, ei) } d.folder.nodesMu.Lock() d.folder.nodes[newNode.GetID()] = child d.folder.nodesMu.Unlock() return child, child, nil }
go
func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (node fs.Node, handle fs.Handle, err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Create", fmt.Sprintf("%s %s", d.node.GetBasename(), req.Name)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Create %s", req.Name) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() isExec := (req.Mode.Perm() & 0100) != 0 excl := getEXCLFromCreateRequest(req) newNode, ei, err := d.folder.fs.config.KBFSOps().CreateFile( ctx, d.node, req.Name, isExec, excl) if err != nil { return nil, nil, err } child := d.makeFile(newNode) // Create is normally followed an Attr call. Fuse uses the same context for // them. If the context is cancelled after the Create call enters the // critical portion, and grace period has passed before Attr happens, the // Attr can result in EINTR which application does not expect. This caches // the EntryInfo for the created node and allows the subsequent Attr call to // use the cached EntryInfo instead of relying on a new Stat call. if reqID, ok := ctx.Value(CtxIDKey).(string); ok { child.eiCache.set(reqID, ei) } d.folder.nodesMu.Lock() d.folder.nodes[newNode.GetID()] = child d.folder.nodesMu.Unlock() return child, child, nil }
[ "func", "(", "d", "*", "Dir", ")", "Create", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "CreateRequest", ",", "resp", "*", "fuse", ".", "CreateResponse", ")", "(", "node", "fs", ".", "Node", ",", "handle", "fs", ".", "Hand...
// Create implements the fs.NodeCreater interface for Dir.
[ "Create", "implements", "the", "fs", ".", "NodeCreater", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L626-L658
161,338
keybase/client
go/kbfs/libfuse/dir.go
Mkdir
func (d *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) ( node fs.Node, err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Mkdir", fmt.Sprintf("%s %s", d.node.GetBasename(), req.Name)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Mkdir %s", req.Name) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return nil, err } newNode, _, err := d.folder.fs.config.KBFSOps().CreateDir( ctx, d.node, req.Name) if err != nil { return nil, err } child := newDir(d.folder, newNode) d.folder.nodesMu.Lock() d.folder.nodes[newNode.GetID()] = child d.folder.nodesMu.Unlock() return child, nil }
go
func (d *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) ( node fs.Node, err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Mkdir", fmt.Sprintf("%s %s", d.node.GetBasename(), req.Name)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Mkdir %s", req.Name) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return nil, err } newNode, _, err := d.folder.fs.config.KBFSOps().CreateDir( ctx, d.node, req.Name) if err != nil { return nil, err } child := newDir(d.folder, newNode) d.folder.nodesMu.Lock() d.folder.nodes[newNode.GetID()] = child d.folder.nodesMu.Unlock() return child, nil }
[ "func", "(", "d", "*", "Dir", ")", "Mkdir", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "MkdirRequest", ")", "(", "node", "fs", ".", "Node", ",", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ".",...
// Mkdir implements the fs.NodeMkdirer interface for Dir.
[ "Mkdir", "implements", "the", "fs", ".", "NodeMkdirer", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L661-L688
161,339
keybase/client
go/kbfs/libfuse/dir.go
Symlink
func (d *Dir) Symlink(ctx context.Context, req *fuse.SymlinkRequest) ( node fs.Node, err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Symlink", fmt.Sprintf("%s %s -> %s", d.node.GetBasename(), req.NewName, req.Target)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Dir Symlink %s -> %s", req.NewName, req.Target) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return nil, err } if _, err := d.folder.fs.config.KBFSOps().CreateLink( ctx, d.node, req.NewName, req.Target); err != nil { return nil, err } child := &Symlink{ parent: d, name: req.NewName, inode: d.folder.fs.assignInode(), } return child, nil }
go
func (d *Dir) Symlink(ctx context.Context, req *fuse.SymlinkRequest) ( node fs.Node, err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Symlink", fmt.Sprintf("%s %s -> %s", d.node.GetBasename(), req.NewName, req.Target)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Dir Symlink %s -> %s", req.NewName, req.Target) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return nil, err } if _, err := d.folder.fs.config.KBFSOps().CreateLink( ctx, d.node, req.NewName, req.Target); err != nil { return nil, err } child := &Symlink{ parent: d, name: req.NewName, inode: d.folder.fs.assignInode(), } return child, nil }
[ "func", "(", "d", "*", "Dir", ")", "Symlink", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "SymlinkRequest", ")", "(", "node", "fs", ".", "Node", ",", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ...
// Symlink implements the fs.NodeSymlinker interface for Dir.
[ "Symlink", "implements", "the", "fs", ".", "NodeSymlinker", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L691-L720
161,340
keybase/client
go/kbfs/libfuse/dir.go
Rename
func (d *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) (err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Rename", fmt.Sprintf("%s %s -> %s", d.node.GetBasename(), req.OldName, req.NewName)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Dir Rename %s -> %s", req.OldName, req.NewName) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() var realNewDir *Dir switch newDir := newDir.(type) { case *Dir: realNewDir = newDir case *TLF: var err error realNewDir, err = newDir.loadDir(ctx) if err != nil { return err } case *FolderList, *Root: // This normally wouldn't happen since a presumably pre-check on // destination permissions would have failed. But in case it happens, it // should be a EACCES according to rename() man page. return fuse.Errno(syscall.EACCES) default: // This shouldn't happen unless we add other nodes. EIO is not in the error // codes listed in rename(), but there doesn't seem to be any suitable // error code listed for this situation either. return fuse.Errno(syscall.EIO) } err = d.folder.fs.config.KBFSOps().Rename(ctx, d.node, req.OldName, realNewDir.node, req.NewName) switch e := err.(type) { case nil: return nil case libkbfs.RenameAcrossDirsError: var execPathErr error e.ApplicationExecPath, execPathErr = sysutils.GetExecPathFromPID(req.Pid) if execPathErr != nil { d.folder.fs.log.CDebugf(ctx, "Dir Rename: getting exec path for PID %d error: %v", req.Pid, execPathErr) } return e default: return err } }
go
func (d *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) (err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Rename", fmt.Sprintf("%s %s -> %s", d.node.GetBasename(), req.OldName, req.NewName)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Dir Rename %s -> %s", req.OldName, req.NewName) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() var realNewDir *Dir switch newDir := newDir.(type) { case *Dir: realNewDir = newDir case *TLF: var err error realNewDir, err = newDir.loadDir(ctx) if err != nil { return err } case *FolderList, *Root: // This normally wouldn't happen since a presumably pre-check on // destination permissions would have failed. But in case it happens, it // should be a EACCES according to rename() man page. return fuse.Errno(syscall.EACCES) default: // This shouldn't happen unless we add other nodes. EIO is not in the error // codes listed in rename(), but there doesn't seem to be any suitable // error code listed for this situation either. return fuse.Errno(syscall.EIO) } err = d.folder.fs.config.KBFSOps().Rename(ctx, d.node, req.OldName, realNewDir.node, req.NewName) switch e := err.(type) { case nil: return nil case libkbfs.RenameAcrossDirsError: var execPathErr error e.ApplicationExecPath, execPathErr = sysutils.GetExecPathFromPID(req.Pid) if execPathErr != nil { d.folder.fs.log.CDebugf(ctx, "Dir Rename: getting exec path for PID %d error: %v", req.Pid, execPathErr) } return e default: return err } }
[ "func", "(", "d", "*", "Dir", ")", "Rename", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "RenameRequest", ",", "newDir", "fs", ".", "Node", ")", "(", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ...
// Rename implements the fs.NodeRenamer interface for Dir.
[ "Rename", "implements", "the", "fs", ".", "NodeRenamer", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L723-L774
161,341
keybase/client
go/kbfs/libfuse/dir.go
Remove
func (d *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) (err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Remove", fmt.Sprintf("%s %s", d.node.GetBasename(), req.Name)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Remove %s", req.Name) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return err } // node will be removed from Folder.nodes, if it is there in the // first place, by its Forget if req.Dir { err = d.folder.fs.config.KBFSOps().RemoveDir(ctx, d.node, req.Name) } else { err = d.folder.fs.config.KBFSOps().RemoveEntry(ctx, d.node, req.Name) } if err != nil { return err } return nil }
go
func (d *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) (err error) { ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Remove", fmt.Sprintf("%s %s", d.node.GetBasename(), req.Name)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Remove %s", req.Name) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return err } // node will be removed from Folder.nodes, if it is there in the // first place, by its Forget if req.Dir { err = d.folder.fs.config.KBFSOps().RemoveDir(ctx, d.node, req.Name) } else { err = d.folder.fs.config.KBFSOps().RemoveEntry(ctx, d.node, req.Name) } if err != nil { return err } return nil }
[ "func", "(", "d", "*", "Dir", ")", "Remove", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "RemoveRequest", ")", "(", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ".", "config", ".", "MaybeStartTrace",...
// Remove implements the fs.NodeRemover interface for Dir.
[ "Remove", "implements", "the", "fs", ".", "NodeRemover", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L777-L805
161,342
keybase/client
go/kbfs/libfuse/dir.go
ReadDirAll
func (d *Dir) ReadDirAll(ctx context.Context) (res []fuse.Dirent, err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.ReadDirAll", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir ReadDirAll") defer func() { err = d.folder.processError(ctx, libkbfs.ReadMode, err) }() children, err := d.folder.fs.config.KBFSOps().GetDirChildren(ctx, d.node) if err != nil { return nil, err } for name, ei := range children { fde := fuse.Dirent{ Name: name, // Technically we should be setting the inode here, but // since we don't have a proper node for each of these // entries yet we can't generate one, because we don't // have anywhere to save it. So bazil.org/fuse will // generate a random one for each entry, but doesn't store // it anywhere, so it's safe. } switch ei.Type { case data.File, data.Exec: fde.Type = fuse.DT_File case data.Dir: fde.Type = fuse.DT_Dir case data.Sym: fde.Type = fuse.DT_Link } res = append(res, fde) } d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Returning %d entries", len(res)) return res, nil }
go
func (d *Dir) ReadDirAll(ctx context.Context) (res []fuse.Dirent, err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.ReadDirAll", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir ReadDirAll") defer func() { err = d.folder.processError(ctx, libkbfs.ReadMode, err) }() children, err := d.folder.fs.config.KBFSOps().GetDirChildren(ctx, d.node) if err != nil { return nil, err } for name, ei := range children { fde := fuse.Dirent{ Name: name, // Technically we should be setting the inode here, but // since we don't have a proper node for each of these // entries yet we can't generate one, because we don't // have anywhere to save it. So bazil.org/fuse will // generate a random one for each entry, but doesn't store // it anywhere, so it's safe. } switch ei.Type { case data.File, data.Exec: fde.Type = fuse.DT_File case data.Dir: fde.Type = fuse.DT_Dir case data.Sym: fde.Type = fuse.DT_Link } res = append(res, fde) } d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Returning %d entries", len(res)) return res, nil }
[ "func", "(", "d", "*", "Dir", ")", "ReadDirAll", "(", "ctx", "context", ".", "Context", ")", "(", "res", "[", "]", "fuse", ".", "Dirent", ",", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ".", "config", ".", "MaybeStartTra...
// ReadDirAll implements the fs.NodeReadDirAller interface for Dir.
[ "ReadDirAll", "implements", "the", "fs", ".", "NodeReadDirAller", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L808-L843
161,343
keybase/client
go/kbfs/libfuse/dir.go
Setattr
func (d *Dir) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) (err error) { valid := req.Valid ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Setattr", fmt.Sprintf("%s %s", d.node.GetBasename(), valid)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir SetAttr %s", valid) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() if valid.Mode() { // You can't set the mode on KBFS directories, but we don't // want to return EPERM because that unnecessarily fails some // applications like unzip. Instead ignore it, print a debug // message, and advertise this behavior on the // "understand_kbfs" doc online. d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Ignoring unsupported attempt to set "+ "the mode on a directory") valid &^= fuse.SetattrMode } if valid.Mtime() { err := d.folder.fs.config.KBFSOps().SetMtime( ctx, d.node, &req.Mtime) if err != nil { return err } valid &^= fuse.SetattrMtime | fuse.SetattrMtimeNow } // KBFS has no concept of persistent atime; explicitly don't handle it valid &^= fuse.SetattrAtime | fuse.SetattrAtimeNow // things we don't need to explicitly handle valid &^= fuse.SetattrLockOwner | fuse.SetattrHandle if valid.Uid() || valid.Gid() { // You can't set the UID/GID on KBFS directories, but we don't // want to return ENOSYS because that causes scary warnings on // some programs like mv. Instead ignore it, print a debug // message, and advertise this behavior on the // "understand_kbfs" doc online. d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Ignoring unsupported attempt to set "+ "the UID/GID on a directory") valid &^= fuse.SetattrUid | fuse.SetattrGid } if valid != 0 { // don't let an unhandled operation slip by without error d.folder.fs.log.CInfof(ctx, "Setattr did not handle %v", valid) return fuse.ENOSYS } // Something in Linux kernel *requires* directories to provide // attributes here, where it was just an optimization for files. return d.attr(ctx, &resp.Attr) }
go
func (d *Dir) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) (err error) { valid := req.Valid ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Setattr", fmt.Sprintf("%s %s", d.node.GetBasename(), valid)) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir SetAttr %s", valid) defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() if valid.Mode() { // You can't set the mode on KBFS directories, but we don't // want to return EPERM because that unnecessarily fails some // applications like unzip. Instead ignore it, print a debug // message, and advertise this behavior on the // "understand_kbfs" doc online. d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Ignoring unsupported attempt to set "+ "the mode on a directory") valid &^= fuse.SetattrMode } if valid.Mtime() { err := d.folder.fs.config.KBFSOps().SetMtime( ctx, d.node, &req.Mtime) if err != nil { return err } valid &^= fuse.SetattrMtime | fuse.SetattrMtimeNow } // KBFS has no concept of persistent atime; explicitly don't handle it valid &^= fuse.SetattrAtime | fuse.SetattrAtimeNow // things we don't need to explicitly handle valid &^= fuse.SetattrLockOwner | fuse.SetattrHandle if valid.Uid() || valid.Gid() { // You can't set the UID/GID on KBFS directories, but we don't // want to return ENOSYS because that causes scary warnings on // some programs like mv. Instead ignore it, print a debug // message, and advertise this behavior on the // "understand_kbfs" doc online. d.folder.fs.vlog.CLogf( ctx, libkb.VLog1, "Ignoring unsupported attempt to set "+ "the UID/GID on a directory") valid &^= fuse.SetattrUid | fuse.SetattrGid } if valid != 0 { // don't let an unhandled operation slip by without error d.folder.fs.log.CInfof(ctx, "Setattr did not handle %v", valid) return fuse.ENOSYS } // Something in Linux kernel *requires* directories to provide // attributes here, where it was just an optimization for files. return d.attr(ctx, &resp.Attr) }
[ "func", "(", "d", "*", "Dir", ")", "Setattr", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "SetattrRequest", ",", "resp", "*", "fuse", ".", "SetattrResponse", ")", "(", "err", "error", ")", "{", "valid", ":=", "req", ".", "V...
// Setattr implements the fs.NodeSetattrer interface for Dir.
[ "Setattr", "implements", "the", "fs", ".", "NodeSetattrer", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L851-L908
161,344
keybase/client
go/kbfs/libfuse/dir.go
Fsync
func (d *Dir) Fsync(ctx context.Context, req *fuse.FsyncRequest) (err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.Fsync", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Fsync") defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return err } return d.folder.fs.config.KBFSOps().SyncAll(ctx, d.node.GetFolderBranch()) }
go
func (d *Dir) Fsync(ctx context.Context, req *fuse.FsyncRequest) (err error) { ctx = d.folder.fs.config.MaybeStartTrace( ctx, "Dir.Fsync", d.node.GetBasename()) defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }() d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Fsync") defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }() // This fits in situation 1 as described in libkbfs/delayed_cancellation.go err = libcontext.EnableDelayedCancellationWithGracePeriod( ctx, d.folder.fs.config.DelayedCancellationGracePeriod()) if err != nil { return err } return d.folder.fs.config.KBFSOps().SyncAll(ctx, d.node.GetFolderBranch()) }
[ "func", "(", "d", "*", "Dir", ")", "Fsync", "(", "ctx", "context", ".", "Context", ",", "req", "*", "fuse", ".", "FsyncRequest", ")", "(", "err", "error", ")", "{", "ctx", "=", "d", ".", "folder", ".", "fs", ".", "config", ".", "MaybeStartTrace", ...
// Fsync implements the fs.NodeFsyncer interface for Dir.
[ "Fsync", "implements", "the", "fs", ".", "NodeFsyncer", "interface", "for", "Dir", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/dir.go#L911-L927
161,345
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
cancelExistingLocked
func (cr *ConflictResolver) cancelExistingLocked(ci conflictInput) bool { // The input is only interesting if one of the revisions is // greater than what we've looked at to date. if ci.unmerged <= cr.currInput.unmerged && ci.merged <= cr.currInput.merged { return false } if cr.currCancel != nil { cr.currCancel() } return true }
go
func (cr *ConflictResolver) cancelExistingLocked(ci conflictInput) bool { // The input is only interesting if one of the revisions is // greater than what we've looked at to date. if ci.unmerged <= cr.currInput.unmerged && ci.merged <= cr.currInput.merged { return false } if cr.currCancel != nil { cr.currCancel() } return true }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "cancelExistingLocked", "(", "ci", "conflictInput", ")", "bool", "{", "// The input is only interesting if one of the revisions is", "// greater than what we've looked at to date.", "if", "ci", ".", "unmerged", "<=", "cr", "....
// cancelExistingLocked must be called while holding cr.inputLock.
[ "cancelExistingLocked", "must", "be", "called", "while", "holding", "cr", ".", "inputLock", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L176-L187
161,346
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
ForceCancel
func (cr *ConflictResolver) ForceCancel() { cr.inputLock.Lock() defer cr.inputLock.Unlock() if cr.currCancel != nil { cr.currCancel() } }
go
func (cr *ConflictResolver) ForceCancel() { cr.inputLock.Lock() defer cr.inputLock.Unlock() if cr.currCancel != nil { cr.currCancel() } }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "ForceCancel", "(", ")", "{", "cr", ".", "inputLock", ".", "Lock", "(", ")", "\n", "defer", "cr", ".", "inputLock", ".", "Unlock", "(", ")", "\n", "if", "cr", ".", "currCancel", "!=", "nil", "{", "cr...
// ForceCancel cancels any currently-running CR, regardless of what // its inputs were.
[ "ForceCancel", "cancels", "any", "currently", "-", "running", "CR", "regardless", "of", "what", "its", "inputs", "were", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L191-L197
161,347
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
processInput
func (cr *ConflictResolver) processInput(baseCtx context.Context, inputChan <-chan conflictInput) { // Start off with a closed prevCRDone, so that the first CR call // doesn't have to wait. prevCRDone := make(chan struct{}) close(prevCRDone) defer func() { cr.inputLock.Lock() defer cr.inputLock.Unlock() if cr.currCancel != nil { cr.currCancel() } libcontext.CleanupCancellationDelayer(baseCtx) }() for ci := range inputChan { ctx := CtxWithRandomIDReplayable(baseCtx, CtxCRIDKey, CtxCROpID, cr.log) valid := func() bool { cr.inputLock.Lock() defer cr.inputLock.Unlock() valid := cr.cancelExistingLocked(ci) if !valid { return false } cr.log.CDebugf(ctx, "New conflict input %v following old "+ "input %v", ci, cr.currInput) cr.currInput = ci ctx, cr.currCancel = context.WithCancel(ctx) return true }() if !valid { cr.log.CDebugf(ctx, "Ignoring uninteresting input: %v", ci) cr.resolveGroup.Done() continue } waitChan := prevCRDone prevCRDone = make(chan struct{}) // closed when doResolve finishes go func(ci conflictInput, done chan<- struct{}) { defer cr.resolveGroup.Done() defer close(done) // Wait for the previous CR without blocking any // Resolve callers, as that could result in deadlock // (KBFS-1001). select { case <-waitChan: case <-ctx.Done(): cr.log.CDebugf(ctx, "Resolution canceled before starting") return } cr.doResolve(ctx, ci) }(ci, prevCRDone) } }
go
func (cr *ConflictResolver) processInput(baseCtx context.Context, inputChan <-chan conflictInput) { // Start off with a closed prevCRDone, so that the first CR call // doesn't have to wait. prevCRDone := make(chan struct{}) close(prevCRDone) defer func() { cr.inputLock.Lock() defer cr.inputLock.Unlock() if cr.currCancel != nil { cr.currCancel() } libcontext.CleanupCancellationDelayer(baseCtx) }() for ci := range inputChan { ctx := CtxWithRandomIDReplayable(baseCtx, CtxCRIDKey, CtxCROpID, cr.log) valid := func() bool { cr.inputLock.Lock() defer cr.inputLock.Unlock() valid := cr.cancelExistingLocked(ci) if !valid { return false } cr.log.CDebugf(ctx, "New conflict input %v following old "+ "input %v", ci, cr.currInput) cr.currInput = ci ctx, cr.currCancel = context.WithCancel(ctx) return true }() if !valid { cr.log.CDebugf(ctx, "Ignoring uninteresting input: %v", ci) cr.resolveGroup.Done() continue } waitChan := prevCRDone prevCRDone = make(chan struct{}) // closed when doResolve finishes go func(ci conflictInput, done chan<- struct{}) { defer cr.resolveGroup.Done() defer close(done) // Wait for the previous CR without blocking any // Resolve callers, as that could result in deadlock // (KBFS-1001). select { case <-waitChan: case <-ctx.Done(): cr.log.CDebugf(ctx, "Resolution canceled before starting") return } cr.doResolve(ctx, ci) }(ci, prevCRDone) } }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "processInput", "(", "baseCtx", "context", ".", "Context", ",", "inputChan", "<-", "chan", "conflictInput", ")", "{", "// Start off with a closed prevCRDone, so that the first CR call", "// doesn't have to wait.", "prevCRDone...
// processInput processes conflict resolution jobs from the given // channel until it is closed. This function uses a parameter for the // channel instead of accessing cr.inputChan directly so that it // doesn't have to hold inputChanLock.
[ "processInput", "processes", "conflict", "resolution", "jobs", "from", "the", "given", "channel", "until", "it", "is", "closed", ".", "This", "function", "uses", "a", "parameter", "for", "the", "channel", "instead", "of", "accessing", "cr", ".", "inputChan", "...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L203-L257
161,348
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
Resolve
func (cr *ConflictResolver) Resolve(ctx context.Context, unmerged kbfsmd.Revision, merged kbfsmd.Revision) { cr.inputChanLock.RLock() defer cr.inputChanLock.RUnlock() // CR can end up trying to cancel itself via the SyncAll call, so // prevent that from happening. if crOpID := ctx.Value(CtxCRIDKey); crOpID != nil { cr.log.CDebugf(ctx, "Ignoring self-resolve during CR") return } if cr.inputChan == nil { return } // Call Add before cancelling existing CR in order to prevent the // resolveGroup from becoming briefly empty and allowing things waiting // on it to believe that CR has finished. cr.resolveGroup.Add(1) ci := conflictInput{unmerged, merged} func() { cr.inputLock.Lock() defer cr.inputLock.Unlock() // Cancel any running CR before we return, so the caller can be // confident any ongoing CR superseded by this new input will be // canceled before it releases any locks it holds. // // TODO: return early if this returns false, and log something // using a newly-pass-in context. _ = cr.cancelExistingLocked(ci) }() cr.inputChan <- ci }
go
func (cr *ConflictResolver) Resolve(ctx context.Context, unmerged kbfsmd.Revision, merged kbfsmd.Revision) { cr.inputChanLock.RLock() defer cr.inputChanLock.RUnlock() // CR can end up trying to cancel itself via the SyncAll call, so // prevent that from happening. if crOpID := ctx.Value(CtxCRIDKey); crOpID != nil { cr.log.CDebugf(ctx, "Ignoring self-resolve during CR") return } if cr.inputChan == nil { return } // Call Add before cancelling existing CR in order to prevent the // resolveGroup from becoming briefly empty and allowing things waiting // on it to believe that CR has finished. cr.resolveGroup.Add(1) ci := conflictInput{unmerged, merged} func() { cr.inputLock.Lock() defer cr.inputLock.Unlock() // Cancel any running CR before we return, so the caller can be // confident any ongoing CR superseded by this new input will be // canceled before it releases any locks it holds. // // TODO: return early if this returns false, and log something // using a newly-pass-in context. _ = cr.cancelExistingLocked(ci) }() cr.inputChan <- ci }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "Resolve", "(", "ctx", "context", ".", "Context", ",", "unmerged", "kbfsmd", ".", "Revision", ",", "merged", "kbfsmd", ".", "Revision", ")", "{", "cr", ".", "inputChanLock", ".", "RLock", "(", ")", "\n", ...
// Resolve takes the latest known unmerged and merged revision // numbers, and kicks off the resolution process.
[ "Resolve", "takes", "the", "latest", "known", "unmerged", "and", "merged", "revision", "numbers", "and", "kicks", "off", "the", "resolution", "process", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L261-L296
161,349
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
BeginNewBranch
func (cr *ConflictResolver) BeginNewBranch() { cr.inputLock.Lock() defer cr.inputLock.Unlock() // Reset the curr input so we don't ignore a future CR // request that uses the same revision number (i.e., // because the previous CR failed to flush due to a // conflict). cr.currInput = conflictInput{} }
go
func (cr *ConflictResolver) BeginNewBranch() { cr.inputLock.Lock() defer cr.inputLock.Unlock() // Reset the curr input so we don't ignore a future CR // request that uses the same revision number (i.e., // because the previous CR failed to flush due to a // conflict). cr.currInput = conflictInput{} }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "BeginNewBranch", "(", ")", "{", "cr", ".", "inputLock", ".", "Lock", "(", ")", "\n", "defer", "cr", ".", "inputLock", ".", "Unlock", "(", ")", "\n", "// Reset the curr input so we don't ignore a future CR", "//...
// BeginNewBranch resets any internal state to be ready to accept // resolutions from a new branch.
[ "BeginNewBranch", "resets", "any", "internal", "state", "to", "be", "ready", "to", "accept", "resolutions", "from", "a", "new", "branch", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L325-L333
161,350
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
updateCurrInput
func (cr *ConflictResolver) updateCurrInput(ctx context.Context, unmerged, merged []ImmutableRootMetadata) (err error) { cr.inputLock.Lock() defer cr.inputLock.Unlock() // check done while holding the lock, so we know for sure if // we've already been canceled and replaced by a new input. err = cr.checkDone(ctx) if err != nil { return err } prevInput := cr.currInput defer func() { // reset the currInput if we get an error below if err != nil { cr.currInput = prevInput } }() rev := unmerged[len(unmerged)-1].bareMd.RevisionNumber() if rev < cr.currInput.unmerged { return fmt.Errorf("Unmerged revision %d is lower than the "+ "expected unmerged revision %d", rev, cr.currInput.unmerged) } cr.currInput.unmerged = rev if len(merged) > 0 { rev = merged[len(merged)-1].bareMd.RevisionNumber() if rev < cr.currInput.merged { return fmt.Errorf("Merged revision %d is lower than the "+ "expected merged revision %d", rev, cr.currInput.merged) } } else { rev = kbfsmd.RevisionUninitialized } cr.currInput.merged = rev // Take the lock right away next time if either there are lots of // unmerged revisions, or this is a local squash and we won't // block for very long. // // TODO: if there are a lot of merged revisions, and they keep // coming, we might consider doing a "partial" resolution, writing // the result back to the unmerged branch (basically "rebasing" // it). See KBFS-1896. if (len(unmerged) > cr.maxRevsThreshold) || (len(unmerged) > 0 && unmerged[0].BID() == kbfsmd.PendingLocalSquashBranchID) { cr.lockNextTime = true } return nil }
go
func (cr *ConflictResolver) updateCurrInput(ctx context.Context, unmerged, merged []ImmutableRootMetadata) (err error) { cr.inputLock.Lock() defer cr.inputLock.Unlock() // check done while holding the lock, so we know for sure if // we've already been canceled and replaced by a new input. err = cr.checkDone(ctx) if err != nil { return err } prevInput := cr.currInput defer func() { // reset the currInput if we get an error below if err != nil { cr.currInput = prevInput } }() rev := unmerged[len(unmerged)-1].bareMd.RevisionNumber() if rev < cr.currInput.unmerged { return fmt.Errorf("Unmerged revision %d is lower than the "+ "expected unmerged revision %d", rev, cr.currInput.unmerged) } cr.currInput.unmerged = rev if len(merged) > 0 { rev = merged[len(merged)-1].bareMd.RevisionNumber() if rev < cr.currInput.merged { return fmt.Errorf("Merged revision %d is lower than the "+ "expected merged revision %d", rev, cr.currInput.merged) } } else { rev = kbfsmd.RevisionUninitialized } cr.currInput.merged = rev // Take the lock right away next time if either there are lots of // unmerged revisions, or this is a local squash and we won't // block for very long. // // TODO: if there are a lot of merged revisions, and they keep // coming, we might consider doing a "partial" resolution, writing // the result back to the unmerged branch (basically "rebasing" // it). See KBFS-1896. if (len(unmerged) > cr.maxRevsThreshold) || (len(unmerged) > 0 && unmerged[0].BID() == kbfsmd.PendingLocalSquashBranchID) { cr.lockNextTime = true } return nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "updateCurrInput", "(", "ctx", "context", ".", "Context", ",", "unmerged", ",", "merged", "[", "]", "ImmutableRootMetadata", ")", "(", "err", "error", ")", "{", "cr", ".", "inputLock", ".", "Lock", "(", ")...
// updateCurrInput assumes that both unmerged and merged are // non-empty.
[ "updateCurrInput", "assumes", "that", "both", "unmerged", "and", "merged", "are", "non", "-", "empty", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L413-L463
161,351
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
Less
func (sp crSortedPaths) Less(i, j int) bool { return len(sp[i].Path) > len(sp[j].Path) }
go
func (sp crSortedPaths) Less(i, j int) bool { return len(sp[i].Path) > len(sp[j].Path) }
[ "func", "(", "sp", "crSortedPaths", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "len", "(", "sp", "[", "i", "]", ".", "Path", ")", ">", "len", "(", "sp", "[", "j", "]", ".", "Path", ")", "\n", "}" ]
// Less implements sort.Interface for crSortedPaths
[ "Less", "implements", "sort", ".", "Interface", "for", "crSortedPaths" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L523-L525
161,352
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
Swap
func (sp crSortedPaths) Swap(i, j int) { sp[j], sp[i] = sp[i], sp[j] }
go
func (sp crSortedPaths) Swap(i, j int) { sp[j], sp[i] = sp[i], sp[j] }
[ "func", "(", "sp", "crSortedPaths", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "sp", "[", "j", "]", ",", "sp", "[", "i", "]", "=", "sp", "[", "i", "]", ",", "sp", "[", "j", "]", "\n", "}" ]
// Swap implements sort.Interface for crSortedPaths
[ "Swap", "implements", "sort", ".", "Interface", "for", "crSortedPaths" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L528-L530
161,353
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
createdFileWithNonzeroSizes
func (cr *ConflictResolver) createdFileWithNonzeroSizes( ctx context.Context, unmergedChains, mergedChains *crChains, unmergedChain *crChain, mergedChain *crChain, unmergedCop, mergedCop *createOp) (bool, error) { lState := makeFBOLockState() // The pointers on the ops' final paths aren't necessarily filled // in, so construct our own partial paths using the chain // pointers, which are enough to satisfy `GetEntry`. mergedPath := data.Path{ FolderBranch: mergedCop.getFinalPath().FolderBranch, Path: []data.PathNode{ {BlockPointer: mergedChain.mostRecent, Name: ""}, {BlockPointer: data.ZeroPtr, Name: mergedCop.NewName}, }, } kmd := mergedChains.mostRecentChainMDInfo mergedEntry, err := cr.fbo.blocks.GetEntry(ctx, lState, kmd, mergedPath) if _, noExists := errors.Cause(err).(idutil.NoSuchNameError); noExists { return false, nil } else if err != nil { return false, err } kmd = unmergedChains.mostRecentChainMDInfo unmergedPath := data.Path{ FolderBranch: mergedCop.getFinalPath().FolderBranch, Path: []data.PathNode{ {BlockPointer: unmergedChain.mostRecent, Name: ""}, {BlockPointer: data.ZeroPtr, Name: mergedCop.NewName}, }, } unmergedEntry, err := cr.fbo.blocks.GetEntry(ctx, lState, kmd, unmergedPath) if _, noExists := errors.Cause(err).(idutil.NoSuchNameError); noExists { return false, nil } else if err != nil { return false, err } if mergedEntry.Size > 0 && unmergedEntry.Size > 0 { cr.log.CDebugf(ctx, "Not merging files named %s with non-zero sizes "+ "(merged=%d unmerged=%d)", unmergedCop.NewName, mergedEntry.Size, unmergedEntry.Size) return true, nil } return false, nil }
go
func (cr *ConflictResolver) createdFileWithNonzeroSizes( ctx context.Context, unmergedChains, mergedChains *crChains, unmergedChain *crChain, mergedChain *crChain, unmergedCop, mergedCop *createOp) (bool, error) { lState := makeFBOLockState() // The pointers on the ops' final paths aren't necessarily filled // in, so construct our own partial paths using the chain // pointers, which are enough to satisfy `GetEntry`. mergedPath := data.Path{ FolderBranch: mergedCop.getFinalPath().FolderBranch, Path: []data.PathNode{ {BlockPointer: mergedChain.mostRecent, Name: ""}, {BlockPointer: data.ZeroPtr, Name: mergedCop.NewName}, }, } kmd := mergedChains.mostRecentChainMDInfo mergedEntry, err := cr.fbo.blocks.GetEntry(ctx, lState, kmd, mergedPath) if _, noExists := errors.Cause(err).(idutil.NoSuchNameError); noExists { return false, nil } else if err != nil { return false, err } kmd = unmergedChains.mostRecentChainMDInfo unmergedPath := data.Path{ FolderBranch: mergedCop.getFinalPath().FolderBranch, Path: []data.PathNode{ {BlockPointer: unmergedChain.mostRecent, Name: ""}, {BlockPointer: data.ZeroPtr, Name: mergedCop.NewName}, }, } unmergedEntry, err := cr.fbo.blocks.GetEntry(ctx, lState, kmd, unmergedPath) if _, noExists := errors.Cause(err).(idutil.NoSuchNameError); noExists { return false, nil } else if err != nil { return false, err } if mergedEntry.Size > 0 && unmergedEntry.Size > 0 { cr.log.CDebugf(ctx, "Not merging files named %s with non-zero sizes "+ "(merged=%d unmerged=%d)", unmergedCop.NewName, mergedEntry.Size, unmergedEntry.Size) return true, nil } return false, nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "createdFileWithNonzeroSizes", "(", "ctx", "context", ".", "Context", ",", "unmergedChains", ",", "mergedChains", "*", "crChains", ",", "unmergedChain", "*", "crChain", ",", "mergedChain", "*", "crChain", ",", "un...
// createdFileWithNonzeroSizes checks two possibly-conflicting // createOps and returns true if the corresponding file has non-zero // directory entry sizes in both the unmerged and merged branch. We // need to check this sometimes, because a call to // `createdFileWithConflictingWrite` might not have access to syncOps // that have been resolved away in a previous iteration. See // KBFS-2825 for details.
[ "createdFileWithNonzeroSizes", "checks", "two", "possibly", "-", "conflicting", "createOps", "and", "returns", "true", "if", "the", "corresponding", "file", "has", "non", "-", "zero", "directory", "entry", "sizes", "in", "both", "the", "unmerged", "and", "merged",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L574-L620
161,354
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
findCreatedDirsToMerge
func (cr *ConflictResolver) findCreatedDirsToMerge(ctx context.Context, unmergedPaths []data.Path, unmergedChains, mergedChains *crChains) ( []data.Path, error) { var newUnmergedPaths []data.Path for _, unmergedPath := range unmergedPaths { unmergedChain, ok := unmergedChains.byMostRecent[unmergedPath.TailPointer()] if !ok { return nil, fmt.Errorf("findCreatedDirsToMerge: No unmerged chain "+ "for most recent %v", unmergedPath.TailPointer()) } newPaths, err := cr.checkPathForMerge(ctx, unmergedChain, unmergedPath, unmergedChains, mergedChains) if err != nil { return nil, err } newUnmergedPaths = append(newUnmergedPaths, newPaths...) } return newUnmergedPaths, nil }
go
func (cr *ConflictResolver) findCreatedDirsToMerge(ctx context.Context, unmergedPaths []data.Path, unmergedChains, mergedChains *crChains) ( []data.Path, error) { var newUnmergedPaths []data.Path for _, unmergedPath := range unmergedPaths { unmergedChain, ok := unmergedChains.byMostRecent[unmergedPath.TailPointer()] if !ok { return nil, fmt.Errorf("findCreatedDirsToMerge: No unmerged chain "+ "for most recent %v", unmergedPath.TailPointer()) } newPaths, err := cr.checkPathForMerge(ctx, unmergedChain, unmergedPath, unmergedChains, mergedChains) if err != nil { return nil, err } newUnmergedPaths = append(newUnmergedPaths, newPaths...) } return newUnmergedPaths, nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "findCreatedDirsToMerge", "(", "ctx", "context", ".", "Context", ",", "unmergedPaths", "[", "]", "data", ".", "Path", ",", "unmergedChains", ",", "mergedChains", "*", "crChains", ")", "(", "[", "]", "data", ...
// findCreatedDirsToMerge finds directories that were created in both // the unmerged and merged branches, and resets the original unmerged // pointer to match the original merged pointer. It returns a slice of // new unmerged paths that need to be combined with the unmergedPaths // slice.
[ "findCreatedDirsToMerge", "finds", "directories", "that", "were", "created", "in", "both", "the", "unmerged", "and", "merged", "branches", "and", "resets", "the", "original", "unmerged", "pointer", "to", "match", "the", "original", "merged", "pointer", ".", "It", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L768-L788
161,355
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
addChildBlocksIfIndirectFile
func (cr *ConflictResolver) addChildBlocksIfIndirectFile( ctx context.Context, lState *kbfssync.LockState, unmergedChains *crChains, currPath data.Path, op op) error { // For files with indirect pointers, add all child blocks // as refblocks for the re-created file. infos, err := cr.fbo.blocks.GetIndirectFileBlockInfos( ctx, lState, unmergedChains.mostRecentChainMDInfo, currPath) if err != nil { return err } if len(infos) > 0 { cr.log.CDebugf(ctx, "Adding child pointers for recreated "+ "file %s", currPath) for _, info := range infos { op.AddRefBlock(info.BlockPointer) } } return nil }
go
func (cr *ConflictResolver) addChildBlocksIfIndirectFile( ctx context.Context, lState *kbfssync.LockState, unmergedChains *crChains, currPath data.Path, op op) error { // For files with indirect pointers, add all child blocks // as refblocks for the re-created file. infos, err := cr.fbo.blocks.GetIndirectFileBlockInfos( ctx, lState, unmergedChains.mostRecentChainMDInfo, currPath) if err != nil { return err } if len(infos) > 0 { cr.log.CDebugf(ctx, "Adding child pointers for recreated "+ "file %s", currPath) for _, info := range infos { op.AddRefBlock(info.BlockPointer) } } return nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "addChildBlocksIfIndirectFile", "(", "ctx", "context", ".", "Context", ",", "lState", "*", "kbfssync", ".", "LockState", ",", "unmergedChains", "*", "crChains", ",", "currPath", "data", ".", "Path", ",", "op", ...
// addChildBlocksIfIndirectFile adds refblocks for all child blocks of // the given file. It will return an error if called with a pointer // that doesn't represent a file.
[ "addChildBlocksIfIndirectFile", "adds", "refblocks", "for", "all", "child", "blocks", "of", "the", "given", "file", ".", "It", "will", "return", "an", "error", "if", "called", "with", "a", "pointer", "that", "doesn", "t", "represent", "a", "file", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L798-L816
161,356
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
addRecreateOpsToUnmergedChains
func (cr *ConflictResolver) addRecreateOpsToUnmergedChains(ctx context.Context, recreateOps []*createOp, unmergedChains, mergedChains *crChains, mergedPaths map[data.BlockPointer]data.Path) ([]data.Path, error) { if len(recreateOps) == 0 { return nil, nil } // First create a lookup table that maps every block pointer in // every merged path to a corresponding key in the mergedPaths map. keys := make(map[data.BlockPointer]data.BlockPointer) for ptr, p := range mergedPaths { for _, node := range p.Path { keys[node.BlockPointer] = ptr } } var newUnmergedPaths []data.Path for _, rop := range recreateOps { // If rop.Dir.Unref is a merged most recent pointer, look up the // original. Otherwise rop.Dir.Unref is the original. Use the // original to look up the appropriate unmerged chain and stick // this op at the front. origTargetPtr, err := mergedChains.originalFromMostRecentOrSame(rop.Dir.Unref) if err != nil { return nil, err } chain, ok := unmergedChains.byOriginal[origTargetPtr] if !ok { return nil, fmt.Errorf("recreateOp for %v has no chain", origTargetPtr) } if len(chain.ops) == 0 { newUnmergedPaths = append(newUnmergedPaths, rop.getFinalPath()) } chain.ops = append([]op{rop}, chain.ops...) // Look up the corresponding unmerged most recent pointer, and // check whether there's a merged path for it yet. If not, // create one by looking it up in the lookup table (created // above) and taking the appropriate subpath. _, ok = mergedPaths[chain.mostRecent] if !ok { mergedMostRecent := chain.original if !mergedChains.isDeleted(chain.original) { if mChain, ok := mergedChains.byOriginal[chain.original]; ok { mergedMostRecent = mChain.mostRecent } } key, ok := keys[mergedMostRecent] if !ok { return nil, fmt.Errorf("Couldn't find a merged path "+ "containing the target of a recreate op: %v", mergedMostRecent) } currPath := mergedPaths[key] for currPath.TailPointer() != mergedMostRecent && currPath.HasValidParent() { currPath = *currPath.ParentPath() } mergedPaths[chain.mostRecent] = currPath } } return newUnmergedPaths, nil }
go
func (cr *ConflictResolver) addRecreateOpsToUnmergedChains(ctx context.Context, recreateOps []*createOp, unmergedChains, mergedChains *crChains, mergedPaths map[data.BlockPointer]data.Path) ([]data.Path, error) { if len(recreateOps) == 0 { return nil, nil } // First create a lookup table that maps every block pointer in // every merged path to a corresponding key in the mergedPaths map. keys := make(map[data.BlockPointer]data.BlockPointer) for ptr, p := range mergedPaths { for _, node := range p.Path { keys[node.BlockPointer] = ptr } } var newUnmergedPaths []data.Path for _, rop := range recreateOps { // If rop.Dir.Unref is a merged most recent pointer, look up the // original. Otherwise rop.Dir.Unref is the original. Use the // original to look up the appropriate unmerged chain and stick // this op at the front. origTargetPtr, err := mergedChains.originalFromMostRecentOrSame(rop.Dir.Unref) if err != nil { return nil, err } chain, ok := unmergedChains.byOriginal[origTargetPtr] if !ok { return nil, fmt.Errorf("recreateOp for %v has no chain", origTargetPtr) } if len(chain.ops) == 0 { newUnmergedPaths = append(newUnmergedPaths, rop.getFinalPath()) } chain.ops = append([]op{rop}, chain.ops...) // Look up the corresponding unmerged most recent pointer, and // check whether there's a merged path for it yet. If not, // create one by looking it up in the lookup table (created // above) and taking the appropriate subpath. _, ok = mergedPaths[chain.mostRecent] if !ok { mergedMostRecent := chain.original if !mergedChains.isDeleted(chain.original) { if mChain, ok := mergedChains.byOriginal[chain.original]; ok { mergedMostRecent = mChain.mostRecent } } key, ok := keys[mergedMostRecent] if !ok { return nil, fmt.Errorf("Couldn't find a merged path "+ "containing the target of a recreate op: %v", mergedMostRecent) } currPath := mergedPaths[key] for currPath.TailPointer() != mergedMostRecent && currPath.HasValidParent() { currPath = *currPath.ParentPath() } mergedPaths[chain.mostRecent] = currPath } } return newUnmergedPaths, nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "addRecreateOpsToUnmergedChains", "(", "ctx", "context", ".", "Context", ",", "recreateOps", "[", "]", "*", "createOp", ",", "unmergedChains", ",", "mergedChains", "*", "crChains", ",", "mergedPaths", "map", "[", ...
// addRecreateOpsToUnmergedChains inserts each recreateOp, into its // appropriate unmerged chain, creating one if it doesn't exist yet. // It also adds entries as necessary to mergedPaths, and returns a // slice of new unmergedPaths to be added.
[ "addRecreateOpsToUnmergedChains", "inserts", "each", "recreateOp", "into", "its", "appropriate", "unmerged", "chain", "creating", "one", "if", "it", "doesn", "t", "exist", "yet", ".", "It", "also", "adds", "entries", "as", "necessary", "to", "mergedPaths", "and", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L1349-L1415
161,357
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
addMergedRecreates
func (cr *ConflictResolver) addMergedRecreates(ctx context.Context, unmergedChains, mergedChains *crChains, mostRecentMergedWriterInfo writerInfo) error { for _, unmergedChain := range unmergedChains.byMostRecent { // First check for nodes that have been deleted in the unmerged // branch, but modified in the merged branch, and drop those // unmerged operations. for _, untypedOp := range unmergedChain.ops { ro, ok := untypedOp.(*rmOp) if !ok { continue } // Perhaps the rm target has been renamed somewhere else, // before eventually being deleted. In this case, we have // to look up the original by iterating over // renamedOriginals. if len(ro.Unrefs()) == 0 { for original, info := range unmergedChains.renamedOriginals { if info.originalOldParent == unmergedChain.original && info.oldName == ro.OldName && unmergedChains.isDeleted(original) { ro.AddUnrefBlock(original) break } } } for _, ptr := range ro.Unrefs() { unrefOriginal, err := unmergedChains.originalFromMostRecentOrSame(ptr) if err != nil { return err } if c, ok := mergedChains.byOriginal[unrefOriginal]; ok { ro.dropThis = true // Need to prepend a create here to the merged parent, // in order catch any conflicts. parentOriginal := unmergedChain.original name := ro.OldName if newParent, newName, ok := mergedChains.renamedParentAndName(unrefOriginal); ok { // It was renamed in the merged branch, so // recreate with the new parent and new name. parentOriginal = newParent name = newName } else if info, ok := unmergedChains.renamedOriginals[unrefOriginal]; ok { // It was only renamed in the old parent, so // use the old parent and original name. parentOriginal = info.originalOldParent name = info.oldName } chain, ok := mergedChains.byOriginal[parentOriginal] if !ok { return fmt.Errorf("Couldn't find chain for parent %v "+ "of merged entry %v we're trying to recreate", parentOriginal, unrefOriginal) } t := data.Dir if c.isFile() { // TODO: how to fix this up for executables // and symlinks? Only matters for checking // conflicts if something with the same name // is created on the unmerged branch. t = data.File } co, err := newCreateOp(name, chain.original, t) if err != nil { return err } err = co.Dir.setRef(chain.original) if err != nil { return err } co.AddRefBlock(c.mostRecent) co.setWriterInfo(mostRecentMergedWriterInfo) chain.ops = append([]op{co}, chain.ops...) cr.log.CDebugf(ctx, "Re-created rm'd merge-modified node "+ "%v with operation %s in parent %v", unrefOriginal, co, parentOriginal) } } } } return nil }
go
func (cr *ConflictResolver) addMergedRecreates(ctx context.Context, unmergedChains, mergedChains *crChains, mostRecentMergedWriterInfo writerInfo) error { for _, unmergedChain := range unmergedChains.byMostRecent { // First check for nodes that have been deleted in the unmerged // branch, but modified in the merged branch, and drop those // unmerged operations. for _, untypedOp := range unmergedChain.ops { ro, ok := untypedOp.(*rmOp) if !ok { continue } // Perhaps the rm target has been renamed somewhere else, // before eventually being deleted. In this case, we have // to look up the original by iterating over // renamedOriginals. if len(ro.Unrefs()) == 0 { for original, info := range unmergedChains.renamedOriginals { if info.originalOldParent == unmergedChain.original && info.oldName == ro.OldName && unmergedChains.isDeleted(original) { ro.AddUnrefBlock(original) break } } } for _, ptr := range ro.Unrefs() { unrefOriginal, err := unmergedChains.originalFromMostRecentOrSame(ptr) if err != nil { return err } if c, ok := mergedChains.byOriginal[unrefOriginal]; ok { ro.dropThis = true // Need to prepend a create here to the merged parent, // in order catch any conflicts. parentOriginal := unmergedChain.original name := ro.OldName if newParent, newName, ok := mergedChains.renamedParentAndName(unrefOriginal); ok { // It was renamed in the merged branch, so // recreate with the new parent and new name. parentOriginal = newParent name = newName } else if info, ok := unmergedChains.renamedOriginals[unrefOriginal]; ok { // It was only renamed in the old parent, so // use the old parent and original name. parentOriginal = info.originalOldParent name = info.oldName } chain, ok := mergedChains.byOriginal[parentOriginal] if !ok { return fmt.Errorf("Couldn't find chain for parent %v "+ "of merged entry %v we're trying to recreate", parentOriginal, unrefOriginal) } t := data.Dir if c.isFile() { // TODO: how to fix this up for executables // and symlinks? Only matters for checking // conflicts if something with the same name // is created on the unmerged branch. t = data.File } co, err := newCreateOp(name, chain.original, t) if err != nil { return err } err = co.Dir.setRef(chain.original) if err != nil { return err } co.AddRefBlock(c.mostRecent) co.setWriterInfo(mostRecentMergedWriterInfo) chain.ops = append([]op{co}, chain.ops...) cr.log.CDebugf(ctx, "Re-created rm'd merge-modified node "+ "%v with operation %s in parent %v", unrefOriginal, co, parentOriginal) } } } } return nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "addMergedRecreates", "(", "ctx", "context", ".", "Context", ",", "unmergedChains", ",", "mergedChains", "*", "crChains", ",", "mostRecentMergedWriterInfo", "writerInfo", ")", "error", "{", "for", "_", ",", "unmer...
// addMergedRecreates drops any unmerged operations that remove a node // that was modified in the merged branch, and adds a create op to the // merged chain so that the node will be re-created locally.
[ "addMergedRecreates", "drops", "any", "unmerged", "operations", "that", "remove", "a", "node", "that", "was", "modified", "in", "the", "merged", "branch", "and", "adds", "a", "create", "op", "to", "the", "merged", "chain", "so", "that", "the", "node", "will"...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L1994-L2082
161,358
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
getActionsToMerge
func (cr *ConflictResolver) getActionsToMerge( ctx context.Context, unmergedChains, mergedChains *crChains, mergedPaths map[data.BlockPointer]data.Path) ( map[data.BlockPointer]crActionList, error) { actionMap := make(map[data.BlockPointer]crActionList) for unmergedMostRecent, unmergedChain := range unmergedChains.byMostRecent { original := unmergedChain.original // If this is a file that has been deleted in the merged // branch, a corresponding recreate op will take care of it, // no need to do anything here. // We don't need the "ok" value from this lookup because it's // fine to pass a nil mergedChain into crChain.getActionsToMerge. mergedChain := mergedChains.byOriginal[original] mergedPath, ok := mergedPaths[unmergedMostRecent] if !ok { // This most likely means that the file was created or // deleted in the unmerged branch and thus has no // corresponding merged path yet. continue } if !mergedPath.IsValid() { cr.log.CWarningf(ctx, "Ignoring invalid merged path for %v "+ "(original=%v)", unmergedMostRecent, original) continue } actions, err := unmergedChain.getActionsToMerge( ctx, cr.config.ConflictRenamer(), mergedPath, mergedChain) if err != nil { return nil, err } if len(actions) > 0 { actionMap[mergedPath.TailPointer()] = actions } } return actionMap, nil }
go
func (cr *ConflictResolver) getActionsToMerge( ctx context.Context, unmergedChains, mergedChains *crChains, mergedPaths map[data.BlockPointer]data.Path) ( map[data.BlockPointer]crActionList, error) { actionMap := make(map[data.BlockPointer]crActionList) for unmergedMostRecent, unmergedChain := range unmergedChains.byMostRecent { original := unmergedChain.original // If this is a file that has been deleted in the merged // branch, a corresponding recreate op will take care of it, // no need to do anything here. // We don't need the "ok" value from this lookup because it's // fine to pass a nil mergedChain into crChain.getActionsToMerge. mergedChain := mergedChains.byOriginal[original] mergedPath, ok := mergedPaths[unmergedMostRecent] if !ok { // This most likely means that the file was created or // deleted in the unmerged branch and thus has no // corresponding merged path yet. continue } if !mergedPath.IsValid() { cr.log.CWarningf(ctx, "Ignoring invalid merged path for %v "+ "(original=%v)", unmergedMostRecent, original) continue } actions, err := unmergedChain.getActionsToMerge( ctx, cr.config.ConflictRenamer(), mergedPath, mergedChain) if err != nil { return nil, err } if len(actions) > 0 { actionMap[mergedPath.TailPointer()] = actions } } return actionMap, nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "getActionsToMerge", "(", "ctx", "context", ".", "Context", ",", "unmergedChains", ",", "mergedChains", "*", "crChains", ",", "mergedPaths", "map", "[", "data", ".", "BlockPointer", "]", "data", ".", "Path", "...
// getActionsToMerge returns the set of actions needed to merge each // unmerged chain of operations, in a map keyed by the tail pointer of // the corresponding merged path.
[ "getActionsToMerge", "returns", "the", "set", "of", "actions", "needed", "to", "merge", "each", "unmerged", "chain", "of", "operations", "in", "a", "map", "keyed", "by", "the", "tail", "pointer", "of", "the", "corresponding", "merged", "path", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L2087-L2127
161,359
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
createResolvedMD
func (cr *ConflictResolver) createResolvedMD(ctx context.Context, lState *kbfssync.LockState, unmergedPaths []data.Path, unmergedChains, mergedChains *crChains, mostRecentMergedMD ImmutableRootMetadata) (*RootMetadata, error) { err := cr.checkDone(ctx) if err != nil { return nil, err } newMD, err := mostRecentMergedMD.MakeSuccessor( ctx, cr.config.MetadataVersion(), cr.config.Codec(), cr.config.KeyManager(), cr.config.KBPKI(), cr.config.KBPKI(), cr.config, mostRecentMergedMD.MdID(), true) if err != nil { return nil, err } var newPaths []data.Path for original, chain := range unmergedChains.byOriginal { added := false for i, op := range chain.ops { if cop, ok := op.(*createOp); ok { // We need to add in any creates that happened // within newly-created directories (which aren't // being merged with other newly-created directories), // to ensure that the overall Refs are correct and // that future CR processes can check those create ops // for conflicts. if unmergedChains.isCreated(original) && !mergedChains.isCreated(original) { // Shallowly copy the create op and update its // directory to the most recent pointer -- this won't // work with the usual revert ops process because that // skips chains which are newly-created within this // branch. newCreateOp := *cop newCreateOp.Dir, err = makeBlockUpdate( chain.mostRecent, chain.mostRecent) if err != nil { return nil, err } chain.ops[i] = &newCreateOp if !added { newPaths = append(newPaths, data.Path{ FolderBranch: cr.fbo.folderBranch, Path: []data.PathNode{{ BlockPointer: chain.mostRecent}}, }) added = true } } if cop.Type == data.Dir || len(cop.Refs()) == 0 { continue } // Add any direct file blocks too into each create op, // which originated in later unmerged syncs. ptr, err := unmergedChains.mostRecentFromOriginalOrSame(cop.Refs()[0]) if err != nil { return nil, err } trackSyncPtrChangesInCreate( ptr, chain, unmergedChains, cop.NewName) } } } if len(newPaths) > 0 { // Put the new paths at the beginning so they are processed // last in sorted order. unmergedPaths = append(newPaths, unmergedPaths...) } ops, err := cr.makeRevertedOps( ctx, lState, unmergedPaths, unmergedChains, mergedChains) if err != nil { return nil, err } cr.log.CDebugf(ctx, "Remote notifications: %v", ops) for _, op := range ops { cr.log.CDebugf(ctx, "%s: refs %v", op, op.Refs()) newMD.AddOp(op) } // Add a final dummy operation to collect all of the block updates. newMD.AddOp(newResolutionOp()) return newMD, nil }
go
func (cr *ConflictResolver) createResolvedMD(ctx context.Context, lState *kbfssync.LockState, unmergedPaths []data.Path, unmergedChains, mergedChains *crChains, mostRecentMergedMD ImmutableRootMetadata) (*RootMetadata, error) { err := cr.checkDone(ctx) if err != nil { return nil, err } newMD, err := mostRecentMergedMD.MakeSuccessor( ctx, cr.config.MetadataVersion(), cr.config.Codec(), cr.config.KeyManager(), cr.config.KBPKI(), cr.config.KBPKI(), cr.config, mostRecentMergedMD.MdID(), true) if err != nil { return nil, err } var newPaths []data.Path for original, chain := range unmergedChains.byOriginal { added := false for i, op := range chain.ops { if cop, ok := op.(*createOp); ok { // We need to add in any creates that happened // within newly-created directories (which aren't // being merged with other newly-created directories), // to ensure that the overall Refs are correct and // that future CR processes can check those create ops // for conflicts. if unmergedChains.isCreated(original) && !mergedChains.isCreated(original) { // Shallowly copy the create op and update its // directory to the most recent pointer -- this won't // work with the usual revert ops process because that // skips chains which are newly-created within this // branch. newCreateOp := *cop newCreateOp.Dir, err = makeBlockUpdate( chain.mostRecent, chain.mostRecent) if err != nil { return nil, err } chain.ops[i] = &newCreateOp if !added { newPaths = append(newPaths, data.Path{ FolderBranch: cr.fbo.folderBranch, Path: []data.PathNode{{ BlockPointer: chain.mostRecent}}, }) added = true } } if cop.Type == data.Dir || len(cop.Refs()) == 0 { continue } // Add any direct file blocks too into each create op, // which originated in later unmerged syncs. ptr, err := unmergedChains.mostRecentFromOriginalOrSame(cop.Refs()[0]) if err != nil { return nil, err } trackSyncPtrChangesInCreate( ptr, chain, unmergedChains, cop.NewName) } } } if len(newPaths) > 0 { // Put the new paths at the beginning so they are processed // last in sorted order. unmergedPaths = append(newPaths, unmergedPaths...) } ops, err := cr.makeRevertedOps( ctx, lState, unmergedPaths, unmergedChains, mergedChains) if err != nil { return nil, err } cr.log.CDebugf(ctx, "Remote notifications: %v", ops) for _, op := range ops { cr.log.CDebugf(ctx, "%s: refs %v", op, op.Refs()) newMD.AddOp(op) } // Add a final dummy operation to collect all of the block updates. newMD.AddOp(newResolutionOp()) return newMD, nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "createResolvedMD", "(", "ctx", "context", ".", "Context", ",", "lState", "*", "kbfssync", ".", "LockState", ",", "unmergedPaths", "[", "]", "data", ".", "Path", ",", "unmergedChains", ",", "mergedChains", "*"...
// createResolvedMD creates a MD update that will be merged into the // main folder as the resolving commit. It contains all of the // unmerged operations, as well as a "dummy" operation at the end // which will catch all of the BlockPointer updates. A later phase // will move all of those updates into their proper locations within // the other operations.
[ "createResolvedMD", "creates", "a", "MD", "update", "that", "will", "be", "merged", "into", "the", "main", "folder", "as", "the", "resolving", "commit", ".", "It", "contains", "all", "of", "the", "unmerged", "operations", "as", "well", "as", "a", "dummy", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L2703-L2791
161,360
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
makePostResolutionPaths
func (cr *ConflictResolver) makePostResolutionPaths(ctx context.Context, md *RootMetadata, unmergedChains, mergedChains *crChains, mergedPaths map[data.BlockPointer]data.Path) (map[data.BlockPointer]data.Path, error) { err := cr.checkDone(ctx) if err != nil { return nil, err } session, err := cr.config.KBPKI().GetCurrentSession(ctx) if err != nil { return nil, err } // No need to run any identifies on these chains, since we // have already finished all actions. resolvedChains, err := newCRChains( ctx, cr.config.Codec(), cr.config, []chainMetadata{rootMetadataWithKeyAndTimestamp{md, session.VerifyingKey, cr.config.Clock().Now()}}, &cr.fbo.blocks, false) if err != nil { return nil, err } // If there are no renames, we don't need to fix any of the paths if len(resolvedChains.renamedOriginals) == 0 { return mergedPaths, nil } resolvedPaths := make(map[data.BlockPointer]data.Path) for ptr, oldP := range mergedPaths { p, err := cr.resolveOnePath(ctx, ptr, unmergedChains, mergedChains, resolvedChains, mergedPaths, resolvedPaths) if err != nil { return nil, err } cr.log.CDebugf(ctx, "Resolved path for %v from %v to %v", ptr, oldP.Path, p.Path) } return resolvedPaths, nil }
go
func (cr *ConflictResolver) makePostResolutionPaths(ctx context.Context, md *RootMetadata, unmergedChains, mergedChains *crChains, mergedPaths map[data.BlockPointer]data.Path) (map[data.BlockPointer]data.Path, error) { err := cr.checkDone(ctx) if err != nil { return nil, err } session, err := cr.config.KBPKI().GetCurrentSession(ctx) if err != nil { return nil, err } // No need to run any identifies on these chains, since we // have already finished all actions. resolvedChains, err := newCRChains( ctx, cr.config.Codec(), cr.config, []chainMetadata{rootMetadataWithKeyAndTimestamp{md, session.VerifyingKey, cr.config.Clock().Now()}}, &cr.fbo.blocks, false) if err != nil { return nil, err } // If there are no renames, we don't need to fix any of the paths if len(resolvedChains.renamedOriginals) == 0 { return mergedPaths, nil } resolvedPaths := make(map[data.BlockPointer]data.Path) for ptr, oldP := range mergedPaths { p, err := cr.resolveOnePath(ctx, ptr, unmergedChains, mergedChains, resolvedChains, mergedPaths, resolvedPaths) if err != nil { return nil, err } cr.log.CDebugf(ctx, "Resolved path for %v from %v to %v", ptr, oldP.Path, p.Path) } return resolvedPaths, nil }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "makePostResolutionPaths", "(", "ctx", "context", ".", "Context", ",", "md", "*", "RootMetadata", ",", "unmergedChains", ",", "mergedChains", "*", "crChains", ",", "mergedPaths", "map", "[", "data", ".", "BlockP...
// makePostResolutionPaths returns the full paths to each unmerged // pointer, taking into account any rename operations that occurred in // the merged branch.
[ "makePostResolutionPaths", "returns", "the", "full", "paths", "to", "each", "unmerged", "pointer", "taking", "into", "account", "any", "rename", "operations", "that", "occurred", "in", "the", "merged", "branch", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L2907-L2948
161,361
keybase/client
go/kbfs/libkbfs/conflict_resolver.go
finalizeResolution
func (cr *ConflictResolver) finalizeResolution(ctx context.Context, lState *kbfssync.LockState, md *RootMetadata, unmergedChains, mergedChains *crChains, updates map[data.BlockPointer]data.BlockPointer, bps blockPutState, blocksToDelete []kbfsblock.ID, writerLocked bool) error { err := cr.checkDone(ctx) if err != nil { return err } // Fix up all the block pointers in the merged ops to work well // for local notifications. Make a dummy op at the beginning to // convert all the merged most recent pointers into unmerged most // recent pointers. newOps, err := cr.getOpsForLocalNotification( ctx, lState, md, unmergedChains, mergedChains, updates) if err != nil { return err } cr.log.CDebugf(ctx, "Local notifications: %v", newOps) if writerLocked { return cr.fbo.finalizeResolutionLocked( ctx, lState, md, bps, newOps, blocksToDelete) } return cr.fbo.finalizeResolution( ctx, lState, md, bps, newOps, blocksToDelete) }
go
func (cr *ConflictResolver) finalizeResolution(ctx context.Context, lState *kbfssync.LockState, md *RootMetadata, unmergedChains, mergedChains *crChains, updates map[data.BlockPointer]data.BlockPointer, bps blockPutState, blocksToDelete []kbfsblock.ID, writerLocked bool) error { err := cr.checkDone(ctx) if err != nil { return err } // Fix up all the block pointers in the merged ops to work well // for local notifications. Make a dummy op at the beginning to // convert all the merged most recent pointers into unmerged most // recent pointers. newOps, err := cr.getOpsForLocalNotification( ctx, lState, md, unmergedChains, mergedChains, updates) if err != nil { return err } cr.log.CDebugf(ctx, "Local notifications: %v", newOps) if writerLocked { return cr.fbo.finalizeResolutionLocked( ctx, lState, md, bps, newOps, blocksToDelete) } return cr.fbo.finalizeResolution( ctx, lState, md, bps, newOps, blocksToDelete) }
[ "func", "(", "cr", "*", "ConflictResolver", ")", "finalizeResolution", "(", "ctx", "context", ".", "Context", ",", "lState", "*", "kbfssync", ".", "LockState", ",", "md", "*", "RootMetadata", ",", "unmergedChains", ",", "mergedChains", "*", "crChains", ",", ...
// finalizeResolution finishes the resolution process, making the // resolution visible to any nodes on the merged branch, and taking // the local node out of staged mode.
[ "finalizeResolution", "finishes", "the", "resolution", "process", "making", "the", "resolution", "visible", "to", "any", "nodes", "on", "the", "merged", "branch", "and", "taking", "the", "local", "node", "out", "of", "staged", "mode", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_resolver.go#L3076-L3105
161,362
keybase/client
go/kbfs/tlfhandle/path.go
BuildCanonicalPathForTlfType
func BuildCanonicalPathForTlfType(t tlf.Type, paths ...string) string { var pathType PathType switch t { case tlf.Private: pathType = PrivatePathType case tlf.Public: pathType = PublicPathType case tlf.SingleTeam: pathType = SingleTeamPathType default: panic(fmt.Sprintf("Unknown tlf path type: %d", t)) } return BuildCanonicalPath(pathType, paths...) }
go
func BuildCanonicalPathForTlfType(t tlf.Type, paths ...string) string { var pathType PathType switch t { case tlf.Private: pathType = PrivatePathType case tlf.Public: pathType = PublicPathType case tlf.SingleTeam: pathType = SingleTeamPathType default: panic(fmt.Sprintf("Unknown tlf path type: %d", t)) } return BuildCanonicalPath(pathType, paths...) }
[ "func", "BuildCanonicalPathForTlfType", "(", "t", "tlf", ".", "Type", ",", "paths", "...", "string", ")", "string", "{", "var", "pathType", "PathType", "\n", "switch", "t", "{", "case", "tlf", ".", "Private", ":", "pathType", "=", "PrivatePathType", "\n", ...
// BuildCanonicalPathForTlfType is like BuildCanonicalPath, but accepts a // tlf.Type instead of PathhType.
[ "BuildCanonicalPathForTlfType", "is", "like", "BuildCanonicalPath", "but", "accepts", "a", "tlf", ".", "Type", "instead", "of", "PathhType", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/path.go#L53-L67
161,363
keybase/client
go/kbfs/tlfhandle/path.go
BuildCanonicalPathForTlfName
func BuildCanonicalPathForTlfName(t tlf.Type, tlfName tlf.CanonicalName) string { return BuildCanonicalPathForTlfType(t, string(tlfName)) }
go
func BuildCanonicalPathForTlfName(t tlf.Type, tlfName tlf.CanonicalName) string { return BuildCanonicalPathForTlfType(t, string(tlfName)) }
[ "func", "BuildCanonicalPathForTlfName", "(", "t", "tlf", ".", "Type", ",", "tlfName", "tlf", ".", "CanonicalName", ")", "string", "{", "return", "BuildCanonicalPathForTlfType", "(", "t", ",", "string", "(", "tlfName", ")", ")", "\n", "}" ]
// BuildCanonicalPathForTlfName returns a canonical path for a tlf.
[ "BuildCanonicalPathForTlfName", "returns", "a", "canonical", "path", "for", "a", "tlf", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/path.go#L70-L72
161,364
keybase/client
go/kbfs/tlfhandle/path.go
BuildCanonicalPathForTlf
func BuildCanonicalPathForTlf(tlf tlf.ID, paths ...string) string { return BuildCanonicalPathForTlfType(tlf.Type(), paths...) }
go
func BuildCanonicalPathForTlf(tlf tlf.ID, paths ...string) string { return BuildCanonicalPathForTlfType(tlf.Type(), paths...) }
[ "func", "BuildCanonicalPathForTlf", "(", "tlf", "tlf", ".", "ID", ",", "paths", "...", "string", ")", "string", "{", "return", "BuildCanonicalPathForTlfType", "(", "tlf", ".", "Type", "(", ")", ",", "paths", "...", ")", "\n", "}" ]
// BuildCanonicalPathForTlf returns a canonical path for a tlf. Although tlf // identifies a TLF, paths should still include the TLF name. This function // does not try to canonicalize TLF names.
[ "BuildCanonicalPathForTlf", "returns", "a", "canonical", "path", "for", "a", "tlf", ".", "Although", "tlf", "identifies", "a", "TLF", "paths", "should", "still", "include", "the", "TLF", "name", ".", "This", "function", "does", "not", "try", "to", "canonicaliz...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/path.go#L77-L79
161,365
keybase/client
go/protocol/gregor1/incoming.go
ConsumeMessageMulti
func (c IncomingClient) ConsumeMessageMulti(ctx context.Context, __arg ConsumeMessageMultiArg) (err error) { err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.consumeMessageMulti", []interface{}{__arg}, nil, rpc.CompressionGzip) return }
go
func (c IncomingClient) ConsumeMessageMulti(ctx context.Context, __arg ConsumeMessageMultiArg) (err error) { err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.consumeMessageMulti", []interface{}{__arg}, nil, rpc.CompressionGzip) return }
[ "func", "(", "c", "IncomingClient", ")", "ConsumeMessageMulti", "(", "ctx", "context", ".", "Context", ",", "__arg", "ConsumeMessageMultiArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "CallCompressed", "(", "ctx", ",", "\"", ...
// consumeMessageMulti will take msg and consume it for all the users listed // in uids. This is so a gregor client can send the same message to many UIDs // with one call, as opposed to calling consumeMessage for each UID.
[ "consumeMessageMulti", "will", "take", "msg", "and", "consume", "it", "for", "all", "the", "users", "listed", "in", "uids", ".", "This", "is", "so", "a", "gregor", "client", "can", "send", "the", "same", "message", "to", "many", "UIDs", "with", "one", "c...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/gregor1/incoming.go#L321-L324
161,366
keybase/client
go/client/cmd_pgp_gen.go
Run
func (v *CmdPGPGen) Run() (err error) { protocols := []rpc.Protocol{ NewSecretUIProtocol(v.G()), } cli, err := GetPGPClient(v.G()) if err != nil { return err } user, err := GetUserClient(v.G()) if err != nil { return err } if err = RegisterProtocolsWithContext(protocols, v.G()); err != nil { return err } // Prompt for user IDs if none given on command line if len(v.arg.Gen.PGPUids) == 0 { if err = v.propmptPGPIDs(); err != nil { return err } } else if err = v.arg.Gen.CreatePGPIDs(); err != nil { return err } hasRandomPw, err := user.LoadHasRandomPw(context.TODO(), keybase1.LoadHasRandomPwArg{}) if err != nil { return err } if !hasRandomPw { v.arg.PushSecret, err = v.G().UI.GetTerminalUI().PromptYesNo(PromptDescriptorPGPGenPushSecret, "Push an encrypted copy of your new secret key to the Keybase.io server?", libkb.PromptDefaultYes) if err != nil { return err } } if v.arg.DoExport { v.arg.ExportEncrypted, err = v.G().UI.GetTerminalUI().PromptYesNo(PromptDescriptorPGPGenEncryptSecret, "When exporting to the GnuPG keychain, encrypt private keys with a passphrase?", libkb.PromptDefaultYes) if err != nil { return err } } err = cli.PGPKeyGen(context.TODO(), v.arg.Export()) err = AddPGPMultiInstructions(err) return err }
go
func (v *CmdPGPGen) Run() (err error) { protocols := []rpc.Protocol{ NewSecretUIProtocol(v.G()), } cli, err := GetPGPClient(v.G()) if err != nil { return err } user, err := GetUserClient(v.G()) if err != nil { return err } if err = RegisterProtocolsWithContext(protocols, v.G()); err != nil { return err } // Prompt for user IDs if none given on command line if len(v.arg.Gen.PGPUids) == 0 { if err = v.propmptPGPIDs(); err != nil { return err } } else if err = v.arg.Gen.CreatePGPIDs(); err != nil { return err } hasRandomPw, err := user.LoadHasRandomPw(context.TODO(), keybase1.LoadHasRandomPwArg{}) if err != nil { return err } if !hasRandomPw { v.arg.PushSecret, err = v.G().UI.GetTerminalUI().PromptYesNo(PromptDescriptorPGPGenPushSecret, "Push an encrypted copy of your new secret key to the Keybase.io server?", libkb.PromptDefaultYes) if err != nil { return err } } if v.arg.DoExport { v.arg.ExportEncrypted, err = v.G().UI.GetTerminalUI().PromptYesNo(PromptDescriptorPGPGenEncryptSecret, "When exporting to the GnuPG keychain, encrypt private keys with a passphrase?", libkb.PromptDefaultYes) if err != nil { return err } } err = cli.PGPKeyGen(context.TODO(), v.arg.Export()) err = AddPGPMultiInstructions(err) return err }
[ "func", "(", "v", "*", "CmdPGPGen", ")", "Run", "(", ")", "(", "err", "error", ")", "{", "protocols", ":=", "[", "]", "rpc", ".", "Protocol", "{", "NewSecretUIProtocol", "(", "v", ".", "G", "(", ")", ")", ",", "}", "\n", "cli", ",", "err", ":="...
// Why use CreatePGPIDs rather than MakeAllIds?
[ "Why", "use", "CreatePGPIDs", "rather", "than", "MakeAllIds?" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_pgp_gen.go#L45-L91
161,367
keybase/client
go/kbfs/idutil/data_types.go
ResetInfo
func (rki RevokedKeyInfo) ResetInfo() (keybase1.Seqno, bool) { return rki.resetSeqno, rki.isReset }
go
func (rki RevokedKeyInfo) ResetInfo() (keybase1.Seqno, bool) { return rki.resetSeqno, rki.isReset }
[ "func", "(", "rki", "RevokedKeyInfo", ")", "ResetInfo", "(", ")", "(", "keybase1", ".", "Seqno", ",", "bool", ")", "{", "return", "rki", ".", "resetSeqno", ",", "rki", ".", "isReset", "\n", "}" ]
// ResetInfo returns, if this key belongs to an account before it was // reset, data about that reset.
[ "ResetInfo", "returns", "if", "this", "key", "belongs", "to", "an", "account", "before", "it", "was", "reset", "data", "about", "that", "reset", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/data_types.go#L61-L63
161,368
keybase/client
go/kbfs/idutil/data_types.go
SetResetInfo
func (rki *RevokedKeyInfo) SetResetInfo(seqno keybase1.Seqno, isReset bool) { rki.resetSeqno = seqno rki.isReset = isReset }
go
func (rki *RevokedKeyInfo) SetResetInfo(seqno keybase1.Seqno, isReset bool) { rki.resetSeqno = seqno rki.isReset = isReset }
[ "func", "(", "rki", "*", "RevokedKeyInfo", ")", "SetResetInfo", "(", "seqno", "keybase1", ".", "Seqno", ",", "isReset", "bool", ")", "{", "rki", ".", "resetSeqno", "=", "seqno", "\n", "rki", ".", "isReset", "=", "isReset", "\n", "}" ]
// SetResetInfo sets, if this key belongs to an account before it was // reset, data about that reset.
[ "SetResetInfo", "sets", "if", "this", "key", "belongs", "to", "an", "account", "before", "it", "was", "reset", "data", "about", "that", "reset", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/data_types.go#L67-L70
161,369
keybase/client
go/kbfs/idutil/data_types.go
DeepCopy
func (ui UserInfo) DeepCopy() UserInfo { copyUI := ui copyUI.VerifyingKeys = make( []kbfscrypto.VerifyingKey, len(ui.VerifyingKeys)) copy(copyUI.VerifyingKeys, ui.VerifyingKeys) copyUI.CryptPublicKeys = make( []kbfscrypto.CryptPublicKey, len(ui.CryptPublicKeys)) copy(copyUI.CryptPublicKeys, ui.CryptPublicKeys) copyUI.KIDNames = make(map[keybase1.KID]string, len(ui.KIDNames)) for k, v := range ui.KIDNames { copyUI.KIDNames[k] = v } copyUI.RevokedVerifyingKeys = make( map[kbfscrypto.VerifyingKey]RevokedKeyInfo, len(ui.RevokedVerifyingKeys)) for k, v := range ui.RevokedVerifyingKeys { copyUI.RevokedVerifyingKeys[k] = v } copyUI.RevokedCryptPublicKeys = make( map[kbfscrypto.CryptPublicKey]RevokedKeyInfo, len(ui.RevokedCryptPublicKeys)) for k, v := range ui.RevokedCryptPublicKeys { copyUI.RevokedCryptPublicKeys[k] = v } return copyUI }
go
func (ui UserInfo) DeepCopy() UserInfo { copyUI := ui copyUI.VerifyingKeys = make( []kbfscrypto.VerifyingKey, len(ui.VerifyingKeys)) copy(copyUI.VerifyingKeys, ui.VerifyingKeys) copyUI.CryptPublicKeys = make( []kbfscrypto.CryptPublicKey, len(ui.CryptPublicKeys)) copy(copyUI.CryptPublicKeys, ui.CryptPublicKeys) copyUI.KIDNames = make(map[keybase1.KID]string, len(ui.KIDNames)) for k, v := range ui.KIDNames { copyUI.KIDNames[k] = v } copyUI.RevokedVerifyingKeys = make( map[kbfscrypto.VerifyingKey]RevokedKeyInfo, len(ui.RevokedVerifyingKeys)) for k, v := range ui.RevokedVerifyingKeys { copyUI.RevokedVerifyingKeys[k] = v } copyUI.RevokedCryptPublicKeys = make( map[kbfscrypto.CryptPublicKey]RevokedKeyInfo, len(ui.RevokedCryptPublicKeys)) for k, v := range ui.RevokedCryptPublicKeys { copyUI.RevokedCryptPublicKeys[k] = v } return copyUI }
[ "func", "(", "ui", "UserInfo", ")", "DeepCopy", "(", ")", "UserInfo", "{", "copyUI", ":=", "ui", "\n", "copyUI", ".", "VerifyingKeys", "=", "make", "(", "[", "]", "kbfscrypto", ".", "VerifyingKey", ",", "len", "(", "ui", ".", "VerifyingKeys", ")", ")",...
// DeepCopy returns a copy of `ui`, including deep copies of all slice // and map members.
[ "DeepCopy", "returns", "a", "copy", "of", "ui", "including", "deep", "copies", "of", "all", "slice", "and", "map", "members", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/data_types.go#L89-L114
161,370
keybase/client
go/kbfs/libfs/error_file.go
GetEncodedErrors
func GetEncodedErrors(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error) { return func(_ context.Context) ([]byte, time.Time, error) { errors := config.Reporter().AllKnownErrors() jsonErrors := make([]JSONReportedError, len(errors)) for i, e := range errors { jsonErrors[i].Time = e.Time jsonErrors[i].Error = e.Error.Error() jsonErrors[i].Stack = convertStack(e.Stack) } data, err := PrettyJSON(jsonErrors) var t time.Time if len(errors) > 0 { t = errors[len(errors)-1].Time } return data, t, err } }
go
func GetEncodedErrors(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error) { return func(_ context.Context) ([]byte, time.Time, error) { errors := config.Reporter().AllKnownErrors() jsonErrors := make([]JSONReportedError, len(errors)) for i, e := range errors { jsonErrors[i].Time = e.Time jsonErrors[i].Error = e.Error.Error() jsonErrors[i].Stack = convertStack(e.Stack) } data, err := PrettyJSON(jsonErrors) var t time.Time if len(errors) > 0 { t = errors[len(errors)-1].Time } return data, t, err } }
[ "func", "GetEncodedErrors", "(", "config", "libkbfs", ".", "Config", ")", "func", "(", "context", ".", "Context", ")", "(", "[", "]", "byte", ",", "time", ".", "Time", ",", "error", ")", "{", "return", "func", "(", "_", "context", ".", "Context", ")"...
// GetEncodedErrors gets the list of encoded errors in a format suitable // for error file.
[ "GetEncodedErrors", "gets", "the", "list", "of", "encoded", "errors", "in", "a", "format", "suitable", "for", "error", "file", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/error_file.go#L34-L50
161,371
keybase/client
go/mounter/mounter_osx.go
cstr
func cstr(ca []int8) string { s := make([]byte, 0, len(ca)) for _, c := range ca { if c == 0x00 { break } s = append(s, byte(c)) } return string(s) }
go
func cstr(ca []int8) string { s := make([]byte, 0, len(ca)) for _, c := range ca { if c == 0x00 { break } s = append(s, byte(c)) } return string(s) }
[ "func", "cstr", "(", "ca", "[", "]", "int8", ")", "string", "{", "s", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "len", "(", "ca", ")", ")", "\n", "for", "_", ",", "c", ":=", "range", "ca", "{", "if", "c", "==", "0x00", "{", "bre...
// cstr converts a nil-terminated C string into a Go string
[ "cstr", "converts", "a", "nil", "-", "terminated", "C", "string", "into", "a", "Go", "string" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/mounter/mounter_osx.go#L42-L51
161,372
keybase/client
go/chat/storage/storage.go
Merge
func (s *Storage) Merge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msgs []chat1.MessageUnboxed) (res MergeResult, err Error) { defer s.Trace(ctx, func() error { return err }, "Merge")() return s.MergeHelper(ctx, convID, uid, msgs, nil) }
go
func (s *Storage) Merge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msgs []chat1.MessageUnboxed) (res MergeResult, err Error) { defer s.Trace(ctx, func() error { return err }, "Merge")() return s.MergeHelper(ctx, convID, uid, msgs, nil) }
[ "func", "(", "s", "*", "Storage", ")", "Merge", "(", "ctx", "context", ".", "Context", ",", "convID", "chat1", ".", "ConversationID", ",", "uid", "gregor1", ".", "UID", ",", "msgs", "[", "]", "chat1", ".", "MessageUnboxed", ")", "(", "res", "MergeResul...
// Merge requires msgs to be sorted by descending message ID
[ "Merge", "requires", "msgs", "to", "be", "sorted", "by", "descending", "message", "ID" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage.go#L378-L382
161,373
keybase/client
go/chat/storage/storage.go
applyExpunge
func (s *Storage) applyExpunge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, expunge chat1.Expunge) (*chat1.Expunge, Error) { s.Debug(ctx, "applyExpunge(%v, %v, %v)", convID, uid, expunge.Upto) de := func(format string, args ...interface{}) { s.Debug(ctx, "applyExpunge: "+fmt.Sprintf(format, args...)) } rc := NewInsatiableResultCollector() // collect all messages err := s.engine.ReadMessages(ctx, rc, convID, uid, expunge.Upto-1, 0) switch err.(type) { case nil: // ok case MissError: de("record-only delh: no local messages") err := s.delhTracker.setMaxDeleteHistoryUpto(ctx, convID, uid, expunge.Upto) if err != nil { de("failed to store delh track: %v", err) } return nil, nil default: return nil, err } var allAssets []chat1.Asset var writeback, allPurged []chat1.MessageUnboxed for _, msg := range rc.Result() { if !chat1.IsDeletableByDeleteHistory(msg.GetMessageType()) { // Skip message types that cannot be deleted this way continue } if !msg.IsValid() { de("skipping invalid msg: %v", msg.DebugString()) continue } mvalid := msg.Valid() if mvalid.MessageBody.IsNil() { continue } mvalid.ServerHeader.SupersededBy = expunge.Basis // Can be 0 msgPurged, assets := s.purgeMessage(mvalid) allPurged = append(allPurged, msg) allAssets = append(allAssets, assets...) writeback = append(writeback, msgPurged) } // queue asset deletions in the background s.assetDeleter.DeleteAssets(ctx, uid, convID, allAssets) // queue search index update in the background go s.G().Indexer.Remove(ctx, convID, uid, allPurged) de("deleting %v messages", len(writeback)) if err = s.engine.WriteMessages(ctx, convID, uid, writeback); err != nil { de("write messages failed: %v", err) return nil, err } err = s.delhTracker.setDeletedUpto(ctx, convID, uid, expunge.Upto) if err != nil { de("failed to store delh track: %v", err) } return &expunge, nil }
go
func (s *Storage) applyExpunge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, expunge chat1.Expunge) (*chat1.Expunge, Error) { s.Debug(ctx, "applyExpunge(%v, %v, %v)", convID, uid, expunge.Upto) de := func(format string, args ...interface{}) { s.Debug(ctx, "applyExpunge: "+fmt.Sprintf(format, args...)) } rc := NewInsatiableResultCollector() // collect all messages err := s.engine.ReadMessages(ctx, rc, convID, uid, expunge.Upto-1, 0) switch err.(type) { case nil: // ok case MissError: de("record-only delh: no local messages") err := s.delhTracker.setMaxDeleteHistoryUpto(ctx, convID, uid, expunge.Upto) if err != nil { de("failed to store delh track: %v", err) } return nil, nil default: return nil, err } var allAssets []chat1.Asset var writeback, allPurged []chat1.MessageUnboxed for _, msg := range rc.Result() { if !chat1.IsDeletableByDeleteHistory(msg.GetMessageType()) { // Skip message types that cannot be deleted this way continue } if !msg.IsValid() { de("skipping invalid msg: %v", msg.DebugString()) continue } mvalid := msg.Valid() if mvalid.MessageBody.IsNil() { continue } mvalid.ServerHeader.SupersededBy = expunge.Basis // Can be 0 msgPurged, assets := s.purgeMessage(mvalid) allPurged = append(allPurged, msg) allAssets = append(allAssets, assets...) writeback = append(writeback, msgPurged) } // queue asset deletions in the background s.assetDeleter.DeleteAssets(ctx, uid, convID, allAssets) // queue search index update in the background go s.G().Indexer.Remove(ctx, convID, uid, allPurged) de("deleting %v messages", len(writeback)) if err = s.engine.WriteMessages(ctx, convID, uid, writeback); err != nil { de("write messages failed: %v", err) return nil, err } err = s.delhTracker.setDeletedUpto(ctx, convID, uid, expunge.Upto) if err != nil { de("failed to store delh track: %v", err) } return &expunge, nil }
[ "func", "(", "s", "*", "Storage", ")", "applyExpunge", "(", "ctx", "context", ".", "Context", ",", "convID", "chat1", ".", "ConversationID", ",", "uid", "gregor1", ".", "UID", ",", "expunge", "chat1", ".", "Expunge", ")", "(", "*", "chat1", ".", "Expun...
// Apply a delete history. // Returns a non-nil expunge if deletes happened. // Always runs through local messages.
[ "Apply", "a", "delete", "history", ".", "Returns", "a", "non", "-", "nil", "expunge", "if", "deletes", "happened", ".", "Always", "runs", "through", "local", "messages", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage.go#L760-L824
161,374
keybase/client
go/chat/storage/storage.go
clearUpthrough
func (s *Storage) clearUpthrough(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, upthrough chat1.MessageID) (err Error) { defer s.Trace(ctx, func() error { return err }, "clearUpthrough")() key, ierr := GetSecretBoxKey(ctx, s.G().ExternalG(), DefaultSecretUI) if ierr != nil { return MiscError{Msg: "unable to get secret key: " + ierr.Error()} } ctx, err = s.engine.Init(ctx, key, convID, uid) if err != nil { return err } var msgIDs []chat1.MessageID for m := upthrough; m > 0; m-- { msgIDs = append(msgIDs, m) } return s.engine.ClearMessages(ctx, convID, uid, msgIDs) }
go
func (s *Storage) clearUpthrough(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, upthrough chat1.MessageID) (err Error) { defer s.Trace(ctx, func() error { return err }, "clearUpthrough")() key, ierr := GetSecretBoxKey(ctx, s.G().ExternalG(), DefaultSecretUI) if ierr != nil { return MiscError{Msg: "unable to get secret key: " + ierr.Error()} } ctx, err = s.engine.Init(ctx, key, convID, uid) if err != nil { return err } var msgIDs []chat1.MessageID for m := upthrough; m > 0; m-- { msgIDs = append(msgIDs, m) } return s.engine.ClearMessages(ctx, convID, uid, msgIDs) }
[ "func", "(", "s", "*", "Storage", ")", "clearUpthrough", "(", "ctx", "context", ".", "Context", ",", "convID", "chat1", ".", "ConversationID", ",", "uid", "gregor1", ".", "UID", ",", "upthrough", "chat1", ".", "MessageID", ")", "(", "err", "Error", ")", ...
// clearUpthrough clears up to the given message ID, inclusive
[ "clearUpthrough", "clears", "up", "to", "the", "given", "message", "ID", "inclusive" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage.go#L827-L844
161,375
keybase/client
go/chat/storage/storage.go
updateReactionIDs
func (s *Storage) updateReactionIDs(reactionIDs []chat1.MessageID, msgid chat1.MessageID) ([]chat1.MessageID, bool) { for _, reactionID := range reactionIDs { if reactionID == msgid { return reactionIDs, false } } return append(reactionIDs, msgid), true }
go
func (s *Storage) updateReactionIDs(reactionIDs []chat1.MessageID, msgid chat1.MessageID) ([]chat1.MessageID, bool) { for _, reactionID := range reactionIDs { if reactionID == msgid { return reactionIDs, false } } return append(reactionIDs, msgid), true }
[ "func", "(", "s", "*", "Storage", ")", "updateReactionIDs", "(", "reactionIDs", "[", "]", "chat1", ".", "MessageID", ",", "msgid", "chat1", ".", "MessageID", ")", "(", "[", "]", "chat1", ".", "MessageID", ",", "bool", ")", "{", "for", "_", ",", "reac...
// updateReactionIDs appends `msgid` to `reactionIDs` if it is not already // present.
[ "updateReactionIDs", "appends", "msgid", "to", "reactionIDs", "if", "it", "is", "not", "already", "present", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage.go#L1184-L1191
161,376
keybase/client
go/chat/storage/storage.go
updateReactionTargetOnDelete
func (s *Storage) updateReactionTargetOnDelete(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, reactionMsg *chat1.MessageUnboxed) (*chat1.MessageUnboxed, bool, Error) { s.Debug(ctx, "updateReactionTargetOnDelete: reationMsg: %v", reactionMsg) if reactionMsg.Valid().MessageBody.IsNil() { return nil, false, nil } targetMsgID := reactionMsg.Valid().MessageBody.Reaction().MessageID targetMsg, err := s.getMessage(ctx, convID, uid, targetMsgID) if err != nil || targetMsg == nil { return nil, false, err } if targetMsg.IsValid() { mvalid := targetMsg.Valid() reactionIDs := []chat1.MessageID{} for _, msgID := range mvalid.ServerHeader.ReactionIDs { if msgID != reactionMsg.GetMessageID() { reactionIDs = append(reactionIDs, msgID) } } updated := len(mvalid.ServerHeader.ReactionIDs) != len(reactionIDs) mvalid.ServerHeader.ReactionIDs = reactionIDs newMsg := chat1.NewMessageUnboxedWithValid(mvalid) return &newMsg, updated, nil } return nil, false, nil }
go
func (s *Storage) updateReactionTargetOnDelete(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, reactionMsg *chat1.MessageUnboxed) (*chat1.MessageUnboxed, bool, Error) { s.Debug(ctx, "updateReactionTargetOnDelete: reationMsg: %v", reactionMsg) if reactionMsg.Valid().MessageBody.IsNil() { return nil, false, nil } targetMsgID := reactionMsg.Valid().MessageBody.Reaction().MessageID targetMsg, err := s.getMessage(ctx, convID, uid, targetMsgID) if err != nil || targetMsg == nil { return nil, false, err } if targetMsg.IsValid() { mvalid := targetMsg.Valid() reactionIDs := []chat1.MessageID{} for _, msgID := range mvalid.ServerHeader.ReactionIDs { if msgID != reactionMsg.GetMessageID() { reactionIDs = append(reactionIDs, msgID) } } updated := len(mvalid.ServerHeader.ReactionIDs) != len(reactionIDs) mvalid.ServerHeader.ReactionIDs = reactionIDs newMsg := chat1.NewMessageUnboxedWithValid(mvalid) return &newMsg, updated, nil } return nil, false, nil }
[ "func", "(", "s", "*", "Storage", ")", "updateReactionTargetOnDelete", "(", "ctx", "context", ".", "Context", ",", "convID", "chat1", ".", "ConversationID", ",", "uid", "gregor1", ".", "UID", ",", "reactionMsg", "*", "chat1", ".", "MessageUnboxed", ")", "(",...
// updateReactionTargetOnDelete modifies the reaction's target message when the // reaction itself is deleted
[ "updateReactionTargetOnDelete", "modifies", "the", "reaction", "s", "target", "message", "when", "the", "reaction", "itself", "is", "deleted" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage.go#L1195-L1222
161,377
keybase/client
go/chat/storage/storage.go
purgeMessage
func (s *Storage) purgeMessage(mvalid chat1.MessageUnboxedValid) (chat1.MessageUnboxed, []chat1.Asset) { assets := utils.AssetsForMessage(s.G(), mvalid.MessageBody) var emptyBody chat1.MessageBody mvalid.MessageBody = emptyBody var emptyReactions chat1.ReactionMap mvalid.Reactions = emptyReactions return chat1.NewMessageUnboxedWithValid(mvalid), assets }
go
func (s *Storage) purgeMessage(mvalid chat1.MessageUnboxedValid) (chat1.MessageUnboxed, []chat1.Asset) { assets := utils.AssetsForMessage(s.G(), mvalid.MessageBody) var emptyBody chat1.MessageBody mvalid.MessageBody = emptyBody var emptyReactions chat1.ReactionMap mvalid.Reactions = emptyReactions return chat1.NewMessageUnboxedWithValid(mvalid), assets }
[ "func", "(", "s", "*", "Storage", ")", "purgeMessage", "(", "mvalid", "chat1", ".", "MessageUnboxedValid", ")", "(", "chat1", ".", "MessageUnboxed", ",", "[", "]", "chat1", ".", "Asset", ")", "{", "assets", ":=", "utils", ".", "AssetsForMessage", "(", "s...
// Clears the body of a message and returns any assets to be deleted.
[ "Clears", "the", "body", "of", "a", "message", "and", "returns", "any", "assets", "to", "be", "deleted", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage.go#L1225-L1232
161,378
keybase/client
go/kbfs/libkbfs/ops.go
AddRefBlock
func (oc *OpCommon) AddRefBlock(ptr data.BlockPointer) { oc.RefBlocks = append(oc.RefBlocks, ptr) }
go
func (oc *OpCommon) AddRefBlock(ptr data.BlockPointer) { oc.RefBlocks = append(oc.RefBlocks, ptr) }
[ "func", "(", "oc", "*", "OpCommon", ")", "AddRefBlock", "(", "ptr", "data", ".", "BlockPointer", ")", "{", "oc", ".", "RefBlocks", "=", "append", "(", "oc", ".", "RefBlocks", ",", "ptr", ")", "\n", "}" ]
// AddRefBlock adds this block to the list of newly-referenced blocks // for this op.
[ "AddRefBlock", "adds", "this", "block", "to", "the", "list", "of", "newly", "-", "referenced", "blocks", "for", "this", "op", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L195-L197
161,379
keybase/client
go/kbfs/libkbfs/ops.go
DelRefBlock
func (oc *OpCommon) DelRefBlock(ptr data.BlockPointer) { for i, ref := range oc.RefBlocks { if ptr == ref { oc.RefBlocks = append(oc.RefBlocks[:i], oc.RefBlocks[i+1:]...) break } } }
go
func (oc *OpCommon) DelRefBlock(ptr data.BlockPointer) { for i, ref := range oc.RefBlocks { if ptr == ref { oc.RefBlocks = append(oc.RefBlocks[:i], oc.RefBlocks[i+1:]...) break } } }
[ "func", "(", "oc", "*", "OpCommon", ")", "DelRefBlock", "(", "ptr", "data", ".", "BlockPointer", ")", "{", "for", "i", ",", "ref", ":=", "range", "oc", ".", "RefBlocks", "{", "if", "ptr", "==", "ref", "{", "oc", ".", "RefBlocks", "=", "append", "("...
// DelRefBlock removes the first reference of the given block from the // list of newly-referenced blocks for this op.
[ "DelRefBlock", "removes", "the", "first", "reference", "of", "the", "given", "block", "from", "the", "list", "of", "newly", "-", "referenced", "blocks", "for", "this", "op", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L201-L208
161,380
keybase/client
go/kbfs/libkbfs/ops.go
AddUnrefBlock
func (oc *OpCommon) AddUnrefBlock(ptr data.BlockPointer) { oc.UnrefBlocks = append(oc.UnrefBlocks, ptr) }
go
func (oc *OpCommon) AddUnrefBlock(ptr data.BlockPointer) { oc.UnrefBlocks = append(oc.UnrefBlocks, ptr) }
[ "func", "(", "oc", "*", "OpCommon", ")", "AddUnrefBlock", "(", "ptr", "data", ".", "BlockPointer", ")", "{", "oc", ".", "UnrefBlocks", "=", "append", "(", "oc", ".", "UnrefBlocks", ",", "ptr", ")", "\n", "}" ]
// AddUnrefBlock adds this block to the list of newly-unreferenced blocks // for this op.
[ "AddUnrefBlock", "adds", "this", "block", "to", "the", "list", "of", "newly", "-", "unreferenced", "blocks", "for", "this", "op", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L212-L214
161,381
keybase/client
go/kbfs/libkbfs/ops.go
DelUnrefBlock
func (oc *OpCommon) DelUnrefBlock(ptr data.BlockPointer) { for i, unref := range oc.UnrefBlocks { if ptr == unref { oc.UnrefBlocks = append(oc.UnrefBlocks[:i], oc.UnrefBlocks[i+1:]...) break } } }
go
func (oc *OpCommon) DelUnrefBlock(ptr data.BlockPointer) { for i, unref := range oc.UnrefBlocks { if ptr == unref { oc.UnrefBlocks = append(oc.UnrefBlocks[:i], oc.UnrefBlocks[i+1:]...) break } } }
[ "func", "(", "oc", "*", "OpCommon", ")", "DelUnrefBlock", "(", "ptr", "data", ".", "BlockPointer", ")", "{", "for", "i", ",", "unref", ":=", "range", "oc", ".", "UnrefBlocks", "{", "if", "ptr", "==", "unref", "{", "oc", ".", "UnrefBlocks", "=", "appe...
// DelUnrefBlock removes the first unreference of the given block from // the list of unreferenced blocks for this op.
[ "DelUnrefBlock", "removes", "the", "first", "unreference", "of", "the", "given", "block", "from", "the", "list", "of", "unreferenced", "blocks", "for", "this", "op", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L218-L225
161,382
keybase/client
go/kbfs/libkbfs/ops.go
AddUpdate
func (oc *OpCommon) AddUpdate(oldPtr data.BlockPointer, newPtr data.BlockPointer) { // Either pointer may be zero, if we're building an op that // will be fixed up later. bu := blockUpdate{oldPtr, newPtr} oc.Updates = append(oc.Updates, bu) }
go
func (oc *OpCommon) AddUpdate(oldPtr data.BlockPointer, newPtr data.BlockPointer) { // Either pointer may be zero, if we're building an op that // will be fixed up later. bu := blockUpdate{oldPtr, newPtr} oc.Updates = append(oc.Updates, bu) }
[ "func", "(", "oc", "*", "OpCommon", ")", "AddUpdate", "(", "oldPtr", "data", ".", "BlockPointer", ",", "newPtr", "data", ".", "BlockPointer", ")", "{", "// Either pointer may be zero, if we're building an op that", "// will be fixed up later.", "bu", ":=", "blockUpdate"...
// AddUpdate adds a mapping from an old block to the new version of // that block, for this op.
[ "AddUpdate", "adds", "a", "mapping", "from", "an", "old", "block", "to", "the", "new", "version", "of", "that", "block", "for", "this", "op", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L229-L234
161,383
keybase/client
go/kbfs/libkbfs/ops.go
ToEditNotification
func (oc *OpCommon) ToEditNotification( _ kbfsmd.Revision, _ time.Time, _ kbfscrypto.VerifyingKey, _ keybase1.UID, _ tlf.ID) *kbfsedits.NotificationMessage { // Ops embedding this that can be converted should override this. return nil }
go
func (oc *OpCommon) ToEditNotification( _ kbfsmd.Revision, _ time.Time, _ kbfscrypto.VerifyingKey, _ keybase1.UID, _ tlf.ID) *kbfsedits.NotificationMessage { // Ops embedding this that can be converted should override this. return nil }
[ "func", "(", "oc", "*", "OpCommon", ")", "ToEditNotification", "(", "_", "kbfsmd", ".", "Revision", ",", "_", "time", ".", "Time", ",", "_", "kbfscrypto", ".", "VerifyingKey", ",", "_", "keybase1", ".", "UID", ",", "_", "tlf", ".", "ID", ")", "*", ...
// ToEditNotification implements the op interface for OpCommon.
[ "ToEditNotification", "implements", "the", "op", "interface", "for", "OpCommon", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L305-L310
161,384
keybase/client
go/kbfs/libkbfs/ops.go
End
func (w WriteRange) End() uint64 { if w.isTruncate() { panic("Truncates don't have an end") } return w.Off + w.Len }
go
func (w WriteRange) End() uint64 { if w.isTruncate() { panic("Truncates don't have an end") } return w.Off + w.Len }
[ "func", "(", "w", "WriteRange", ")", "End", "(", ")", "uint64", "{", "if", "w", ".", "isTruncate", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "w", ".", "Off", "+", "w", ".", "Len", "\n", "}" ]
// End returns the index of the largest byte not affected by this // write. It only makes sense to call this for non-truncates.
[ "End", "returns", "the", "index", "of", "the", "largest", "byte", "not", "affected", "by", "this", "write", ".", "It", "only", "makes", "sense", "to", "call", "this", "for", "non", "-", "truncates", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L810-L815
161,385
keybase/client
go/kbfs/libkbfs/ops.go
SizeExceptUpdates
func (gco *GCOp) SizeExceptUpdates() uint64 { return data.BPSize * uint64(len(gco.UnrefBlocks)) }
go
func (gco *GCOp) SizeExceptUpdates() uint64 { return data.BPSize * uint64(len(gco.UnrefBlocks)) }
[ "func", "(", "gco", "*", "GCOp", ")", "SizeExceptUpdates", "(", ")", "uint64", "{", "return", "data", ".", "BPSize", "*", "uint64", "(", "len", "(", "gco", ".", "UnrefBlocks", ")", ")", "\n", "}" ]
// SizeExceptUpdates implements op.
[ "SizeExceptUpdates", "implements", "op", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L1432-L1434
161,386
keybase/client
go/kbfs/libkbfs/ops.go
StringWithRefs
func (gco *GCOp) StringWithRefs(indent string) string { res := gco.String() + "\n" res += gco.stringWithRefs(indent) return res }
go
func (gco *GCOp) StringWithRefs(indent string) string { res := gco.String() + "\n" res += gco.stringWithRefs(indent) return res }
[ "func", "(", "gco", "*", "GCOp", ")", "StringWithRefs", "(", "indent", "string", ")", "string", "{", "res", ":=", "gco", ".", "String", "(", ")", "+", "\"", "\\n", "\"", "\n", "res", "+=", "gco", ".", "stringWithRefs", "(", "indent", ")", "\n", "re...
// StringWithRefs implements the op interface for GCOp.
[ "StringWithRefs", "implements", "the", "op", "interface", "for", "GCOp", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L1449-L1453
161,387
keybase/client
go/kbfs/libkbfs/ops.go
checkConflict
func (gco *GCOp) checkConflict( ctx context.Context, renamer ConflictRenamer, mergedOp op, isFile bool) (crAction, error) { return nil, nil }
go
func (gco *GCOp) checkConflict( ctx context.Context, renamer ConflictRenamer, mergedOp op, isFile bool) (crAction, error) { return nil, nil }
[ "func", "(", "gco", "*", "GCOp", ")", "checkConflict", "(", "ctx", "context", ".", "Context", ",", "renamer", "ConflictRenamer", ",", "mergedOp", "op", ",", "isFile", "bool", ")", "(", "crAction", ",", "error", ")", "{", "return", "nil", ",", "nil", "\...
// checkConflict implements op.
[ "checkConflict", "implements", "op", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L1456-L1460
161,388
keybase/client
go/kbfs/libkbfs/ops.go
RegisterOps
func RegisterOps(codec kbfscodec.Codec) { codec.RegisterType(reflect.TypeOf(createOp{}), createOpCode) codec.RegisterType(reflect.TypeOf(rmOp{}), rmOpCode) codec.RegisterType(reflect.TypeOf(renameOp{}), renameOpCode) codec.RegisterType(reflect.TypeOf(syncOp{}), syncOpCode) codec.RegisterType(reflect.TypeOf(setAttrOp{}), setAttrOpCode) codec.RegisterType(reflect.TypeOf(resolutionOp{}), resolutionOpCode) codec.RegisterType(reflect.TypeOf(rekeyOp{}), rekeyOpCode) codec.RegisterType(reflect.TypeOf(GCOp{}), gcOpCode) codec.RegisterIfaceSliceType(reflect.TypeOf(opsList{}), opsListCode, opPointerizer) }
go
func RegisterOps(codec kbfscodec.Codec) { codec.RegisterType(reflect.TypeOf(createOp{}), createOpCode) codec.RegisterType(reflect.TypeOf(rmOp{}), rmOpCode) codec.RegisterType(reflect.TypeOf(renameOp{}), renameOpCode) codec.RegisterType(reflect.TypeOf(syncOp{}), syncOpCode) codec.RegisterType(reflect.TypeOf(setAttrOp{}), setAttrOpCode) codec.RegisterType(reflect.TypeOf(resolutionOp{}), resolutionOpCode) codec.RegisterType(reflect.TypeOf(rekeyOp{}), rekeyOpCode) codec.RegisterType(reflect.TypeOf(GCOp{}), gcOpCode) codec.RegisterIfaceSliceType(reflect.TypeOf(opsList{}), opsListCode, opPointerizer) }
[ "func", "RegisterOps", "(", "codec", "kbfscodec", ".", "Codec", ")", "{", "codec", ".", "RegisterType", "(", "reflect", ".", "TypeOf", "(", "createOp", "{", "}", ")", ",", "createOpCode", ")", "\n", "codec", ".", "RegisterType", "(", "reflect", ".", "Typ...
// RegisterOps registers all op types with the given codec.
[ "RegisterOps", "registers", "all", "op", "types", "with", "the", "given", "codec", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/ops.go#L1563-L1574
161,389
keybase/client
go/service/account.go
EnterResetPipeline
func (h *AccountHandler) EnterResetPipeline(ctx context.Context, arg keybase1.EnterResetPipelineArg) (err error) { mctx := libkb.NewMetaContext(ctx, h.G()) defer mctx.TraceTimed("EnterResetPipline", func() error { return err })() uis := libkb.UIs{ LoginUI: h.getLoginUI(arg.SessionID), SecretUI: h.getSecretUI(arg.SessionID, h.G()), LogUI: h.getLogUI(arg.SessionID), SessionID: arg.SessionID, } eng := engine.NewAccountReset(h.G(), arg.UsernameOrEmail) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) return engine.RunEngine2(m, eng) }
go
func (h *AccountHandler) EnterResetPipeline(ctx context.Context, arg keybase1.EnterResetPipelineArg) (err error) { mctx := libkb.NewMetaContext(ctx, h.G()) defer mctx.TraceTimed("EnterResetPipline", func() error { return err })() uis := libkb.UIs{ LoginUI: h.getLoginUI(arg.SessionID), SecretUI: h.getSecretUI(arg.SessionID, h.G()), LogUI: h.getLogUI(arg.SessionID), SessionID: arg.SessionID, } eng := engine.NewAccountReset(h.G(), arg.UsernameOrEmail) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) return engine.RunEngine2(m, eng) }
[ "func", "(", "h", "*", "AccountHandler", ")", "EnterResetPipeline", "(", "ctx", "context", ".", "Context", ",", "arg", "keybase1", ".", "EnterResetPipelineArg", ")", "(", "err", "error", ")", "{", "mctx", ":=", "libkb", ".", "NewMetaContext", "(", "ctx", "...
// EnterPipeline allows a user to enter the reset pipeline. The user must // verify ownership of the account via an email confirmation or their password. // Resets are not allowed on a provisioned device.
[ "EnterPipeline", "allows", "a", "user", "to", "enter", "the", "reset", "pipeline", ".", "The", "user", "must", "verify", "ownership", "of", "the", "account", "via", "an", "email", "confirmation", "or", "their", "password", ".", "Resets", "are", "not", "allow...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/account.go#L217-L229
161,390
keybase/client
go/service/account.go
CancelReset
func (h *AccountHandler) CancelReset(ctx context.Context, sessionID int) error { mctx := libkb.NewMetaContext(ctx, h.G()) return libkb.CancelResetPipeline(mctx) }
go
func (h *AccountHandler) CancelReset(ctx context.Context, sessionID int) error { mctx := libkb.NewMetaContext(ctx, h.G()) return libkb.CancelResetPipeline(mctx) }
[ "func", "(", "h", "*", "AccountHandler", ")", "CancelReset", "(", "ctx", "context", ".", "Context", ",", "sessionID", "int", ")", "error", "{", "mctx", ":=", "libkb", ".", "NewMetaContext", "(", "ctx", ",", "h", ".", "G", "(", ")", ")", "\n", "return...
// CancelReset allows a user to cancel the reset process via an authenticated API call.
[ "CancelReset", "allows", "a", "user", "to", "cancel", "the", "reset", "process", "via", "an", "authenticated", "API", "call", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/account.go#L232-L235
161,391
keybase/client
go/pvl/helpers.go
selectionText
func selectionText(selection *goquery.Selection) string { var results []string selection.Each(func(i int, element *goquery.Selection) { results = append(results, element.Text()) }) return strings.Join(results, " ") }
go
func selectionText(selection *goquery.Selection) string { var results []string selection.Each(func(i int, element *goquery.Selection) { results = append(results, element.Text()) }) return strings.Join(results, " ") }
[ "func", "selectionText", "(", "selection", "*", "goquery", ".", "Selection", ")", "string", "{", "var", "results", "[", "]", "string", "\n", "selection", ".", "Each", "(", "func", "(", "i", "int", ",", "element", "*", "goquery", ".", "Selection", ")", ...
// selectionText gets the Text of all elements in a selection, concatenated by a space. // The result can be an empty string.
[ "selectionText", "gets", "the", "Text", "of", "all", "elements", "in", "a", "selection", "concatenated", "by", "a", "space", ".", "The", "result", "can", "be", "an", "empty", "string", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/helpers.go#L68-L74
161,392
keybase/client
go/pvl/helpers.go
selectionAttr
func selectionAttr(selection *goquery.Selection, attr string) string { var results []string selection.Each(func(i int, element *goquery.Selection) { res, ok := element.Attr(attr) if ok { results = append(results, res) } }) return strings.Join(results, " ") }
go
func selectionAttr(selection *goquery.Selection, attr string) string { var results []string selection.Each(func(i int, element *goquery.Selection) { res, ok := element.Attr(attr) if ok { results = append(results, res) } }) return strings.Join(results, " ") }
[ "func", "selectionAttr", "(", "selection", "*", "goquery", ".", "Selection", ",", "attr", "string", ")", "string", "{", "var", "results", "[", "]", "string", "\n", "selection", ".", "Each", "(", "func", "(", "i", "int", ",", "element", "*", "goquery", ...
// selectionAttr gets the specified attr of all elements in a selection, concatenated by a space. // If getting the attr of any elements fails, that does not cause an error. // The result can be an empty string.
[ "selectionAttr", "gets", "the", "specified", "attr", "of", "all", "elements", "in", "a", "selection", "concatenated", "by", "a", "space", ".", "If", "getting", "the", "attr", "of", "any", "elements", "fails", "that", "does", "not", "cause", "an", "error", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/helpers.go#L79-L88
161,393
keybase/client
go/pvl/helpers.go
selectionData
func selectionData(selection *goquery.Selection) string { var results []string selection.Each(func(i int, element *goquery.Selection) { if len(element.Nodes) > 0 { results = append(results, element.Nodes[0].Data) } }) return strings.Join(results, " ") }
go
func selectionData(selection *goquery.Selection) string { var results []string selection.Each(func(i int, element *goquery.Selection) { if len(element.Nodes) > 0 { results = append(results, element.Nodes[0].Data) } }) return strings.Join(results, " ") }
[ "func", "selectionData", "(", "selection", "*", "goquery", ".", "Selection", ")", "string", "{", "var", "results", "[", "]", "string", "\n", "selection", ".", "Each", "(", "func", "(", "i", "int", ",", "element", "*", "goquery", ".", "Selection", ")", ...
// selectionData gets the first node's data of all elements in a selection, concatenated by a space. // The result can be an empty string.
[ "selectionData", "gets", "the", "first", "node", "s", "data", "of", "all", "elements", "in", "a", "selection", "concatenated", "by", "a", "space", ".", "The", "result", "can", "be", "an", "empty", "string", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/helpers.go#L92-L100
161,394
keybase/client
go/pvl/helpers.go
validateDomain
func validateDomain(s string) bool { // Throw a protocol in front because the parser wants one. proto := "http" u, err := url.Parse(proto + "://" + s) if err != nil { return false } // The final group must include a non-numeric character. // To disallow the likes of "8.8.8.8." dotsplit := strings.Split(strings.TrimSuffix(u.Host, "."), ".") if len(dotsplit) > 0 { group := dotsplit[len(dotsplit)-1] if !hasalpha.MatchString(group) { return false } } ok := (u.IsAbs()) && (u.Scheme == proto) && (u.User == nil) && (u.Path == "") && (u.RawPath == "") && (u.RawQuery == "") && (u.Fragment == "") && // Disallow colons. So no port, and no ipv6. (!strings.Contains(u.Host, ":")) && // Disallow any valid ip addresses. (net.ParseIP(u.Host) == nil) return ok }
go
func validateDomain(s string) bool { // Throw a protocol in front because the parser wants one. proto := "http" u, err := url.Parse(proto + "://" + s) if err != nil { return false } // The final group must include a non-numeric character. // To disallow the likes of "8.8.8.8." dotsplit := strings.Split(strings.TrimSuffix(u.Host, "."), ".") if len(dotsplit) > 0 { group := dotsplit[len(dotsplit)-1] if !hasalpha.MatchString(group) { return false } } ok := (u.IsAbs()) && (u.Scheme == proto) && (u.User == nil) && (u.Path == "") && (u.RawPath == "") && (u.RawQuery == "") && (u.Fragment == "") && // Disallow colons. So no port, and no ipv6. (!strings.Contains(u.Host, ":")) && // Disallow any valid ip addresses. (net.ParseIP(u.Host) == nil) return ok }
[ "func", "validateDomain", "(", "s", "string", ")", "bool", "{", "// Throw a protocol in front because the parser wants one.", "proto", ":=", "\"", "\"", "\n", "u", ",", "err", ":=", "url", ".", "Parse", "(", "proto", "+", "\"", "\"", "+", "s", ")", "\n", "...
// Check that a url is valid and has only a domain and is not an ip. // No port, path, protocol, user, query, or any other junk is allowed.
[ "Check", "that", "a", "url", "is", "valid", "and", "has", "only", "a", "domain", "and", "is", "not", "an", "ip", ".", "No", "port", "path", "protocol", "user", "query", "or", "any", "other", "junk", "is", "allowed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/helpers.go#L115-L145
161,395
keybase/client
go/pvl/helpers.go
validateProtocol
func validateProtocol(s string, allowed []string) (string, bool) { canons := map[string]string{ "http": "http", "https": "https", "dns": "dns", "http:": "http", "https:": "https", "dns:": "dns", "http://": "http", "https://": "https", "dns://": "dns", } canon, ok := canons[s] if ok { return canon, stringsContains(allowed, canon) } return canon, false }
go
func validateProtocol(s string, allowed []string) (string, bool) { canons := map[string]string{ "http": "http", "https": "https", "dns": "dns", "http:": "http", "https:": "https", "dns:": "dns", "http://": "http", "https://": "https", "dns://": "dns", } canon, ok := canons[s] if ok { return canon, stringsContains(allowed, canon) } return canon, false }
[ "func", "validateProtocol", "(", "s", "string", ",", "allowed", "[", "]", "string", ")", "(", "string", ",", "bool", ")", "{", "canons", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "\"", "\"", ",", "\"", "\"", ":", "\"", "\""...
// validateProtocol takes a protocol and returns the canonicalized form and whether it is valid.
[ "validateProtocol", "takes", "a", "protocol", "and", "returns", "the", "canonicalized", "form", "and", "whether", "it", "is", "valid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/helpers.go#L148-L166
161,396
keybase/client
go/engine/puk_upgrade.go
NewPerUserKeyUpgrade
func NewPerUserKeyUpgrade(g *libkb.GlobalContext, args *PerUserKeyUpgradeArgs) *PerUserKeyUpgrade { return &PerUserKeyUpgrade{ args: args, Contextified: libkb.NewContextified(g), } }
go
func NewPerUserKeyUpgrade(g *libkb.GlobalContext, args *PerUserKeyUpgradeArgs) *PerUserKeyUpgrade { return &PerUserKeyUpgrade{ args: args, Contextified: libkb.NewContextified(g), } }
[ "func", "NewPerUserKeyUpgrade", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "args", "*", "PerUserKeyUpgradeArgs", ")", "*", "PerUserKeyUpgrade", "{", "return", "&", "PerUserKeyUpgrade", "{", "args", ":", "args", ",", "Contextified", ":", "libkb", ".", "...
// NewPerUserKeyUpgrade creates a PerUserKeyUpgrade engine.
[ "NewPerUserKeyUpgrade", "creates", "a", "PerUserKeyUpgrade", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/puk_upgrade.go#L25-L30
161,397
keybase/client
go/libkb/active_device.go
NewProvisionalActiveDevice
func NewProvisionalActiveDevice(m MetaContext, uv keybase1.UserVersion, d keybase1.DeviceID, sigKey GenericKey, encKey GenericKey, deviceName string) *ActiveDevice { return &ActiveDevice{ uv: uv, deviceID: d, deviceName: deviceName, signingKey: sigKey, encryptionKey: encKey, nistFactory: NewNISTFactory(m.G(), uv.Uid, d, sigKey), secretSyncer: NewSecretSyncer(m.G()), } }
go
func NewProvisionalActiveDevice(m MetaContext, uv keybase1.UserVersion, d keybase1.DeviceID, sigKey GenericKey, encKey GenericKey, deviceName string) *ActiveDevice { return &ActiveDevice{ uv: uv, deviceID: d, deviceName: deviceName, signingKey: sigKey, encryptionKey: encKey, nistFactory: NewNISTFactory(m.G(), uv.Uid, d, sigKey), secretSyncer: NewSecretSyncer(m.G()), } }
[ "func", "NewProvisionalActiveDevice", "(", "m", "MetaContext", ",", "uv", "keybase1", ".", "UserVersion", ",", "d", "keybase1", ".", "DeviceID", ",", "sigKey", "GenericKey", ",", "encKey", "GenericKey", ",", "deviceName", "string", ")", "*", "ActiveDevice", "{",...
// NewProvisionalActiveDevice creates an ActiveDevice that is "provisional", in // that it should not be considered the global ActiveDevice. Instead, it should // reside in thread-local context, and can be weaved through the login // machinery without trampling the actual global ActiveDevice.
[ "NewProvisionalActiveDevice", "creates", "an", "ActiveDevice", "that", "is", "provisional", "in", "that", "it", "should", "not", "be", "considered", "the", "global", "ActiveDevice", ".", "Instead", "it", "should", "reside", "in", "thread", "-", "local", "context",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L51-L61
161,398
keybase/client
go/libkb/active_device.go
Copy
func (a *ActiveDevice) Copy(m MetaContext, src *ActiveDevice) error { // Take a consistent snapshot of the src device. Be careful not to hold // locks on both devices at once. src.Lock() uv := src.uv deviceID := src.deviceID sigKey := src.signingKey encKey := src.encryptionKey name := src.deviceName ctime := src.deviceCtime src.Unlock() return a.Set(m, uv, deviceID, sigKey, encKey, name, ctime) }
go
func (a *ActiveDevice) Copy(m MetaContext, src *ActiveDevice) error { // Take a consistent snapshot of the src device. Be careful not to hold // locks on both devices at once. src.Lock() uv := src.uv deviceID := src.deviceID sigKey := src.signingKey encKey := src.encryptionKey name := src.deviceName ctime := src.deviceCtime src.Unlock() return a.Set(m, uv, deviceID, sigKey, encKey, name, ctime) }
[ "func", "(", "a", "*", "ActiveDevice", ")", "Copy", "(", "m", "MetaContext", ",", "src", "*", "ActiveDevice", ")", "error", "{", "// Take a consistent snapshot of the src device. Be careful not to hold", "// locks on both devices at once.", "src", ".", "Lock", "(", ")",...
// Copy ActiveDevice info from the given ActiveDevice.
[ "Copy", "ActiveDevice", "info", "from", "the", "given", "ActiveDevice", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L94-L108
161,399
keybase/client
go/libkb/active_device.go
Set
func (a *ActiveDevice) Set(m MetaContext, uv keybase1.UserVersion, deviceID keybase1.DeviceID, sigKey, encKey GenericKey, deviceName string, deviceCtime keybase1.Time) error { a.Lock() defer a.Unlock() if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil { return err } a.signingKey = sigKey a.encryptionKey = encKey a.deviceName = deviceName a.deviceCtime = deviceCtime a.nistFactory = NewNISTFactory(m.G(), uv.Uid, deviceID, sigKey) a.secretSyncer = NewSecretSyncer(m.G()) return nil }
go
func (a *ActiveDevice) Set(m MetaContext, uv keybase1.UserVersion, deviceID keybase1.DeviceID, sigKey, encKey GenericKey, deviceName string, deviceCtime keybase1.Time) error { a.Lock() defer a.Unlock() if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil { return err } a.signingKey = sigKey a.encryptionKey = encKey a.deviceName = deviceName a.deviceCtime = deviceCtime a.nistFactory = NewNISTFactory(m.G(), uv.Uid, deviceID, sigKey) a.secretSyncer = NewSecretSyncer(m.G()) return nil }
[ "func", "(", "a", "*", "ActiveDevice", ")", "Set", "(", "m", "MetaContext", ",", "uv", "keybase1", ".", "UserVersion", ",", "deviceID", "keybase1", ".", "DeviceID", ",", "sigKey", ",", "encKey", "GenericKey", ",", "deviceName", "string", ",", "deviceCtime", ...
// Set acquires the write lock and sets all the fields in ActiveDevice. // The acct parameter is not used for anything except to help ensure // that this is called from inside a LoginState account request.
[ "Set", "acquires", "the", "write", "lock", "and", "sets", "all", "the", "fields", "in", "ActiveDevice", ".", "The", "acct", "parameter", "is", "not", "used", "for", "anything", "except", "to", "help", "ensure", "that", "this", "is", "called", "from", "insi...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L122-L139