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
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
161,400 | keybase/client | go/libkb/active_device.go | setSigningKey | func (a *ActiveDevice) setSigningKey(g *GlobalContext, uv keybase1.UserVersion, deviceID keybase1.DeviceID,
sigKey GenericKey, deviceName string) error {
a.Lock()
defer a.Unlock()
if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {
return err
}
a.signingKey = sigKey
if len(deviceName) > 0 {
a.deviceName = deviceName
}
a.nistFactory = NewNISTFactory(g, uv.Uid, deviceID, sigKey)
return nil
} | go | func (a *ActiveDevice) setSigningKey(g *GlobalContext, uv keybase1.UserVersion, deviceID keybase1.DeviceID,
sigKey GenericKey, deviceName string) error {
a.Lock()
defer a.Unlock()
if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {
return err
}
a.signingKey = sigKey
if len(deviceName) > 0 {
a.deviceName = deviceName
}
a.nistFactory = NewNISTFactory(g, uv.Uid, deviceID, sigKey)
return nil
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"setSigningKey",
"(",
"g",
"*",
"GlobalContext",
",",
"uv",
"keybase1",
".",
"UserVersion",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
",",
"sigKey",
"GenericKey",
",",
"deviceName",
"string",
")",
"error",
"{",
"a",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
":=",
"a",
".",
"internalUpdateUserVersionDeviceID",
"(",
"uv",
",",
"deviceID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"a",
".",
"signingKey",
"=",
"sigKey",
"\n",
"if",
"len",
"(",
"deviceName",
")",
">",
"0",
"{",
"a",
".",
"deviceName",
"=",
"deviceName",
"\n",
"}",
"\n",
"a",
".",
"nistFactory",
"=",
"NewNISTFactory",
"(",
"g",
",",
"uv",
".",
"Uid",
",",
"deviceID",
",",
"sigKey",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // setSigningKey acquires the write lock and sets the signing key.
// The acct parameter is not used for anything except to help ensure
// that this is called from inside a LogingState account request. | [
"setSigningKey",
"acquires",
"the",
"write",
"lock",
"and",
"sets",
"the",
"signing",
"key",
".",
"The",
"acct",
"parameter",
"is",
"not",
"used",
"for",
"anything",
"except",
"to",
"help",
"ensure",
"that",
"this",
"is",
"called",
"from",
"inside",
"a",
"LogingState",
"account",
"request",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L144-L159 |
161,401 | keybase/client | go/libkb/active_device.go | setEncryptionKey | func (a *ActiveDevice) setEncryptionKey(uv keybase1.UserVersion, deviceID keybase1.DeviceID, encKey GenericKey) error {
a.Lock()
defer a.Unlock()
if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {
return err
}
a.encryptionKey = encKey
return nil
} | go | func (a *ActiveDevice) setEncryptionKey(uv keybase1.UserVersion, deviceID keybase1.DeviceID, encKey GenericKey) error {
a.Lock()
defer a.Unlock()
if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {
return err
}
a.encryptionKey = encKey
return nil
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"setEncryptionKey",
"(",
"uv",
"keybase1",
".",
"UserVersion",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
",",
"encKey",
"GenericKey",
")",
"error",
"{",
"a",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
":=",
"a",
".",
"internalUpdateUserVersionDeviceID",
"(",
"uv",
",",
"deviceID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"a",
".",
"encryptionKey",
"=",
"encKey",
"\n",
"return",
"nil",
"\n",
"}"
] | // setEncryptionKey acquires the write lock and sets the encryption key.
// The acct parameter is not used for anything except to help ensure
// that this is called from inside a LogingState account request. | [
"setEncryptionKey",
"acquires",
"the",
"write",
"lock",
"and",
"sets",
"the",
"encryption",
"key",
".",
"The",
"acct",
"parameter",
"is",
"not",
"used",
"for",
"anything",
"except",
"to",
"help",
"ensure",
"that",
"this",
"is",
"called",
"from",
"inside",
"a",
"LogingState",
"account",
"request",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L164-L174 |
161,402 | keybase/client | go/libkb/active_device.go | setDeviceName | func (a *ActiveDevice) setDeviceName(uv keybase1.UserVersion, deviceID keybase1.DeviceID, deviceName string) error {
a.Lock()
defer a.Unlock()
if strings.TrimSpace(deviceName) == "" {
return errors.New("no device name specified")
}
if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {
return err
}
a.deviceName = deviceName
return nil
} | go | func (a *ActiveDevice) setDeviceName(uv keybase1.UserVersion, deviceID keybase1.DeviceID, deviceName string) error {
a.Lock()
defer a.Unlock()
if strings.TrimSpace(deviceName) == "" {
return errors.New("no device name specified")
}
if err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {
return err
}
a.deviceName = deviceName
return nil
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"setDeviceName",
"(",
"uv",
"keybase1",
".",
"UserVersion",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
",",
"deviceName",
"string",
")",
"error",
"{",
"a",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"strings",
".",
"TrimSpace",
"(",
"deviceName",
")",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"a",
".",
"internalUpdateUserVersionDeviceID",
"(",
"uv",
",",
"deviceID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"a",
".",
"deviceName",
"=",
"deviceName",
"\n",
"return",
"nil",
"\n",
"}"
] | // setDeviceName acquires the write lock and sets the device name.
// The acct parameter is not used for anything except to help ensure
// that this is called from inside a LoginState account request. | [
"setDeviceName",
"acquires",
"the",
"write",
"lock",
"and",
"sets",
"the",
"device",
"name",
".",
"The",
"acct",
"parameter",
"is",
"not",
"used",
"for",
"anything",
"except",
"to",
"help",
"ensure",
"that",
"this",
"is",
"called",
"from",
"inside",
"a",
"LoginState",
"account",
"request",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L179-L193 |
161,403 | keybase/client | go/libkb/active_device.go | internalUpdateUserVersionDeviceID | func (a *ActiveDevice) internalUpdateUserVersionDeviceID(uv keybase1.UserVersion, deviceID keybase1.DeviceID) error {
if uv.IsNil() {
return errors.New("ActiveDevice.set with nil uid")
}
if deviceID.IsNil() {
return errors.New("ActiveDevice.set with nil deviceID")
}
if a.uv.IsNil() && a.deviceID.IsNil() {
a.uv = uv
a.deviceID = deviceID
} else if !a.uv.Eq(uv) {
return errors.New("ActiveDevice.set uid mismatch")
} else if !a.deviceID.Eq(deviceID) {
return errors.New("ActiveDevice.set deviceID mismatch")
}
return nil
} | go | func (a *ActiveDevice) internalUpdateUserVersionDeviceID(uv keybase1.UserVersion, deviceID keybase1.DeviceID) error {
if uv.IsNil() {
return errors.New("ActiveDevice.set with nil uid")
}
if deviceID.IsNil() {
return errors.New("ActiveDevice.set with nil deviceID")
}
if a.uv.IsNil() && a.deviceID.IsNil() {
a.uv = uv
a.deviceID = deviceID
} else if !a.uv.Eq(uv) {
return errors.New("ActiveDevice.set uid mismatch")
} else if !a.deviceID.Eq(deviceID) {
return errors.New("ActiveDevice.set deviceID mismatch")
}
return nil
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"internalUpdateUserVersionDeviceID",
"(",
"uv",
"keybase1",
".",
"UserVersion",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
")",
"error",
"{",
"if",
"uv",
".",
"IsNil",
"(",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"deviceID",
".",
"IsNil",
"(",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"a",
".",
"uv",
".",
"IsNil",
"(",
")",
"&&",
"a",
".",
"deviceID",
".",
"IsNil",
"(",
")",
"{",
"a",
".",
"uv",
"=",
"uv",
"\n",
"a",
".",
"deviceID",
"=",
"deviceID",
"\n",
"}",
"else",
"if",
"!",
"a",
".",
"uv",
".",
"Eq",
"(",
"uv",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"!",
"a",
".",
"deviceID",
".",
"Eq",
"(",
"deviceID",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // should only called by the functions in this type, with the write lock. | [
"should",
"only",
"called",
"by",
"the",
"functions",
"in",
"this",
"type",
"with",
"the",
"write",
"lock",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L196-L215 |
161,404 | keybase/client | go/libkb/active_device.go | clear | func (a *ActiveDevice) clear() error {
a.Lock()
defer a.Unlock()
a.uv = keybase1.UserVersion{}
a.deviceID = ""
a.signingKey = nil
a.encryptionKey = nil
a.nistFactory = nil
a.passphrase = nil
a.provisioningKey = nil
a.secretPromptCancelTimer.Reset()
return nil
} | go | func (a *ActiveDevice) clear() error {
a.Lock()
defer a.Unlock()
a.uv = keybase1.UserVersion{}
a.deviceID = ""
a.signingKey = nil
a.encryptionKey = nil
a.nistFactory = nil
a.passphrase = nil
a.provisioningKey = nil
a.secretPromptCancelTimer.Reset()
return nil
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"clear",
"(",
")",
"error",
"{",
"a",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"Unlock",
"(",
")",
"\n\n",
"a",
".",
"uv",
"=",
"keybase1",
".",
"UserVersion",
"{",
"}",
"\n",
"a",
".",
"deviceID",
"=",
"\"",
"\"",
"\n",
"a",
".",
"signingKey",
"=",
"nil",
"\n",
"a",
".",
"encryptionKey",
"=",
"nil",
"\n",
"a",
".",
"nistFactory",
"=",
"nil",
"\n",
"a",
".",
"passphrase",
"=",
"nil",
"\n",
"a",
".",
"provisioningKey",
"=",
"nil",
"\n",
"a",
".",
"secretPromptCancelTimer",
".",
"Reset",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Clear acquires the write lock and resets all the fields to zero values. | [
"Clear",
"acquires",
"the",
"write",
"lock",
"and",
"resets",
"all",
"the",
"fields",
"to",
"zero",
"values",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L222-L236 |
161,405 | keybase/client | go/libkb/active_device.go | UID | func (a *ActiveDevice) UID() keybase1.UID {
a.RLock()
defer a.RUnlock()
return a.uv.Uid
} | go | func (a *ActiveDevice) UID() keybase1.UID {
a.RLock()
defer a.RUnlock()
return a.uv.Uid
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"UID",
"(",
")",
"keybase1",
".",
"UID",
"{",
"a",
".",
"RLock",
"(",
")",
"\n",
"defer",
"a",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"a",
".",
"uv",
".",
"Uid",
"\n",
"}"
] | // UID returns the user ID that was provided when the device keys were cached.
// Safe for use by concurrent goroutines. | [
"UID",
"returns",
"the",
"user",
"ID",
"that",
"was",
"provided",
"when",
"the",
"device",
"keys",
"were",
"cached",
".",
"Safe",
"for",
"use",
"by",
"concurrent",
"goroutines",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L246-L250 |
161,406 | keybase/client | go/libkb/active_device.go | Username | func (a *ActiveDevice) Username(m MetaContext) NormalizedUsername {
return m.G().Env.GetUsernameForUID(a.UID())
} | go | func (a *ActiveDevice) Username(m MetaContext) NormalizedUsername {
return m.G().Env.GetUsernameForUID(a.UID())
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"Username",
"(",
"m",
"MetaContext",
")",
"NormalizedUsername",
"{",
"return",
"m",
".",
"G",
"(",
")",
".",
"Env",
".",
"GetUsernameForUID",
"(",
"a",
".",
"UID",
"(",
")",
")",
"\n",
"}"
] | // Username tries to get the active user's username by looking into the current
// environment and mapping an UID to a username based on our config file. It
// won't work halfway through a provisioning. | [
"Username",
"tries",
"to",
"get",
"the",
"active",
"user",
"s",
"username",
"by",
"looking",
"into",
"the",
"current",
"environment",
"and",
"mapping",
"an",
"UID",
"to",
"a",
"username",
"based",
"on",
"our",
"config",
"file",
".",
"It",
"won",
"t",
"work",
"halfway",
"through",
"a",
"provisioning",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L261-L263 |
161,407 | keybase/client | go/libkb/active_device.go | DeviceID | func (a *ActiveDevice) DeviceID() keybase1.DeviceID {
a.RLock()
defer a.RUnlock()
return a.deviceID
} | go | func (a *ActiveDevice) DeviceID() keybase1.DeviceID {
a.RLock()
defer a.RUnlock()
return a.deviceID
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"DeviceID",
"(",
")",
"keybase1",
".",
"DeviceID",
"{",
"a",
".",
"RLock",
"(",
")",
"\n",
"defer",
"a",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"a",
".",
"deviceID",
"\n",
"}"
] | // DeviceID returns the device ID that was provided when the device keys were
// cached. Safe for use by concurrent goroutines. | [
"DeviceID",
"returns",
"the",
"device",
"ID",
"that",
"was",
"provided",
"when",
"the",
"device",
"keys",
"were",
"cached",
".",
"Safe",
"for",
"use",
"by",
"concurrent",
"goroutines",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L267-L271 |
161,408 | keybase/client | go/libkb/active_device.go | SigningKey | func (a *ActiveDevice) SigningKey() (GenericKey, error) {
a.RLock()
defer a.RUnlock()
if a.signingKey == nil {
return nil, NotFoundError{
Msg: "Not found: device signing key",
}
}
return a.signingKey, nil
} | go | func (a *ActiveDevice) SigningKey() (GenericKey, error) {
a.RLock()
defer a.RUnlock()
if a.signingKey == nil {
return nil, NotFoundError{
Msg: "Not found: device signing key",
}
}
return a.signingKey, nil
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"SigningKey",
"(",
")",
"(",
"GenericKey",
",",
"error",
")",
"{",
"a",
".",
"RLock",
"(",
")",
"\n",
"defer",
"a",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"a",
".",
"signingKey",
"==",
"nil",
"{",
"return",
"nil",
",",
"NotFoundError",
"{",
"Msg",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n",
"return",
"a",
".",
"signingKey",
",",
"nil",
"\n",
"}"
] | // SigningKey returns the signing key for the active device.
// Safe for use by concurrent goroutines. | [
"SigningKey",
"returns",
"the",
"signing",
"key",
"for",
"the",
"active",
"device",
".",
"Safe",
"for",
"use",
"by",
"concurrent",
"goroutines",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L294-L303 |
161,409 | keybase/client | go/libkb/active_device.go | EncryptionKey | func (a *ActiveDevice) EncryptionKey() (GenericKey, error) {
a.RLock()
defer a.RUnlock()
if a.encryptionKey == nil {
return nil, NotFoundError{
Msg: "Not found: device encryption key",
}
}
return a.encryptionKey, nil
} | go | func (a *ActiveDevice) EncryptionKey() (GenericKey, error) {
a.RLock()
defer a.RUnlock()
if a.encryptionKey == nil {
return nil, NotFoundError{
Msg: "Not found: device encryption key",
}
}
return a.encryptionKey, nil
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"EncryptionKey",
"(",
")",
"(",
"GenericKey",
",",
"error",
")",
"{",
"a",
".",
"RLock",
"(",
")",
"\n",
"defer",
"a",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"a",
".",
"encryptionKey",
"==",
"nil",
"{",
"return",
"nil",
",",
"NotFoundError",
"{",
"Msg",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n",
"return",
"a",
".",
"encryptionKey",
",",
"nil",
"\n",
"}"
] | // EncryptionKey returns the encryption key for the active device.
// Safe for use by concurrent goroutines. | [
"EncryptionKey",
"returns",
"the",
"encryption",
"key",
"for",
"the",
"active",
"device",
".",
"Safe",
"for",
"use",
"by",
"concurrent",
"goroutines",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L307-L316 |
161,410 | keybase/client | go/libkb/active_device.go | KeyByType | func (a *ActiveDevice) KeyByType(t SecretKeyType) (GenericKey, error) {
switch t {
case DeviceSigningKeyType:
return a.SigningKey()
case DeviceEncryptionKeyType:
return a.EncryptionKey()
default:
return nil, fmt.Errorf("Invalid type %v", t)
}
} | go | func (a *ActiveDevice) KeyByType(t SecretKeyType) (GenericKey, error) {
switch t {
case DeviceSigningKeyType:
return a.SigningKey()
case DeviceEncryptionKeyType:
return a.EncryptionKey()
default:
return nil, fmt.Errorf("Invalid type %v", t)
}
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"KeyByType",
"(",
"t",
"SecretKeyType",
")",
"(",
"GenericKey",
",",
"error",
")",
"{",
"switch",
"t",
"{",
"case",
"DeviceSigningKeyType",
":",
"return",
"a",
".",
"SigningKey",
"(",
")",
"\n",
"case",
"DeviceEncryptionKeyType",
":",
"return",
"a",
".",
"EncryptionKey",
"(",
")",
"\n",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"t",
")",
"\n",
"}",
"\n",
"}"
] | // KeyByType returns a cached key based on SecretKeyType.
// Safe for use by concurrent goroutines. | [
"KeyByType",
"returns",
"a",
"cached",
"key",
"based",
"on",
"SecretKeyType",
".",
"Safe",
"for",
"use",
"by",
"concurrent",
"goroutines",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L335-L344 |
161,411 | keybase/client | go/libkb/active_device.go | AllFields | func (a *ActiveDevice) AllFields() (uv keybase1.UserVersion, deviceID keybase1.DeviceID, deviceName string, sigKey GenericKey, encKey GenericKey) {
a.RLock()
defer a.RUnlock()
return a.uv, a.deviceID, a.deviceName, a.signingKey, a.encryptionKey
} | go | func (a *ActiveDevice) AllFields() (uv keybase1.UserVersion, deviceID keybase1.DeviceID, deviceName string, sigKey GenericKey, encKey GenericKey) {
a.RLock()
defer a.RUnlock()
return a.uv, a.deviceID, a.deviceName, a.signingKey, a.encryptionKey
} | [
"func",
"(",
"a",
"*",
"ActiveDevice",
")",
"AllFields",
"(",
")",
"(",
"uv",
"keybase1",
".",
"UserVersion",
",",
"deviceID",
"keybase1",
".",
"DeviceID",
",",
"deviceName",
"string",
",",
"sigKey",
"GenericKey",
",",
"encKey",
"GenericKey",
")",
"{",
"a",
".",
"RLock",
"(",
")",
"\n",
"defer",
"a",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"a",
".",
"uv",
",",
"a",
".",
"deviceID",
",",
"a",
".",
"deviceName",
",",
"a",
".",
"signingKey",
",",
"a",
".",
"encryptionKey",
"\n",
"}"
] | // AllFields returns all the ActiveDevice fields via one lock for consistency.
// Safe for use by concurrent goroutines. | [
"AllFields",
"returns",
"all",
"the",
"ActiveDevice",
"fields",
"via",
"one",
"lock",
"for",
"consistency",
".",
"Safe",
"for",
"use",
"by",
"concurrent",
"goroutines",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/active_device.go#L348-L353 |
161,412 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | DoRUnlockedIfPossible | func (bl *blockLock) DoRUnlockedIfPossible(
lState *kbfssync.LockState, f func(*kbfssync.LockState)) {
if !bl.locked {
bl.RUnlock(lState)
defer bl.RLock(lState)
}
f(lState)
} | go | func (bl *blockLock) DoRUnlockedIfPossible(
lState *kbfssync.LockState, f func(*kbfssync.LockState)) {
if !bl.locked {
bl.RUnlock(lState)
defer bl.RLock(lState)
}
f(lState)
} | [
"func",
"(",
"bl",
"*",
"blockLock",
")",
"DoRUnlockedIfPossible",
"(",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"f",
"func",
"(",
"*",
"kbfssync",
".",
"LockState",
")",
")",
"{",
"if",
"!",
"bl",
".",
"locked",
"{",
"bl",
".",
"RUnlock",
"(",
"lState",
")",
"\n",
"defer",
"bl",
".",
"RLock",
"(",
"lState",
")",
"\n",
"}",
"\n\n",
"f",
"(",
"lState",
")",
"\n",
"}"
] | // DoRUnlockedIfPossible must be called when r- or w-locked. If
// r-locked, r-unlocks, runs the given function, and r-locks after
// it's done. Otherwise, just runs the given function. | [
"DoRUnlockedIfPossible",
"must",
"be",
"called",
"when",
"r",
"-",
"or",
"w",
"-",
"locked",
".",
"If",
"r",
"-",
"locked",
"r",
"-",
"unlocks",
"runs",
"the",
"given",
"function",
"and",
"r",
"-",
"locks",
"after",
"it",
"s",
"done",
".",
"Otherwise",
"just",
"runs",
"the",
"given",
"function",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L171-L179 |
161,413 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | markForReIdentifyIfNeeded | func (fbo *folderBranchOps) markForReIdentifyIfNeeded(now time.Time, maxValid time.Duration) {
fbo.identifyLock.Lock()
defer fbo.identifyLock.Unlock()
if fbo.identifyDone && (now.Before(fbo.identifyTime) || fbo.identifyTime.Add(maxValid).Before(now)) {
fbo.log.CDebugf(nil, "Expiring identify from %v", fbo.identifyTime)
fbo.identifyDone = false
}
} | go | func (fbo *folderBranchOps) markForReIdentifyIfNeeded(now time.Time, maxValid time.Duration) {
fbo.identifyLock.Lock()
defer fbo.identifyLock.Unlock()
if fbo.identifyDone && (now.Before(fbo.identifyTime) || fbo.identifyTime.Add(maxValid).Before(now)) {
fbo.log.CDebugf(nil, "Expiring identify from %v", fbo.identifyTime)
fbo.identifyDone = false
}
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"markForReIdentifyIfNeeded",
"(",
"now",
"time",
".",
"Time",
",",
"maxValid",
"time",
".",
"Duration",
")",
"{",
"fbo",
".",
"identifyLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fbo",
".",
"identifyLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"fbo",
".",
"identifyDone",
"&&",
"(",
"now",
".",
"Before",
"(",
"fbo",
".",
"identifyTime",
")",
"||",
"fbo",
".",
"identifyTime",
".",
"Add",
"(",
"maxValid",
")",
".",
"Before",
"(",
"now",
")",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"nil",
",",
"\"",
"\"",
",",
"fbo",
".",
"identifyTime",
")",
"\n",
"fbo",
".",
"identifyDone",
"=",
"false",
"\n",
"}",
"\n",
"}"
] | // markForReIdentifyIfNeeded checks whether this tlf is identified and mark
// it for lazy reidentification if it exceeds time limits. | [
"markForReIdentifyIfNeeded",
"checks",
"whether",
"this",
"tlf",
"is",
"identified",
"and",
"mark",
"it",
"for",
"lazy",
"reidentification",
"if",
"it",
"exceeds",
"time",
"limits",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L518-L525 |
161,414 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | Shutdown | func (fbo *folderBranchOps) Shutdown(ctx context.Context) error {
if fbo.config.CheckStateOnShutdown() {
lState := makeFBOLockState()
if fbo.blocks.GetState(lState) == dirtyState {
fbo.log.CDebugf(ctx, "Skipping state-checking due to dirty state")
} else if fbo.isUnmerged(lState) {
fbo.log.CDebugf(ctx, "Skipping state-checking due to being staged")
} else {
// Make sure we're up to date first
if err := fbo.SyncFromServer(ctx,
fbo.folderBranch, nil); err != nil {
return err
}
// Check the state for consistency before shutting down.
sc := NewStateChecker(fbo.config)
if err := sc.CheckMergedState(ctx, fbo.id()); err != nil {
return err
}
}
}
if err := fbo.fbm.waitForArchives(ctx); err != nil {
return err
}
close(fbo.shutdownChan)
fbo.cr.Shutdown()
fbo.fbm.shutdown()
fbo.rekeyFSM.Shutdown()
// Wait for all the goroutines to finish, so that we don't have any races
// with logging during test reporting.
fbo.doneWg.Wait()
return nil
} | go | func (fbo *folderBranchOps) Shutdown(ctx context.Context) error {
if fbo.config.CheckStateOnShutdown() {
lState := makeFBOLockState()
if fbo.blocks.GetState(lState) == dirtyState {
fbo.log.CDebugf(ctx, "Skipping state-checking due to dirty state")
} else if fbo.isUnmerged(lState) {
fbo.log.CDebugf(ctx, "Skipping state-checking due to being staged")
} else {
// Make sure we're up to date first
if err := fbo.SyncFromServer(ctx,
fbo.folderBranch, nil); err != nil {
return err
}
// Check the state for consistency before shutting down.
sc := NewStateChecker(fbo.config)
if err := sc.CheckMergedState(ctx, fbo.id()); err != nil {
return err
}
}
}
if err := fbo.fbm.waitForArchives(ctx); err != nil {
return err
}
close(fbo.shutdownChan)
fbo.cr.Shutdown()
fbo.fbm.shutdown()
fbo.rekeyFSM.Shutdown()
// Wait for all the goroutines to finish, so that we don't have any races
// with logging during test reporting.
fbo.doneWg.Wait()
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"fbo",
".",
"config",
".",
"CheckStateOnShutdown",
"(",
")",
"{",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n\n",
"if",
"fbo",
".",
"blocks",
".",
"GetState",
"(",
"lState",
")",
"==",
"dirtyState",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"fbo",
".",
"isUnmerged",
"(",
"lState",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"// Make sure we're up to date first",
"if",
"err",
":=",
"fbo",
".",
"SyncFromServer",
"(",
"ctx",
",",
"fbo",
".",
"folderBranch",
",",
"nil",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Check the state for consistency before shutting down.",
"sc",
":=",
"NewStateChecker",
"(",
"fbo",
".",
"config",
")",
"\n",
"if",
"err",
":=",
"sc",
".",
"CheckMergedState",
"(",
"ctx",
",",
"fbo",
".",
"id",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"fbo",
".",
"fbm",
".",
"waitForArchives",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"close",
"(",
"fbo",
".",
"shutdownChan",
")",
"\n",
"fbo",
".",
"cr",
".",
"Shutdown",
"(",
")",
"\n",
"fbo",
".",
"fbm",
".",
"shutdown",
"(",
")",
"\n",
"fbo",
".",
"rekeyFSM",
".",
"Shutdown",
"(",
")",
"\n",
"// Wait for all the goroutines to finish, so that we don't have any races",
"// with logging during test reporting.",
"fbo",
".",
"doneWg",
".",
"Wait",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Shutdown safely shuts down any background goroutines that may have
// been launched by folderBranchOps. | [
"Shutdown",
"safely",
"shuts",
"down",
"any",
"background",
"goroutines",
"that",
"may",
"have",
"been",
"launched",
"by",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L529-L564 |
161,415 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | isUnmerged | func (fbo *folderBranchOps) isUnmerged(lState *kbfssync.LockState) bool {
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.unmergedBID != kbfsmd.NullBranchID
} | go | func (fbo *folderBranchOps) isUnmerged(lState *kbfssync.LockState) bool {
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.unmergedBID != kbfsmd.NullBranchID
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"isUnmerged",
"(",
"lState",
"*",
"kbfssync",
".",
"LockState",
")",
"bool",
"{",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"return",
"fbo",
".",
"unmergedBID",
"!=",
"kbfsmd",
".",
"NullBranchID",
"\n",
"}"
] | // isUnmerged should not be called if mdWriterLock is already taken. | [
"isUnmerged",
"should",
"not",
"be",
"called",
"if",
"mdWriterLock",
"is",
"already",
"taken",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L719-L723 |
161,416 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | clearConflictView | func (fbo *folderBranchOps) clearConflictView(ctx context.Context) (
err error) {
// TODO(KBFS-3990): show the cleared conflict view under a special path,
// so users can copy any unmerged files manually back into their synced
// view before nuking it.
fbo.log.CDebugf(ctx, "Clearing conflict view")
defer func() {
fbo.log.CDebugf(ctx, "Done with clearConflictView: %+v", err)
}()
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
journalEnabled := TLFJournalEnabled(fbo.config, fbo.id())
if journalEnabled {
err = fbo.unstageLocked(ctx, lState, moveJournalsAway)
} else {
err = fbo.unstageLocked(ctx, lState, doPruneBranches)
}
if err != nil {
return err
}
return fbo.cr.clearConflictRecords()
} | go | func (fbo *folderBranchOps) clearConflictView(ctx context.Context) (
err error) {
// TODO(KBFS-3990): show the cleared conflict view under a special path,
// so users can copy any unmerged files manually back into their synced
// view before nuking it.
fbo.log.CDebugf(ctx, "Clearing conflict view")
defer func() {
fbo.log.CDebugf(ctx, "Done with clearConflictView: %+v", err)
}()
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
journalEnabled := TLFJournalEnabled(fbo.config, fbo.id())
if journalEnabled {
err = fbo.unstageLocked(ctx, lState, moveJournalsAway)
} else {
err = fbo.unstageLocked(ctx, lState, doPruneBranches)
}
if err != nil {
return err
}
return fbo.cr.clearConflictRecords()
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"clearConflictView",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"// TODO(KBFS-3990): show the cleared conflict view under a special path,",
"// so users can copy any unmerged files manually back into their synced",
"// view before nuking it.",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n\n",
"journalEnabled",
":=",
"TLFJournalEnabled",
"(",
"fbo",
".",
"config",
",",
"fbo",
".",
"id",
"(",
")",
")",
"\n",
"if",
"journalEnabled",
"{",
"err",
"=",
"fbo",
".",
"unstageLocked",
"(",
"ctx",
",",
"lState",
",",
"moveJournalsAway",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"fbo",
".",
"unstageLocked",
"(",
"ctx",
",",
"lState",
",",
"doPruneBranches",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"fbo",
".",
"cr",
".",
"clearConflictRecords",
"(",
")",
"\n",
"}"
] | // clearConflictView tells the journal to move any pending writes elsewhere,
// resets the CR counter, and resets the FBO to have a synced view of the TLF. | [
"clearConflictView",
"tells",
"the",
"journal",
"to",
"move",
"any",
"pending",
"writes",
"elsewhere",
"resets",
"the",
"CR",
"counter",
"and",
"resets",
"the",
"FBO",
"to",
"have",
"a",
"synced",
"view",
"of",
"the",
"TLF",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L735-L760 |
161,417 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | getJournalPredecessorRevision | func (fbo *folderBranchOps) getJournalPredecessorRevision(ctx context.Context) (
kbfsmd.Revision, error) {
jManager, err := GetJournalManager(fbo.config)
if err != nil {
// Journaling is disabled entirely.
return kbfsmd.RevisionUninitialized, nil
}
jStatus, err := jManager.JournalStatus(fbo.id())
if err != nil {
// Journaling is disabled for this TLF, so use the local head.
// TODO: JournalStatus could return other errors (likely
// file/disk corruption) that indicate a real problem, so it
// might be nice to type those errors so we can distinguish
// them.
return kbfsmd.RevisionUninitialized, nil
}
if jStatus.BranchID != kbfsmd.NullBranchID.String() {
return kbfsmd.RevisionUninitialized, errNoMergedRevWhileStaged
}
if jStatus.RevisionStart == kbfsmd.RevisionUninitialized {
// The journal is empty, so the local head must be the most recent.
return kbfsmd.RevisionUninitialized, nil
} else if jStatus.RevisionStart == kbfsmd.RevisionInitial {
// Nothing has been flushed to the servers yet, so don't
// return anything.
return kbfsmd.RevisionUninitialized, errNoFlushedRevisions
}
return jStatus.RevisionStart - 1, nil
} | go | func (fbo *folderBranchOps) getJournalPredecessorRevision(ctx context.Context) (
kbfsmd.Revision, error) {
jManager, err := GetJournalManager(fbo.config)
if err != nil {
// Journaling is disabled entirely.
return kbfsmd.RevisionUninitialized, nil
}
jStatus, err := jManager.JournalStatus(fbo.id())
if err != nil {
// Journaling is disabled for this TLF, so use the local head.
// TODO: JournalStatus could return other errors (likely
// file/disk corruption) that indicate a real problem, so it
// might be nice to type those errors so we can distinguish
// them.
return kbfsmd.RevisionUninitialized, nil
}
if jStatus.BranchID != kbfsmd.NullBranchID.String() {
return kbfsmd.RevisionUninitialized, errNoMergedRevWhileStaged
}
if jStatus.RevisionStart == kbfsmd.RevisionUninitialized {
// The journal is empty, so the local head must be the most recent.
return kbfsmd.RevisionUninitialized, nil
} else if jStatus.RevisionStart == kbfsmd.RevisionInitial {
// Nothing has been flushed to the servers yet, so don't
// return anything.
return kbfsmd.RevisionUninitialized, errNoFlushedRevisions
}
return jStatus.RevisionStart - 1, nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"getJournalPredecessorRevision",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"kbfsmd",
".",
"Revision",
",",
"error",
")",
"{",
"jManager",
",",
"err",
":=",
"GetJournalManager",
"(",
"fbo",
".",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Journaling is disabled entirely.",
"return",
"kbfsmd",
".",
"RevisionUninitialized",
",",
"nil",
"\n",
"}",
"\n\n",
"jStatus",
",",
"err",
":=",
"jManager",
".",
"JournalStatus",
"(",
"fbo",
".",
"id",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Journaling is disabled for this TLF, so use the local head.",
"// TODO: JournalStatus could return other errors (likely",
"// file/disk corruption) that indicate a real problem, so it",
"// might be nice to type those errors so we can distinguish",
"// them.",
"return",
"kbfsmd",
".",
"RevisionUninitialized",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"jStatus",
".",
"BranchID",
"!=",
"kbfsmd",
".",
"NullBranchID",
".",
"String",
"(",
")",
"{",
"return",
"kbfsmd",
".",
"RevisionUninitialized",
",",
"errNoMergedRevWhileStaged",
"\n",
"}",
"\n\n",
"if",
"jStatus",
".",
"RevisionStart",
"==",
"kbfsmd",
".",
"RevisionUninitialized",
"{",
"// The journal is empty, so the local head must be the most recent.",
"return",
"kbfsmd",
".",
"RevisionUninitialized",
",",
"nil",
"\n",
"}",
"else",
"if",
"jStatus",
".",
"RevisionStart",
"==",
"kbfsmd",
".",
"RevisionInitial",
"{",
"// Nothing has been flushed to the servers yet, so don't",
"// return anything.",
"return",
"kbfsmd",
".",
"RevisionUninitialized",
",",
"errNoFlushedRevisions",
"\n",
"}",
"\n\n",
"return",
"jStatus",
".",
"RevisionStart",
"-",
"1",
",",
"nil",
"\n",
"}"
] | // getJournalPredecessorRevision returns the revision that precedes
// the current journal head if journaling enabled and there are
// unflushed MD updates; otherwise it returns
// kbfsmd.RevisionUninitialized. If there aren't any flushed MD
// revisions, it returns errNoFlushedRevisions. | [
"getJournalPredecessorRevision",
"returns",
"the",
"revision",
"that",
"precedes",
"the",
"current",
"journal",
"head",
"if",
"journaling",
"enabled",
"and",
"there",
"are",
"unflushed",
"MD",
"updates",
";",
"otherwise",
"it",
"returns",
"kbfsmd",
".",
"RevisionUninitialized",
".",
"If",
"there",
"aren",
"t",
"any",
"flushed",
"MD",
"revisions",
"it",
"returns",
"errNoFlushedRevisions",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L785-L817 |
161,418 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | validateHeadLocked | func (fbo *folderBranchOps) validateHeadLocked(
ctx context.Context, lState *kbfssync.LockState,
md ImmutableRootMetadata) error {
fbo.headLock.AssertLocked(lState)
// Validate fbo against fetched md and discard the fetched one.
if fbo.head.TlfID() != md.TlfID() {
fbo.log.CCriticalf(ctx, "Fake untrusted TLF encountered %v %v %v %v", fbo.head.TlfID(), md.TlfID(), fbo.head.mdID, md.mdID)
return kbfsmd.MDTlfIDMismatch{CurrID: fbo.head.TlfID(), NextID: md.TlfID()}
}
fbo.headStatus = headTrusted
return nil
} | go | func (fbo *folderBranchOps) validateHeadLocked(
ctx context.Context, lState *kbfssync.LockState,
md ImmutableRootMetadata) error {
fbo.headLock.AssertLocked(lState)
// Validate fbo against fetched md and discard the fetched one.
if fbo.head.TlfID() != md.TlfID() {
fbo.log.CCriticalf(ctx, "Fake untrusted TLF encountered %v %v %v %v", fbo.head.TlfID(), md.TlfID(), fbo.head.mdID, md.mdID)
return kbfsmd.MDTlfIDMismatch{CurrID: fbo.head.TlfID(), NextID: md.TlfID()}
}
fbo.headStatus = headTrusted
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"validateHeadLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"ImmutableRootMetadata",
")",
"error",
"{",
"fbo",
".",
"headLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n\n",
"// Validate fbo against fetched md and discard the fetched one.",
"if",
"fbo",
".",
"head",
".",
"TlfID",
"(",
")",
"!=",
"md",
".",
"TlfID",
"(",
")",
"{",
"fbo",
".",
"log",
".",
"CCriticalf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"fbo",
".",
"head",
".",
"TlfID",
"(",
")",
",",
"md",
".",
"TlfID",
"(",
")",
",",
"fbo",
".",
"head",
".",
"mdID",
",",
"md",
".",
"mdID",
")",
"\n",
"return",
"kbfsmd",
".",
"MDTlfIDMismatch",
"{",
"CurrID",
":",
"fbo",
".",
"head",
".",
"TlfID",
"(",
")",
",",
"NextID",
":",
"md",
".",
"TlfID",
"(",
")",
"}",
"\n",
"}",
"\n",
"fbo",
".",
"headStatus",
"=",
"headTrusted",
"\n",
"return",
"nil",
"\n",
"}"
] | // validateHeadLocked validates an untrusted head and sets it as trusted.
// see headTrustedState comment for more information. | [
"validateHeadLocked",
"validates",
"an",
"untrusted",
"head",
"and",
"sets",
"it",
"as",
"trusted",
".",
"see",
"headTrustedState",
"comment",
"for",
"more",
"information",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L821-L833 |
161,419 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | doPartialMarkAndSweep | func (fbo *folderBranchOps) doPartialMarkAndSweep(
ctx context.Context, syncConfig keybase1.FolderSyncConfig,
latestMerged ImmutableRootMetadata) (err error) {
startTime, timer := fbo.startOp(
ctx, "Starting partial mark-and-sweep at revision %d",
latestMerged.Revision())
defer func() {
fbo.endOp(
ctx, startTime, timer,
"Partial mark-and-sweep at revision %d done: %+v",
latestMerged.Revision(), err)
}()
if syncConfig.Mode != keybase1.FolderSyncMode_PARTIAL {
return errors.Errorf(
"Bad mode passed to partial unsync: %+v", syncConfig.Mode)
} else if len(syncConfig.Paths) == 0 {
return nil
}
rootNode, _, _, err := fbo.getRootNode(ctx)
if err != nil {
return err
}
tag := ctx.Value(CtxFBOIDKey).(string)
lState := makeFBOLockState()
cacheType := DiskBlockSyncCache
err = fbo.blocks.MarkNode(
ctx, lState, rootNode, latestMerged, tag, cacheType)
if err != nil {
return err
}
pathLoop:
for _, p := range syncConfig.Paths {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
fbo.vlog.CLogf(ctx, libkb.VLog1, "Marking %s", p)
// Mark the parent directories.
parentPath, syncedElem := stdpath.Split(p)
parents := strings.Split(strings.TrimSuffix(parentPath, "/"), "/")
currNode := rootNode
for _, parent := range parents {
if len(parent) == 0 {
continue
}
// TODO: parallelize the parent fetches and lookups.
currNode, _, err = fbo.Lookup(ctx, currNode, parent)
switch errors.Cause(err).(type) {
case idutil.NoSuchNameError:
fbo.vlog.CLogf(
ctx, libkb.VLog1, "Synced path %s doesn't exist yet", p)
continue pathLoop
case nil:
default:
return err
}
err = fbo.blocks.MarkNode(
ctx, lState, currNode, latestMerged, tag, cacheType)
if err != nil {
return err
}
}
// Now mark everything rooted at this path.
currNode, _, err = fbo.Lookup(ctx, currNode, syncedElem)
switch errors.Cause(err).(type) {
case idutil.NoSuchNameError:
fbo.vlog.CLogf(
ctx, libkb.VLog1, "Synced element %s doesn't exist yet", p)
continue pathLoop
case nil:
default:
return err
}
err = fbo.markRecursive(
ctx, lState, currNode, latestMerged, tag, cacheType)
if err != nil {
return err
}
}
return fbo.config.DiskBlockCache().DeleteUnmarked(
ctx, fbo.id(), tag, cacheType)
} | go | func (fbo *folderBranchOps) doPartialMarkAndSweep(
ctx context.Context, syncConfig keybase1.FolderSyncConfig,
latestMerged ImmutableRootMetadata) (err error) {
startTime, timer := fbo.startOp(
ctx, "Starting partial mark-and-sweep at revision %d",
latestMerged.Revision())
defer func() {
fbo.endOp(
ctx, startTime, timer,
"Partial mark-and-sweep at revision %d done: %+v",
latestMerged.Revision(), err)
}()
if syncConfig.Mode != keybase1.FolderSyncMode_PARTIAL {
return errors.Errorf(
"Bad mode passed to partial unsync: %+v", syncConfig.Mode)
} else if len(syncConfig.Paths) == 0 {
return nil
}
rootNode, _, _, err := fbo.getRootNode(ctx)
if err != nil {
return err
}
tag := ctx.Value(CtxFBOIDKey).(string)
lState := makeFBOLockState()
cacheType := DiskBlockSyncCache
err = fbo.blocks.MarkNode(
ctx, lState, rootNode, latestMerged, tag, cacheType)
if err != nil {
return err
}
pathLoop:
for _, p := range syncConfig.Paths {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
fbo.vlog.CLogf(ctx, libkb.VLog1, "Marking %s", p)
// Mark the parent directories.
parentPath, syncedElem := stdpath.Split(p)
parents := strings.Split(strings.TrimSuffix(parentPath, "/"), "/")
currNode := rootNode
for _, parent := range parents {
if len(parent) == 0 {
continue
}
// TODO: parallelize the parent fetches and lookups.
currNode, _, err = fbo.Lookup(ctx, currNode, parent)
switch errors.Cause(err).(type) {
case idutil.NoSuchNameError:
fbo.vlog.CLogf(
ctx, libkb.VLog1, "Synced path %s doesn't exist yet", p)
continue pathLoop
case nil:
default:
return err
}
err = fbo.blocks.MarkNode(
ctx, lState, currNode, latestMerged, tag, cacheType)
if err != nil {
return err
}
}
// Now mark everything rooted at this path.
currNode, _, err = fbo.Lookup(ctx, currNode, syncedElem)
switch errors.Cause(err).(type) {
case idutil.NoSuchNameError:
fbo.vlog.CLogf(
ctx, libkb.VLog1, "Synced element %s doesn't exist yet", p)
continue pathLoop
case nil:
default:
return err
}
err = fbo.markRecursive(
ctx, lState, currNode, latestMerged, tag, cacheType)
if err != nil {
return err
}
}
return fbo.config.DiskBlockCache().DeleteUnmarked(
ctx, fbo.id(), tag, cacheType)
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"doPartialMarkAndSweep",
"(",
"ctx",
"context",
".",
"Context",
",",
"syncConfig",
"keybase1",
".",
"FolderSyncConfig",
",",
"latestMerged",
"ImmutableRootMetadata",
")",
"(",
"err",
"error",
")",
"{",
"startTime",
",",
"timer",
":=",
"fbo",
".",
"startOp",
"(",
"ctx",
",",
"\"",
"\"",
",",
"latestMerged",
".",
"Revision",
"(",
")",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fbo",
".",
"endOp",
"(",
"ctx",
",",
"startTime",
",",
"timer",
",",
"\"",
"\"",
",",
"latestMerged",
".",
"Revision",
"(",
")",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"if",
"syncConfig",
".",
"Mode",
"!=",
"keybase1",
".",
"FolderSyncMode_PARTIAL",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"syncConfig",
".",
"Mode",
")",
"\n",
"}",
"else",
"if",
"len",
"(",
"syncConfig",
".",
"Paths",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"rootNode",
",",
"_",
",",
"_",
",",
"err",
":=",
"fbo",
".",
"getRootNode",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tag",
":=",
"ctx",
".",
"Value",
"(",
"CtxFBOIDKey",
")",
".",
"(",
"string",
")",
"\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"cacheType",
":=",
"DiskBlockSyncCache",
"\n",
"err",
"=",
"fbo",
".",
"blocks",
".",
"MarkNode",
"(",
"ctx",
",",
"lState",
",",
"rootNode",
",",
"latestMerged",
",",
"tag",
",",
"cacheType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"pathLoop",
":",
"for",
"_",
",",
"p",
":=",
"range",
"syncConfig",
".",
"Paths",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"default",
":",
"}",
"\n",
"fbo",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
",",
"p",
")",
"\n\n",
"// Mark the parent directories.",
"parentPath",
",",
"syncedElem",
":=",
"stdpath",
".",
"Split",
"(",
"p",
")",
"\n",
"parents",
":=",
"strings",
".",
"Split",
"(",
"strings",
".",
"TrimSuffix",
"(",
"parentPath",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
")",
"\n",
"currNode",
":=",
"rootNode",
"\n",
"for",
"_",
",",
"parent",
":=",
"range",
"parents",
"{",
"if",
"len",
"(",
"parent",
")",
"==",
"0",
"{",
"continue",
"\n",
"}",
"\n",
"// TODO: parallelize the parent fetches and lookups.",
"currNode",
",",
"_",
",",
"err",
"=",
"fbo",
".",
"Lookup",
"(",
"ctx",
",",
"currNode",
",",
"parent",
")",
"\n",
"switch",
"errors",
".",
"Cause",
"(",
"err",
")",
".",
"(",
"type",
")",
"{",
"case",
"idutil",
".",
"NoSuchNameError",
":",
"fbo",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
",",
"p",
")",
"\n",
"continue",
"pathLoop",
"\n",
"case",
"nil",
":",
"default",
":",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"fbo",
".",
"blocks",
".",
"MarkNode",
"(",
"ctx",
",",
"lState",
",",
"currNode",
",",
"latestMerged",
",",
"tag",
",",
"cacheType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Now mark everything rooted at this path.",
"currNode",
",",
"_",
",",
"err",
"=",
"fbo",
".",
"Lookup",
"(",
"ctx",
",",
"currNode",
",",
"syncedElem",
")",
"\n",
"switch",
"errors",
".",
"Cause",
"(",
"err",
")",
".",
"(",
"type",
")",
"{",
"case",
"idutil",
".",
"NoSuchNameError",
":",
"fbo",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
",",
"p",
")",
"\n",
"continue",
"pathLoop",
"\n",
"case",
"nil",
":",
"default",
":",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"fbo",
".",
"markRecursive",
"(",
"ctx",
",",
"lState",
",",
"currNode",
",",
"latestMerged",
",",
"tag",
",",
"cacheType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"fbo",
".",
"config",
".",
"DiskBlockCache",
"(",
")",
".",
"DeleteUnmarked",
"(",
"ctx",
",",
"fbo",
".",
"id",
"(",
")",
",",
"tag",
",",
"cacheType",
")",
"\n",
"}"
] | // doPartialMarkAndSweep runs a mark-and-sweep algorithm against all
// the currently-synced paths, to delete any blocks not reachable from
// one of these paths. | [
"doPartialMarkAndSweep",
"runs",
"a",
"mark",
"-",
"and",
"-",
"sweep",
"algorithm",
"against",
"all",
"the",
"currently",
"-",
"synced",
"paths",
"to",
"delete",
"any",
"blocks",
"not",
"reachable",
"from",
"one",
"of",
"these",
"paths",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L1256-L1346 |
161,420 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | setNewInitialHeadLocked | func (fbo *folderBranchOps) setNewInitialHeadLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head != (ImmutableRootMetadata{}) {
return errors.New("Unexpected non-nil head in setNewInitialHeadLocked")
}
if md.Revision() != kbfsmd.RevisionInitial {
return errors.Errorf("setNewInitialHeadLocked unexpectedly called with revision %d", md.Revision())
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
} | go | func (fbo *folderBranchOps) setNewInitialHeadLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head != (ImmutableRootMetadata{}) {
return errors.New("Unexpected non-nil head in setNewInitialHeadLocked")
}
if md.Revision() != kbfsmd.RevisionInitial {
return errors.Errorf("setNewInitialHeadLocked unexpectedly called with revision %d", md.Revision())
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"setNewInitialHeadLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"ImmutableRootMetadata",
")",
"error",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"if",
"fbo",
".",
"head",
"!=",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"md",
".",
"Revision",
"(",
")",
"!=",
"kbfsmd",
".",
"RevisionInitial",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"md",
".",
"Revision",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"fbo",
".",
"setHeadLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"headTrusted",
",",
"mdToCommitType",
"(",
"md",
")",
")",
"\n",
"}"
] | // setNewInitialHeadLocked is for when we're creating a brand-new TLF.
// This is trusted. | [
"setNewInitialHeadLocked",
"is",
"for",
"when",
"we",
"re",
"creating",
"a",
"brand",
"-",
"new",
"TLF",
".",
"This",
"is",
"trusted",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L1839-L1850 |
161,421 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | setInitialHeadTrustedLocked | func (fbo *folderBranchOps) setInitialHeadTrustedLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata,
ct mdCommitType) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head != (ImmutableRootMetadata{}) {
return errors.New("Unexpected non-nil head in setInitialHeadTrustedLocked")
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, ct)
} | go | func (fbo *folderBranchOps) setInitialHeadTrustedLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata,
ct mdCommitType) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head != (ImmutableRootMetadata{}) {
return errors.New("Unexpected non-nil head in setInitialHeadTrustedLocked")
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, ct)
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"setInitialHeadTrustedLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"ImmutableRootMetadata",
",",
"ct",
"mdCommitType",
")",
"error",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"if",
"fbo",
".",
"head",
"!=",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"fbo",
".",
"setHeadLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"headTrusted",
",",
"ct",
")",
"\n",
"}"
] | // setInitialHeadTrustedLocked is for when the given RootMetadata
// was fetched due to a user action, and will be checked against the
// TLF name. | [
"setInitialHeadTrustedLocked",
"is",
"for",
"when",
"the",
"given",
"RootMetadata",
"was",
"fetched",
"due",
"to",
"a",
"user",
"action",
"and",
"will",
"be",
"checked",
"against",
"the",
"TLF",
"name",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L1855-L1864 |
161,422 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | setHeadSuccessorLocked | func (fbo *folderBranchOps) setHeadSuccessorLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata, rebased bool) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head == (ImmutableRootMetadata{}) {
// This can happen in tests via SyncFromServer().
return fbo.setInitialHeadTrustedLocked(
ctx, lState, md, mdToCommitType(md))
}
if !rebased {
err := fbo.head.CheckValidSuccessor(fbo.head.mdID, md.ReadOnly())
if err != nil {
return err
}
}
oldHandle := fbo.head.GetTlfHandle()
newHandle := md.GetTlfHandle()
// Newer handles should be equal or more resolved over time.
//
// TODO: In some cases, they shouldn't, e.g. if we're on an
// unmerged branch. Add checks for this.
resolvesTo, partialResolvedOldHandle, err :=
oldHandle.ResolvesTo(
ctx, fbo.config.Codec(), fbo.config.KBPKI(),
tlfhandle.ConstIDGetter{ID: fbo.id()}, fbo.config, *newHandle)
if err != nil {
fbo.log.CDebugf(ctx, "oldHandle=%+v, newHandle=%+v: err=%+v", oldHandle, newHandle, err)
return err
}
oldName := oldHandle.GetCanonicalName()
newName := newHandle.GetCanonicalName()
if !resolvesTo {
fbo.log.CDebugf(ctx, "Incompatible handle error, "+
"oldHandle: %#v, partialResolvedOldHandle: %#v, newHandle: %#v",
oldHandle, partialResolvedOldHandle, newHandle)
return IncompatibleHandleError{
oldName,
partialResolvedOldHandle.GetCanonicalName(),
newName,
}
}
err = fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
if err != nil {
return err
}
if oldName != newName {
fbo.log.CDebugf(ctx, "Handle changed (%s -> %s)",
oldName, newName)
fbo.config.MDCache().ChangeHandleForID(oldHandle, newHandle)
// If the handle has changed, send out a notification.
fbo.observers.tlfHandleChange(ctx, fbo.head.GetTlfHandle())
// Also the folder should be re-identified given the
// newly-resolved assertions.
func() {
fbo.identifyLock.Lock()
defer fbo.identifyLock.Unlock()
fbo.identifyDone = false
}()
}
return nil
} | go | func (fbo *folderBranchOps) setHeadSuccessorLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata, rebased bool) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head == (ImmutableRootMetadata{}) {
// This can happen in tests via SyncFromServer().
return fbo.setInitialHeadTrustedLocked(
ctx, lState, md, mdToCommitType(md))
}
if !rebased {
err := fbo.head.CheckValidSuccessor(fbo.head.mdID, md.ReadOnly())
if err != nil {
return err
}
}
oldHandle := fbo.head.GetTlfHandle()
newHandle := md.GetTlfHandle()
// Newer handles should be equal or more resolved over time.
//
// TODO: In some cases, they shouldn't, e.g. if we're on an
// unmerged branch. Add checks for this.
resolvesTo, partialResolvedOldHandle, err :=
oldHandle.ResolvesTo(
ctx, fbo.config.Codec(), fbo.config.KBPKI(),
tlfhandle.ConstIDGetter{ID: fbo.id()}, fbo.config, *newHandle)
if err != nil {
fbo.log.CDebugf(ctx, "oldHandle=%+v, newHandle=%+v: err=%+v", oldHandle, newHandle, err)
return err
}
oldName := oldHandle.GetCanonicalName()
newName := newHandle.GetCanonicalName()
if !resolvesTo {
fbo.log.CDebugf(ctx, "Incompatible handle error, "+
"oldHandle: %#v, partialResolvedOldHandle: %#v, newHandle: %#v",
oldHandle, partialResolvedOldHandle, newHandle)
return IncompatibleHandleError{
oldName,
partialResolvedOldHandle.GetCanonicalName(),
newName,
}
}
err = fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
if err != nil {
return err
}
if oldName != newName {
fbo.log.CDebugf(ctx, "Handle changed (%s -> %s)",
oldName, newName)
fbo.config.MDCache().ChangeHandleForID(oldHandle, newHandle)
// If the handle has changed, send out a notification.
fbo.observers.tlfHandleChange(ctx, fbo.head.GetTlfHandle())
// Also the folder should be re-identified given the
// newly-resolved assertions.
func() {
fbo.identifyLock.Lock()
defer fbo.identifyLock.Unlock()
fbo.identifyDone = false
}()
}
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"setHeadSuccessorLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"ImmutableRootMetadata",
",",
"rebased",
"bool",
")",
"error",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"if",
"fbo",
".",
"head",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"// This can happen in tests via SyncFromServer().",
"return",
"fbo",
".",
"setInitialHeadTrustedLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"mdToCommitType",
"(",
"md",
")",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"rebased",
"{",
"err",
":=",
"fbo",
".",
"head",
".",
"CheckValidSuccessor",
"(",
"fbo",
".",
"head",
".",
"mdID",
",",
"md",
".",
"ReadOnly",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"oldHandle",
":=",
"fbo",
".",
"head",
".",
"GetTlfHandle",
"(",
")",
"\n",
"newHandle",
":=",
"md",
".",
"GetTlfHandle",
"(",
")",
"\n\n",
"// Newer handles should be equal or more resolved over time.",
"//",
"// TODO: In some cases, they shouldn't, e.g. if we're on an",
"// unmerged branch. Add checks for this.",
"resolvesTo",
",",
"partialResolvedOldHandle",
",",
"err",
":=",
"oldHandle",
".",
"ResolvesTo",
"(",
"ctx",
",",
"fbo",
".",
"config",
".",
"Codec",
"(",
")",
",",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"tlfhandle",
".",
"ConstIDGetter",
"{",
"ID",
":",
"fbo",
".",
"id",
"(",
")",
"}",
",",
"fbo",
".",
"config",
",",
"*",
"newHandle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"oldHandle",
",",
"newHandle",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"oldName",
":=",
"oldHandle",
".",
"GetCanonicalName",
"(",
")",
"\n",
"newName",
":=",
"newHandle",
".",
"GetCanonicalName",
"(",
")",
"\n\n",
"if",
"!",
"resolvesTo",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"oldHandle",
",",
"partialResolvedOldHandle",
",",
"newHandle",
")",
"\n",
"return",
"IncompatibleHandleError",
"{",
"oldName",
",",
"partialResolvedOldHandle",
".",
"GetCanonicalName",
"(",
")",
",",
"newName",
",",
"}",
"\n",
"}",
"\n\n",
"err",
"=",
"fbo",
".",
"setHeadLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"headTrusted",
",",
"mdToCommitType",
"(",
"md",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"oldName",
"!=",
"newName",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"oldName",
",",
"newName",
")",
"\n\n",
"fbo",
".",
"config",
".",
"MDCache",
"(",
")",
".",
"ChangeHandleForID",
"(",
"oldHandle",
",",
"newHandle",
")",
"\n",
"// If the handle has changed, send out a notification.",
"fbo",
".",
"observers",
".",
"tlfHandleChange",
"(",
"ctx",
",",
"fbo",
".",
"head",
".",
"GetTlfHandle",
"(",
")",
")",
"\n",
"// Also the folder should be re-identified given the",
"// newly-resolved assertions.",
"func",
"(",
")",
"{",
"fbo",
".",
"identifyLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fbo",
".",
"identifyLock",
".",
"Unlock",
"(",
")",
"\n",
"fbo",
".",
"identifyDone",
"=",
"false",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // setHeadSuccessorLocked is for when we're applying updates from the
// server or when we're applying new updates we created ourselves. | [
"setHeadSuccessorLocked",
"is",
"for",
"when",
"we",
"re",
"applying",
"updates",
"from",
"the",
"server",
"or",
"when",
"we",
"re",
"applying",
"new",
"updates",
"we",
"created",
"ourselves",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L1868-L1937 |
161,423 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | setHeadPredecessorLocked | func (fbo *folderBranchOps) setHeadPredecessorLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head == (ImmutableRootMetadata{}) {
return errors.New("Unexpected nil head in setHeadPredecessorLocked")
}
if fbo.head.Revision() <= kbfsmd.RevisionInitial {
return errors.Errorf("setHeadPredecessorLocked unexpectedly called with revision %d", fbo.head.Revision())
}
if fbo.head.MergedStatus() != kbfsmd.Unmerged {
return errors.New("Unexpected merged head in setHeadPredecessorLocked")
}
err := md.CheckValidSuccessor(md.mdID, fbo.head.ReadOnly())
if err != nil {
return err
}
oldHandle := fbo.head.GetTlfHandle()
newHandle := md.GetTlfHandle()
// The two handles must be the same, since no rekeying is done
// while unmerged.
eq, err := oldHandle.Equals(fbo.config.Codec(), *newHandle)
if err != nil {
return err
}
if !eq {
return errors.Errorf(
"head handle %v unexpectedly not equal to new handle = %v",
oldHandle, newHandle)
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
} | go | func (fbo *folderBranchOps) setHeadPredecessorLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head == (ImmutableRootMetadata{}) {
return errors.New("Unexpected nil head in setHeadPredecessorLocked")
}
if fbo.head.Revision() <= kbfsmd.RevisionInitial {
return errors.Errorf("setHeadPredecessorLocked unexpectedly called with revision %d", fbo.head.Revision())
}
if fbo.head.MergedStatus() != kbfsmd.Unmerged {
return errors.New("Unexpected merged head in setHeadPredecessorLocked")
}
err := md.CheckValidSuccessor(md.mdID, fbo.head.ReadOnly())
if err != nil {
return err
}
oldHandle := fbo.head.GetTlfHandle()
newHandle := md.GetTlfHandle()
// The two handles must be the same, since no rekeying is done
// while unmerged.
eq, err := oldHandle.Equals(fbo.config.Codec(), *newHandle)
if err != nil {
return err
}
if !eq {
return errors.Errorf(
"head handle %v unexpectedly not equal to new handle = %v",
oldHandle, newHandle)
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"setHeadPredecessorLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"ImmutableRootMetadata",
")",
"error",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"if",
"fbo",
".",
"head",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"fbo",
".",
"head",
".",
"Revision",
"(",
")",
"<=",
"kbfsmd",
".",
"RevisionInitial",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fbo",
".",
"head",
".",
"Revision",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"fbo",
".",
"head",
".",
"MergedStatus",
"(",
")",
"!=",
"kbfsmd",
".",
"Unmerged",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"err",
":=",
"md",
".",
"CheckValidSuccessor",
"(",
"md",
".",
"mdID",
",",
"fbo",
".",
"head",
".",
"ReadOnly",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"oldHandle",
":=",
"fbo",
".",
"head",
".",
"GetTlfHandle",
"(",
")",
"\n",
"newHandle",
":=",
"md",
".",
"GetTlfHandle",
"(",
")",
"\n\n",
"// The two handles must be the same, since no rekeying is done",
"// while unmerged.",
"eq",
",",
"err",
":=",
"oldHandle",
".",
"Equals",
"(",
"fbo",
".",
"config",
".",
"Codec",
"(",
")",
",",
"*",
"newHandle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"eq",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"oldHandle",
",",
"newHandle",
")",
"\n",
"}",
"\n\n",
"return",
"fbo",
".",
"setHeadLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"headTrusted",
",",
"mdToCommitType",
"(",
"md",
")",
")",
"\n",
"}"
] | // setHeadPredecessorLocked is for when we're unstaging updates. | [
"setHeadPredecessorLocked",
"is",
"for",
"when",
"we",
"re",
"unstaging",
"updates",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L1940-L1977 |
161,424 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | setHeadConflictResolvedLocked | func (fbo *folderBranchOps) setHeadConflictResolvedLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head.MergedStatus() != kbfsmd.Unmerged {
return errors.New("Unexpected merged head in setHeadConflictResolvedLocked")
}
if md.MergedStatus() != kbfsmd.Merged {
return errors.New("Unexpected unmerged update in setHeadConflictResolvedLocked")
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
} | go | func (fbo *folderBranchOps) setHeadConflictResolvedLocked(ctx context.Context,
lState *kbfssync.LockState, md ImmutableRootMetadata) error {
fbo.mdWriterLock.AssertLocked(lState)
fbo.headLock.AssertLocked(lState)
if fbo.head.MergedStatus() != kbfsmd.Unmerged {
return errors.New("Unexpected merged head in setHeadConflictResolvedLocked")
}
if md.MergedStatus() != kbfsmd.Merged {
return errors.New("Unexpected unmerged update in setHeadConflictResolvedLocked")
}
return fbo.setHeadLocked(ctx, lState, md, headTrusted, mdToCommitType(md))
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"setHeadConflictResolvedLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"ImmutableRootMetadata",
")",
"error",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"if",
"fbo",
".",
"head",
".",
"MergedStatus",
"(",
")",
"!=",
"kbfsmd",
".",
"Unmerged",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"md",
".",
"MergedStatus",
"(",
")",
"!=",
"kbfsmd",
".",
"Merged",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"fbo",
".",
"setHeadLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"headTrusted",
",",
"mdToCommitType",
"(",
"md",
")",
")",
"\n",
"}"
] | // setHeadConflictResolvedLocked is for when we're setting the merged
// update with resolved conflicts. | [
"setHeadConflictResolvedLocked",
"is",
"for",
"when",
"we",
"re",
"setting",
"the",
"merged",
"update",
"with",
"resolved",
"conflicts",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L1981-L1993 |
161,425 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | getMDForRead | func (fbo *folderBranchOps) getMDForRead(
ctx context.Context, lState *kbfssync.LockState, rtype mdReadType) (
md ImmutableRootMetadata, err error) {
if rtype != mdReadNeedIdentify && rtype != mdReadNoIdentify {
panic("Invalid rtype in getMDLockedForRead")
}
md = fbo.getTrustedHead(ctx, lState, mdCommit)
if md != (ImmutableRootMetadata{}) {
if rtype != mdReadNoIdentify {
err = fbo.identifyOnce(ctx, md.ReadOnly())
}
return md, err
}
return ImmutableRootMetadata{}, MDWriteNeededInRequest{}
} | go | func (fbo *folderBranchOps) getMDForRead(
ctx context.Context, lState *kbfssync.LockState, rtype mdReadType) (
md ImmutableRootMetadata, err error) {
if rtype != mdReadNeedIdentify && rtype != mdReadNoIdentify {
panic("Invalid rtype in getMDLockedForRead")
}
md = fbo.getTrustedHead(ctx, lState, mdCommit)
if md != (ImmutableRootMetadata{}) {
if rtype != mdReadNoIdentify {
err = fbo.identifyOnce(ctx, md.ReadOnly())
}
return md, err
}
return ImmutableRootMetadata{}, MDWriteNeededInRequest{}
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"getMDForRead",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"rtype",
"mdReadType",
")",
"(",
"md",
"ImmutableRootMetadata",
",",
"err",
"error",
")",
"{",
"if",
"rtype",
"!=",
"mdReadNeedIdentify",
"&&",
"rtype",
"!=",
"mdReadNoIdentify",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"md",
"=",
"fbo",
".",
"getTrustedHead",
"(",
"ctx",
",",
"lState",
",",
"mdCommit",
")",
"\n",
"if",
"md",
"!=",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"if",
"rtype",
"!=",
"mdReadNoIdentify",
"{",
"err",
"=",
"fbo",
".",
"identifyOnce",
"(",
"ctx",
",",
"md",
".",
"ReadOnly",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"md",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"MDWriteNeededInRequest",
"{",
"}",
"\n",
"}"
] | // getMDForRead returns an existing md for a read operation. Note that
// mds will not be fetched here. | [
"getMDForRead",
"returns",
"an",
"existing",
"md",
"for",
"a",
"read",
"operation",
".",
"Note",
"that",
"mds",
"will",
"not",
"be",
"fetched",
"here",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L2034-L2050 |
161,426 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | GetTLFHandle | func (fbo *folderBranchOps) GetTLFHandle(ctx context.Context, _ Node) (
*tlfhandle.Handle, error) {
lState := makeFBOLockState()
md, _ := fbo.getHead(ctx, lState, mdNoCommit)
return md.GetTlfHandle(), nil
} | go | func (fbo *folderBranchOps) GetTLFHandle(ctx context.Context, _ Node) (
*tlfhandle.Handle, error) {
lState := makeFBOLockState()
md, _ := fbo.getHead(ctx, lState, mdNoCommit)
return md.GetTlfHandle(), nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"GetTLFHandle",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"Node",
")",
"(",
"*",
"tlfhandle",
".",
"Handle",
",",
"error",
")",
"{",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"md",
",",
"_",
":=",
"fbo",
".",
"getHead",
"(",
"ctx",
",",
"lState",
",",
"mdNoCommit",
")",
"\n",
"return",
"md",
".",
"GetTlfHandle",
"(",
")",
",",
"nil",
"\n",
"}"
] | // GetTLFHandle implements the KBFSOps interface for folderBranchOps. | [
"GetTLFHandle",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L2053-L2058 |
161,427 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | getMDForWriteOrRekeyLocked | func (fbo *folderBranchOps) getMDForWriteOrRekeyLocked(
ctx context.Context, lState *kbfssync.LockState, mdType mdUpdateType) (
md ImmutableRootMetadata, err error) {
defer func() {
if err != nil || mdType == mdRekey {
return
}
err = fbo.identifyOnce(ctx, md.ReadOnly())
}()
md = fbo.getTrustedHead(ctx, lState, mdNoCommit)
if md != (ImmutableRootMetadata{}) {
return md, nil
}
// MDs coming from from rekey notifications are marked untrusted.
//
// TODO: Make tests not take this code path.
fbo.mdWriterLock.AssertLocked(lState)
// Not in cache, fetch from server and add to cache. First, see
// if this device has any unmerged commits -- take the latest one.
mdops := fbo.config.MDOps()
// get the head of the unmerged branch for this device (if any)
md, err = mdops.GetUnmergedForTLF(ctx, fbo.id(), kbfsmd.NullBranchID)
if err != nil {
return ImmutableRootMetadata{}, err
}
mergedMD, err := mdops.GetForTLF(ctx, fbo.id(), nil)
if err != nil {
return ImmutableRootMetadata{}, err
}
if mergedMD == (ImmutableRootMetadata{}) {
return ImmutableRootMetadata{},
errors.WithStack(NoMergedMDError{fbo.id()})
}
if md == (ImmutableRootMetadata{}) {
// There are no unmerged MDs for this device, so just use the current head.
md = mergedMD
} else {
func() {
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
// We don't need to do this for merged head
// because the setHeadLocked() already does
// that anyway.
fbo.setLatestMergedRevisionLocked(ctx, lState, mergedMD.Revision(), false)
}()
}
if md.data.Dir.Type != data.Dir && (!md.IsInitialized() || md.IsReadable()) {
return ImmutableRootMetadata{}, errors.Errorf("Got undecryptable RMD for %s: initialized=%t, readable=%t", fbo.id(), md.IsInitialized(), md.IsReadable())
}
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
headStatus := headTrusted
if mdType == mdRekey {
// If we already have a head (that has been filled after the initial
// check, but before we acquired the lock), then just return it.
if fbo.head != (ImmutableRootMetadata{}) {
return fbo.head, nil
}
headStatus = headUntrusted
}
err = fbo.setHeadLocked(ctx, lState, md, headStatus, mdToCommitType(md))
if err != nil {
return ImmutableRootMetadata{}, err
}
return md, nil
} | go | func (fbo *folderBranchOps) getMDForWriteOrRekeyLocked(
ctx context.Context, lState *kbfssync.LockState, mdType mdUpdateType) (
md ImmutableRootMetadata, err error) {
defer func() {
if err != nil || mdType == mdRekey {
return
}
err = fbo.identifyOnce(ctx, md.ReadOnly())
}()
md = fbo.getTrustedHead(ctx, lState, mdNoCommit)
if md != (ImmutableRootMetadata{}) {
return md, nil
}
// MDs coming from from rekey notifications are marked untrusted.
//
// TODO: Make tests not take this code path.
fbo.mdWriterLock.AssertLocked(lState)
// Not in cache, fetch from server and add to cache. First, see
// if this device has any unmerged commits -- take the latest one.
mdops := fbo.config.MDOps()
// get the head of the unmerged branch for this device (if any)
md, err = mdops.GetUnmergedForTLF(ctx, fbo.id(), kbfsmd.NullBranchID)
if err != nil {
return ImmutableRootMetadata{}, err
}
mergedMD, err := mdops.GetForTLF(ctx, fbo.id(), nil)
if err != nil {
return ImmutableRootMetadata{}, err
}
if mergedMD == (ImmutableRootMetadata{}) {
return ImmutableRootMetadata{},
errors.WithStack(NoMergedMDError{fbo.id()})
}
if md == (ImmutableRootMetadata{}) {
// There are no unmerged MDs for this device, so just use the current head.
md = mergedMD
} else {
func() {
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
// We don't need to do this for merged head
// because the setHeadLocked() already does
// that anyway.
fbo.setLatestMergedRevisionLocked(ctx, lState, mergedMD.Revision(), false)
}()
}
if md.data.Dir.Type != data.Dir && (!md.IsInitialized() || md.IsReadable()) {
return ImmutableRootMetadata{}, errors.Errorf("Got undecryptable RMD for %s: initialized=%t, readable=%t", fbo.id(), md.IsInitialized(), md.IsReadable())
}
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
headStatus := headTrusted
if mdType == mdRekey {
// If we already have a head (that has been filled after the initial
// check, but before we acquired the lock), then just return it.
if fbo.head != (ImmutableRootMetadata{}) {
return fbo.head, nil
}
headStatus = headUntrusted
}
err = fbo.setHeadLocked(ctx, lState, md, headStatus, mdToCommitType(md))
if err != nil {
return ImmutableRootMetadata{}, err
}
return md, nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"getMDForWriteOrRekeyLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"mdType",
"mdUpdateType",
")",
"(",
"md",
"ImmutableRootMetadata",
",",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"||",
"mdType",
"==",
"mdRekey",
"{",
"return",
"\n",
"}",
"\n",
"err",
"=",
"fbo",
".",
"identifyOnce",
"(",
"ctx",
",",
"md",
".",
"ReadOnly",
"(",
")",
")",
"\n",
"}",
"(",
")",
"\n\n",
"md",
"=",
"fbo",
".",
"getTrustedHead",
"(",
"ctx",
",",
"lState",
",",
"mdNoCommit",
")",
"\n",
"if",
"md",
"!=",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"return",
"md",
",",
"nil",
"\n",
"}",
"\n\n",
"// MDs coming from from rekey notifications are marked untrusted.",
"//",
"// TODO: Make tests not take this code path.",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n\n",
"// Not in cache, fetch from server and add to cache. First, see",
"// if this device has any unmerged commits -- take the latest one.",
"mdops",
":=",
"fbo",
".",
"config",
".",
"MDOps",
"(",
")",
"\n\n",
"// get the head of the unmerged branch for this device (if any)",
"md",
",",
"err",
"=",
"mdops",
".",
"GetUnmergedForTLF",
"(",
"ctx",
",",
"fbo",
".",
"id",
"(",
")",
",",
"kbfsmd",
".",
"NullBranchID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"mergedMD",
",",
"err",
":=",
"mdops",
".",
"GetForTLF",
"(",
"ctx",
",",
"fbo",
".",
"id",
"(",
")",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"mergedMD",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"errors",
".",
"WithStack",
"(",
"NoMergedMDError",
"{",
"fbo",
".",
"id",
"(",
")",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"md",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"// There are no unmerged MDs for this device, so just use the current head.",
"md",
"=",
"mergedMD",
"\n",
"}",
"else",
"{",
"func",
"(",
")",
"{",
"fbo",
".",
"headLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"headLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"// We don't need to do this for merged head",
"// because the setHeadLocked() already does",
"// that anyway.",
"fbo",
".",
"setLatestMergedRevisionLocked",
"(",
"ctx",
",",
"lState",
",",
"mergedMD",
".",
"Revision",
"(",
")",
",",
"false",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"md",
".",
"data",
".",
"Dir",
".",
"Type",
"!=",
"data",
".",
"Dir",
"&&",
"(",
"!",
"md",
".",
"IsInitialized",
"(",
")",
"||",
"md",
".",
"IsReadable",
"(",
")",
")",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fbo",
".",
"id",
"(",
")",
",",
"md",
".",
"IsInitialized",
"(",
")",
",",
"md",
".",
"IsReadable",
"(",
")",
")",
"\n",
"}",
"\n\n",
"fbo",
".",
"headLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"headLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"headStatus",
":=",
"headTrusted",
"\n",
"if",
"mdType",
"==",
"mdRekey",
"{",
"// If we already have a head (that has been filled after the initial",
"// check, but before we acquired the lock), then just return it.",
"if",
"fbo",
".",
"head",
"!=",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"return",
"fbo",
".",
"head",
",",
"nil",
"\n",
"}",
"\n",
"headStatus",
"=",
"headUntrusted",
"\n",
"}",
"\n\n",
"err",
"=",
"fbo",
".",
"setHeadLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"headStatus",
",",
"mdToCommitType",
"(",
"md",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"md",
",",
"nil",
"\n",
"}"
] | // getMDForWriteOrRekeyLocked can fetch MDs, identify them and
// contains the fancy logic. For reading use getMDLockedForRead.
// Here we actually can fetch things from the server.
// rekeys are untrusted. | [
"getMDForWriteOrRekeyLocked",
"can",
"fetch",
"MDs",
"identify",
"them",
"and",
"contains",
"the",
"fancy",
"logic",
".",
"For",
"reading",
"use",
"getMDLockedForRead",
".",
"Here",
"we",
"actually",
"can",
"fetch",
"things",
"from",
"the",
"server",
".",
"rekeys",
"are",
"untrusted",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L2064-L2140 |
161,428 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | getMostRecentFullyMergedMD | func (fbo *folderBranchOps) getMostRecentFullyMergedMD(ctx context.Context) (
ImmutableRootMetadata, error) {
mergedRev, err := fbo.getJournalPredecessorRevision(ctx)
if err != nil {
return ImmutableRootMetadata{}, err
}
if mergedRev == kbfsmd.RevisionUninitialized {
// No unflushed journal entries, so use the local head.
lState := makeFBOLockState()
return fbo.getMDForReadHelper(ctx, lState, mdReadNoIdentify)
}
// Otherwise, use the specified revision.
rmd, err := getSingleMD(ctx, fbo.config, fbo.id(), kbfsmd.NullBranchID,
mergedRev, kbfsmd.Merged, nil)
if err != nil {
return ImmutableRootMetadata{}, err
}
fbo.vlog.CLogf(
ctx, libkb.VLog1, "Most recent fully merged revision is %d", mergedRev)
return rmd, nil
} | go | func (fbo *folderBranchOps) getMostRecentFullyMergedMD(ctx context.Context) (
ImmutableRootMetadata, error) {
mergedRev, err := fbo.getJournalPredecessorRevision(ctx)
if err != nil {
return ImmutableRootMetadata{}, err
}
if mergedRev == kbfsmd.RevisionUninitialized {
// No unflushed journal entries, so use the local head.
lState := makeFBOLockState()
return fbo.getMDForReadHelper(ctx, lState, mdReadNoIdentify)
}
// Otherwise, use the specified revision.
rmd, err := getSingleMD(ctx, fbo.config, fbo.id(), kbfsmd.NullBranchID,
mergedRev, kbfsmd.Merged, nil)
if err != nil {
return ImmutableRootMetadata{}, err
}
fbo.vlog.CLogf(
ctx, libkb.VLog1, "Most recent fully merged revision is %d", mergedRev)
return rmd, nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"getMostRecentFullyMergedMD",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"ImmutableRootMetadata",
",",
"error",
")",
"{",
"mergedRev",
",",
"err",
":=",
"fbo",
".",
"getJournalPredecessorRevision",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"mergedRev",
"==",
"kbfsmd",
".",
"RevisionUninitialized",
"{",
"// No unflushed journal entries, so use the local head.",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"return",
"fbo",
".",
"getMDForReadHelper",
"(",
"ctx",
",",
"lState",
",",
"mdReadNoIdentify",
")",
"\n",
"}",
"\n\n",
"// Otherwise, use the specified revision.",
"rmd",
",",
"err",
":=",
"getSingleMD",
"(",
"ctx",
",",
"fbo",
".",
"config",
",",
"fbo",
".",
"id",
"(",
")",
",",
"kbfsmd",
".",
"NullBranchID",
",",
"mergedRev",
",",
"kbfsmd",
".",
"Merged",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"fbo",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
",",
"mergedRev",
")",
"\n",
"return",
"rmd",
",",
"nil",
"\n",
"}"
] | // getMostRecentFullyMergedMD is a helper method that returns the most
// recent merged MD that has been flushed to the server. This could
// be different from the current local head if journaling is on. If
// the journal is on a branch, it returns an error. | [
"getMostRecentFullyMergedMD",
"is",
"a",
"helper",
"method",
"that",
"returns",
"the",
"most",
"recent",
"merged",
"MD",
"that",
"has",
"been",
"flushed",
"to",
"the",
"server",
".",
"This",
"could",
"be",
"different",
"from",
"the",
"current",
"local",
"head",
"if",
"journaling",
"is",
"on",
".",
"If",
"the",
"journal",
"is",
"on",
"a",
"branch",
"it",
"returns",
"an",
"error",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L2171-L2194 |
161,429 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | getMDForRekeyWriteLocked | func (fbo *folderBranchOps) getMDForRekeyWriteLocked(
ctx context.Context, lState *kbfssync.LockState) (
rmd *RootMetadata, lastWriterVerifyingKey kbfscrypto.VerifyingKey,
wasRekeySet bool, err error) {
fbo.mdWriterLock.AssertLocked(lState)
md, err := fbo.getMDForWriteOrRekeyLocked(ctx, lState, mdRekey)
if err != nil {
return nil, kbfscrypto.VerifyingKey{}, false, err
}
if md.TypeForKeying() == tlf.TeamKeying {
return nil, kbfscrypto.VerifyingKey{}, false, nil
}
session, err := fbo.config.KBPKI().GetCurrentSession(ctx)
if err != nil {
return nil, kbfscrypto.VerifyingKey{}, false, err
}
handle := md.GetTlfHandle()
// must be a reader or writer (it checks both.)
if !handle.IsReader(session.UID) {
return nil, kbfscrypto.VerifyingKey{}, false,
NewRekeyPermissionError(md.GetTlfHandle(), session.Name)
}
newMd, err := md.MakeSuccessor(ctx, fbo.config.MetadataVersion(),
fbo.config.Codec(),
fbo.config.KeyManager(), fbo.config.KBPKI(), fbo.config.KBPKI(),
fbo.config, md.mdID, handle.IsWriter(session.UID))
if err != nil {
return nil, kbfscrypto.VerifyingKey{}, false, err
}
// readers shouldn't modify writer metadata
if !handle.IsWriter(session.UID) && !newMd.IsWriterMetadataCopiedSet() {
return nil, kbfscrypto.VerifyingKey{}, false,
NewRekeyPermissionError(handle, session.Name)
}
return newMd, md.LastModifyingWriterVerifyingKey(), md.IsRekeySet(), nil
} | go | func (fbo *folderBranchOps) getMDForRekeyWriteLocked(
ctx context.Context, lState *kbfssync.LockState) (
rmd *RootMetadata, lastWriterVerifyingKey kbfscrypto.VerifyingKey,
wasRekeySet bool, err error) {
fbo.mdWriterLock.AssertLocked(lState)
md, err := fbo.getMDForWriteOrRekeyLocked(ctx, lState, mdRekey)
if err != nil {
return nil, kbfscrypto.VerifyingKey{}, false, err
}
if md.TypeForKeying() == tlf.TeamKeying {
return nil, kbfscrypto.VerifyingKey{}, false, nil
}
session, err := fbo.config.KBPKI().GetCurrentSession(ctx)
if err != nil {
return nil, kbfscrypto.VerifyingKey{}, false, err
}
handle := md.GetTlfHandle()
// must be a reader or writer (it checks both.)
if !handle.IsReader(session.UID) {
return nil, kbfscrypto.VerifyingKey{}, false,
NewRekeyPermissionError(md.GetTlfHandle(), session.Name)
}
newMd, err := md.MakeSuccessor(ctx, fbo.config.MetadataVersion(),
fbo.config.Codec(),
fbo.config.KeyManager(), fbo.config.KBPKI(), fbo.config.KBPKI(),
fbo.config, md.mdID, handle.IsWriter(session.UID))
if err != nil {
return nil, kbfscrypto.VerifyingKey{}, false, err
}
// readers shouldn't modify writer metadata
if !handle.IsWriter(session.UID) && !newMd.IsWriterMetadataCopiedSet() {
return nil, kbfscrypto.VerifyingKey{}, false,
NewRekeyPermissionError(handle, session.Name)
}
return newMd, md.LastModifyingWriterVerifyingKey(), md.IsRekeySet(), nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"getMDForRekeyWriteLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
")",
"(",
"rmd",
"*",
"RootMetadata",
",",
"lastWriterVerifyingKey",
"kbfscrypto",
".",
"VerifyingKey",
",",
"wasRekeySet",
"bool",
",",
"err",
"error",
")",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n\n",
"md",
",",
"err",
":=",
"fbo",
".",
"getMDForWriteOrRekeyLocked",
"(",
"ctx",
",",
"lState",
",",
"mdRekey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"VerifyingKey",
"{",
"}",
",",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"md",
".",
"TypeForKeying",
"(",
")",
"==",
"tlf",
".",
"TeamKeying",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"VerifyingKey",
"{",
"}",
",",
"false",
",",
"nil",
"\n",
"}",
"\n\n",
"session",
",",
"err",
":=",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
".",
"GetCurrentSession",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"VerifyingKey",
"{",
"}",
",",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"handle",
":=",
"md",
".",
"GetTlfHandle",
"(",
")",
"\n\n",
"// must be a reader or writer (it checks both.)",
"if",
"!",
"handle",
".",
"IsReader",
"(",
"session",
".",
"UID",
")",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"VerifyingKey",
"{",
"}",
",",
"false",
",",
"NewRekeyPermissionError",
"(",
"md",
".",
"GetTlfHandle",
"(",
")",
",",
"session",
".",
"Name",
")",
"\n",
"}",
"\n\n",
"newMd",
",",
"err",
":=",
"md",
".",
"MakeSuccessor",
"(",
"ctx",
",",
"fbo",
".",
"config",
".",
"MetadataVersion",
"(",
")",
",",
"fbo",
".",
"config",
".",
"Codec",
"(",
")",
",",
"fbo",
".",
"config",
".",
"KeyManager",
"(",
")",
",",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"fbo",
".",
"config",
",",
"md",
".",
"mdID",
",",
"handle",
".",
"IsWriter",
"(",
"session",
".",
"UID",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"VerifyingKey",
"{",
"}",
",",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"// readers shouldn't modify writer metadata",
"if",
"!",
"handle",
".",
"IsWriter",
"(",
"session",
".",
"UID",
")",
"&&",
"!",
"newMd",
".",
"IsWriterMetadataCopiedSet",
"(",
")",
"{",
"return",
"nil",
",",
"kbfscrypto",
".",
"VerifyingKey",
"{",
"}",
",",
"false",
",",
"NewRekeyPermissionError",
"(",
"handle",
",",
"session",
".",
"Name",
")",
"\n",
"}",
"\n\n",
"return",
"newMd",
",",
"md",
".",
"LastModifyingWriterVerifyingKey",
"(",
")",
",",
"md",
".",
"IsRekeySet",
"(",
")",
",",
"nil",
"\n",
"}"
] | // getMDForRekeyWriteLocked returns a nil `rmd` if it is a team TLF,
// since that can't be rekeyed by KBFS. | [
"getMDForRekeyWriteLocked",
"returns",
"a",
"nil",
"rmd",
"if",
"it",
"is",
"a",
"team",
"TLF",
"since",
"that",
"can",
"t",
"be",
"rekeyed",
"by",
"KBFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L2311-L2354 |
161,430 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | ResetRootBlock | func ResetRootBlock(ctx context.Context, config Config,
rmd *RootMetadata) (data.Block, data.BlockInfo, data.ReadyBlockData, error) {
newDblock := data.NewDirBlock()
chargedTo, err := chargedToForTLF(
ctx, config.KBPKI(), config.KBPKI(), config, rmd.GetTlfHandle())
if err != nil {
return nil, data.BlockInfo{}, data.ReadyBlockData{}, err
}
info, plainSize, readyBlockData, err :=
data.ReadyBlock(ctx, config.BlockCache(), config.BlockOps(),
rmd.ReadOnly(), newDblock, chargedTo, config.DefaultBlockType())
if err != nil {
return nil, data.BlockInfo{}, data.ReadyBlockData{}, err
}
now := config.Clock().Now().UnixNano()
rmd.data.Dir = data.DirEntry{
BlockInfo: info,
EntryInfo: data.EntryInfo{
Type: data.Dir,
Size: uint64(plainSize),
Mtime: now,
Ctime: now,
},
}
prevDiskUsage := rmd.DiskUsage()
rmd.SetDiskUsage(0)
// Redundant, since this is called only for brand-new or
// successor RMDs, but leave in to be defensive.
rmd.ClearBlockChanges()
co := newCreateOpForRootDir()
rmd.AddOp(co)
rmd.AddRefBlock(rmd.data.Dir.BlockInfo)
// Set unref bytes to the previous disk usage, so that the
// accounting works out.
rmd.AddUnrefBytes(prevDiskUsage)
return newDblock, info, readyBlockData, nil
} | go | func ResetRootBlock(ctx context.Context, config Config,
rmd *RootMetadata) (data.Block, data.BlockInfo, data.ReadyBlockData, error) {
newDblock := data.NewDirBlock()
chargedTo, err := chargedToForTLF(
ctx, config.KBPKI(), config.KBPKI(), config, rmd.GetTlfHandle())
if err != nil {
return nil, data.BlockInfo{}, data.ReadyBlockData{}, err
}
info, plainSize, readyBlockData, err :=
data.ReadyBlock(ctx, config.BlockCache(), config.BlockOps(),
rmd.ReadOnly(), newDblock, chargedTo, config.DefaultBlockType())
if err != nil {
return nil, data.BlockInfo{}, data.ReadyBlockData{}, err
}
now := config.Clock().Now().UnixNano()
rmd.data.Dir = data.DirEntry{
BlockInfo: info,
EntryInfo: data.EntryInfo{
Type: data.Dir,
Size: uint64(plainSize),
Mtime: now,
Ctime: now,
},
}
prevDiskUsage := rmd.DiskUsage()
rmd.SetDiskUsage(0)
// Redundant, since this is called only for brand-new or
// successor RMDs, but leave in to be defensive.
rmd.ClearBlockChanges()
co := newCreateOpForRootDir()
rmd.AddOp(co)
rmd.AddRefBlock(rmd.data.Dir.BlockInfo)
// Set unref bytes to the previous disk usage, so that the
// accounting works out.
rmd.AddUnrefBytes(prevDiskUsage)
return newDblock, info, readyBlockData, nil
} | [
"func",
"ResetRootBlock",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"Config",
",",
"rmd",
"*",
"RootMetadata",
")",
"(",
"data",
".",
"Block",
",",
"data",
".",
"BlockInfo",
",",
"data",
".",
"ReadyBlockData",
",",
"error",
")",
"{",
"newDblock",
":=",
"data",
".",
"NewDirBlock",
"(",
")",
"\n",
"chargedTo",
",",
"err",
":=",
"chargedToForTLF",
"(",
"ctx",
",",
"config",
".",
"KBPKI",
"(",
")",
",",
"config",
".",
"KBPKI",
"(",
")",
",",
"config",
",",
"rmd",
".",
"GetTlfHandle",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"data",
".",
"BlockInfo",
"{",
"}",
",",
"data",
".",
"ReadyBlockData",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"info",
",",
"plainSize",
",",
"readyBlockData",
",",
"err",
":=",
"data",
".",
"ReadyBlock",
"(",
"ctx",
",",
"config",
".",
"BlockCache",
"(",
")",
",",
"config",
".",
"BlockOps",
"(",
")",
",",
"rmd",
".",
"ReadOnly",
"(",
")",
",",
"newDblock",
",",
"chargedTo",
",",
"config",
".",
"DefaultBlockType",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"data",
".",
"BlockInfo",
"{",
"}",
",",
"data",
".",
"ReadyBlockData",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"now",
":=",
"config",
".",
"Clock",
"(",
")",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
"\n",
"rmd",
".",
"data",
".",
"Dir",
"=",
"data",
".",
"DirEntry",
"{",
"BlockInfo",
":",
"info",
",",
"EntryInfo",
":",
"data",
".",
"EntryInfo",
"{",
"Type",
":",
"data",
".",
"Dir",
",",
"Size",
":",
"uint64",
"(",
"plainSize",
")",
",",
"Mtime",
":",
"now",
",",
"Ctime",
":",
"now",
",",
"}",
",",
"}",
"\n",
"prevDiskUsage",
":=",
"rmd",
".",
"DiskUsage",
"(",
")",
"\n",
"rmd",
".",
"SetDiskUsage",
"(",
"0",
")",
"\n",
"// Redundant, since this is called only for brand-new or",
"// successor RMDs, but leave in to be defensive.",
"rmd",
".",
"ClearBlockChanges",
"(",
")",
"\n",
"co",
":=",
"newCreateOpForRootDir",
"(",
")",
"\n",
"rmd",
".",
"AddOp",
"(",
"co",
")",
"\n",
"rmd",
".",
"AddRefBlock",
"(",
"rmd",
".",
"data",
".",
"Dir",
".",
"BlockInfo",
")",
"\n",
"// Set unref bytes to the previous disk usage, so that the",
"// accounting works out.",
"rmd",
".",
"AddUnrefBytes",
"(",
"prevDiskUsage",
")",
"\n",
"return",
"newDblock",
",",
"info",
",",
"readyBlockData",
",",
"nil",
"\n",
"}"
] | // ResetRootBlock creates a new empty dir block and sets the given
// metadata's root block to it. | [
"ResetRootBlock",
"creates",
"a",
"new",
"empty",
"dir",
"block",
"and",
"sets",
"the",
"given",
"metadata",
"s",
"root",
"block",
"to",
"it",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L2406-L2444 |
161,431 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | SetInitialHeadToNew | func (fbo *folderBranchOps) SetInitialHeadToNew(
ctx context.Context, id tlf.ID, handle *tlfhandle.Handle) (err error) {
startTime, timer := fbo.startOp(ctx, "SetInitialHeadToNew %s", id)
defer func() {
fbo.endOp(
ctx, startTime, timer, "SetInitialHeadToNew %s done: %+v", id, err)
}()
rmd, err := makeInitialRootMetadata(
fbo.config.MetadataVersion(), id, handle)
if err != nil {
return err
}
return runUnlessCanceled(ctx, func() error {
// New heads can only be set for the MasterBranch.
fb := data.FolderBranch{Tlf: rmd.TlfID(), Branch: data.MasterBranch}
if fb != fbo.folderBranch {
return WrongOpsError{fbo.folderBranch, fb}
}
// Always identify first when trying to initialize the folder,
// even if we turn out not to be a writer. (We can't rely on
// the identifyOnce call in getMDLocked, because that isn't
// called from the initialization code path when the local
// user is not a valid writer.) Also, we want to make sure we
// fail before we set the head, otherwise future calls will
// succeed incorrectly.
err = fbo.identifyOnce(ctx, rmd.ReadOnly())
if err != nil {
return err
}
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.initMDLocked(ctx, lState, rmd)
})
} | go | func (fbo *folderBranchOps) SetInitialHeadToNew(
ctx context.Context, id tlf.ID, handle *tlfhandle.Handle) (err error) {
startTime, timer := fbo.startOp(ctx, "SetInitialHeadToNew %s", id)
defer func() {
fbo.endOp(
ctx, startTime, timer, "SetInitialHeadToNew %s done: %+v", id, err)
}()
rmd, err := makeInitialRootMetadata(
fbo.config.MetadataVersion(), id, handle)
if err != nil {
return err
}
return runUnlessCanceled(ctx, func() error {
// New heads can only be set for the MasterBranch.
fb := data.FolderBranch{Tlf: rmd.TlfID(), Branch: data.MasterBranch}
if fb != fbo.folderBranch {
return WrongOpsError{fbo.folderBranch, fb}
}
// Always identify first when trying to initialize the folder,
// even if we turn out not to be a writer. (We can't rely on
// the identifyOnce call in getMDLocked, because that isn't
// called from the initialization code path when the local
// user is not a valid writer.) Also, we want to make sure we
// fail before we set the head, otherwise future calls will
// succeed incorrectly.
err = fbo.identifyOnce(ctx, rmd.ReadOnly())
if err != nil {
return err
}
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.initMDLocked(ctx, lState, rmd)
})
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"SetInitialHeadToNew",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
",",
"handle",
"*",
"tlfhandle",
".",
"Handle",
")",
"(",
"err",
"error",
")",
"{",
"startTime",
",",
"timer",
":=",
"fbo",
".",
"startOp",
"(",
"ctx",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fbo",
".",
"endOp",
"(",
"ctx",
",",
"startTime",
",",
"timer",
",",
"\"",
"\"",
",",
"id",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"rmd",
",",
"err",
":=",
"makeInitialRootMetadata",
"(",
"fbo",
".",
"config",
".",
"MetadataVersion",
"(",
")",
",",
"id",
",",
"handle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"runUnlessCanceled",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
"// New heads can only be set for the MasterBranch.",
"fb",
":=",
"data",
".",
"FolderBranch",
"{",
"Tlf",
":",
"rmd",
".",
"TlfID",
"(",
")",
",",
"Branch",
":",
"data",
".",
"MasterBranch",
"}",
"\n",
"if",
"fb",
"!=",
"fbo",
".",
"folderBranch",
"{",
"return",
"WrongOpsError",
"{",
"fbo",
".",
"folderBranch",
",",
"fb",
"}",
"\n",
"}",
"\n\n",
"// Always identify first when trying to initialize the folder,",
"// even if we turn out not to be a writer. (We can't rely on",
"// the identifyOnce call in getMDLocked, because that isn't",
"// called from the initialization code path when the local",
"// user is not a valid writer.) Also, we want to make sure we",
"// fail before we set the head, otherwise future calls will",
"// succeed incorrectly.",
"err",
"=",
"fbo",
".",
"identifyOnce",
"(",
"ctx",
",",
"rmd",
".",
"ReadOnly",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n\n",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"return",
"fbo",
".",
"initMDLocked",
"(",
"ctx",
",",
"lState",
",",
"rmd",
")",
"\n",
"}",
")",
"\n",
"}"
] | // SetInitialHeadToNew creates a brand-new ImmutableRootMetadata
// object and sets the head to that. This is trusted. | [
"SetInitialHeadToNew",
"creates",
"a",
"brand",
"-",
"new",
"ImmutableRootMetadata",
"object",
"and",
"sets",
"the",
"head",
"to",
"that",
".",
"This",
"is",
"trusted",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L2794-L2833 |
161,432 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | statEntry | func (fbo *folderBranchOps) statEntry(ctx context.Context, node Node) (
de data.DirEntry, err error) {
defer func() {
err = fbo.transformReadError(ctx, node, err)
}()
err = fbo.checkNodeForRead(ctx, node)
if err != nil {
return data.DirEntry{}, err
}
nodePath, err := fbo.pathFromNodeForRead(node)
if err != nil {
return data.DirEntry{}, err
}
lState := makeFBOLockState()
var md ImmutableRootMetadata
if nodePath.HasValidParent() {
// Look up the node for the parent, and see if it has an FS
// that can be used to stat `node`.
parentPath := nodePath.ParentPath()
parentNode := fbo.nodeCache.Get(parentPath.TailPointer().Ref())
de, ok, err := fbo.statUsingFS(
ctx, lState, parentNode, node.GetBasename())
if err != nil {
return data.DirEntry{}, err
}
if ok {
return de, nil
}
// Otherwise, proceed with the usual way.
md, err = fbo.getMDForReadNeedIdentify(ctx, lState)
// And handle the error, err is local to this block
// shadowing the err in the surrounding block.
if err != nil {
return data.DirEntry{}, err
}
} else {
// If nodePath has no valid parent, it's just the TLF root, so
// we don't need an identify in this case. Note: we don't
// support FS-based stats for the root directory.
md, err = fbo.getMDForReadNoIdentify(ctx, lState)
}
if err != nil {
return data.DirEntry{}, err
}
return fbo.blocks.GetEntryEvenIfDeleted(
ctx, lState, md.ReadOnly(), nodePath)
} | go | func (fbo *folderBranchOps) statEntry(ctx context.Context, node Node) (
de data.DirEntry, err error) {
defer func() {
err = fbo.transformReadError(ctx, node, err)
}()
err = fbo.checkNodeForRead(ctx, node)
if err != nil {
return data.DirEntry{}, err
}
nodePath, err := fbo.pathFromNodeForRead(node)
if err != nil {
return data.DirEntry{}, err
}
lState := makeFBOLockState()
var md ImmutableRootMetadata
if nodePath.HasValidParent() {
// Look up the node for the parent, and see if it has an FS
// that can be used to stat `node`.
parentPath := nodePath.ParentPath()
parentNode := fbo.nodeCache.Get(parentPath.TailPointer().Ref())
de, ok, err := fbo.statUsingFS(
ctx, lState, parentNode, node.GetBasename())
if err != nil {
return data.DirEntry{}, err
}
if ok {
return de, nil
}
// Otherwise, proceed with the usual way.
md, err = fbo.getMDForReadNeedIdentify(ctx, lState)
// And handle the error, err is local to this block
// shadowing the err in the surrounding block.
if err != nil {
return data.DirEntry{}, err
}
} else {
// If nodePath has no valid parent, it's just the TLF root, so
// we don't need an identify in this case. Note: we don't
// support FS-based stats for the root directory.
md, err = fbo.getMDForReadNoIdentify(ctx, lState)
}
if err != nil {
return data.DirEntry{}, err
}
return fbo.blocks.GetEntryEvenIfDeleted(
ctx, lState, md.ReadOnly(), nodePath)
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"statEntry",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"Node",
")",
"(",
"de",
"data",
".",
"DirEntry",
",",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"err",
"=",
"fbo",
".",
"transformReadError",
"(",
"ctx",
",",
"node",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"err",
"=",
"fbo",
".",
"checkNodeForRead",
"(",
"ctx",
",",
"node",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"data",
".",
"DirEntry",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"nodePath",
",",
"err",
":=",
"fbo",
".",
"pathFromNodeForRead",
"(",
"node",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"data",
".",
"DirEntry",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"var",
"md",
"ImmutableRootMetadata",
"\n",
"if",
"nodePath",
".",
"HasValidParent",
"(",
")",
"{",
"// Look up the node for the parent, and see if it has an FS",
"// that can be used to stat `node`.",
"parentPath",
":=",
"nodePath",
".",
"ParentPath",
"(",
")",
"\n",
"parentNode",
":=",
"fbo",
".",
"nodeCache",
".",
"Get",
"(",
"parentPath",
".",
"TailPointer",
"(",
")",
".",
"Ref",
"(",
")",
")",
"\n",
"de",
",",
"ok",
",",
"err",
":=",
"fbo",
".",
"statUsingFS",
"(",
"ctx",
",",
"lState",
",",
"parentNode",
",",
"node",
".",
"GetBasename",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"data",
".",
"DirEntry",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"ok",
"{",
"return",
"de",
",",
"nil",
"\n",
"}",
"\n\n",
"// Otherwise, proceed with the usual way.",
"md",
",",
"err",
"=",
"fbo",
".",
"getMDForReadNeedIdentify",
"(",
"ctx",
",",
"lState",
")",
"\n",
"// And handle the error, err is local to this block",
"// shadowing the err in the surrounding block.",
"if",
"err",
"!=",
"nil",
"{",
"return",
"data",
".",
"DirEntry",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// If nodePath has no valid parent, it's just the TLF root, so",
"// we don't need an identify in this case. Note: we don't",
"// support FS-based stats for the root directory.",
"md",
",",
"err",
"=",
"fbo",
".",
"getMDForReadNoIdentify",
"(",
"ctx",
",",
"lState",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"data",
".",
"DirEntry",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"fbo",
".",
"blocks",
".",
"GetEntryEvenIfDeleted",
"(",
"ctx",
",",
"lState",
",",
"md",
".",
"ReadOnly",
"(",
")",
",",
"nodePath",
")",
"\n",
"}"
] | // statEntry is like Stat, but it returns a DirEntry. This is used by
// tests. | [
"statEntry",
"is",
"like",
"Stat",
"but",
"it",
"returns",
"a",
"DirEntry",
".",
"This",
"is",
"used",
"by",
"tests",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L3301-L3351 |
161,433 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | isRevisionConflict | func isRevisionConflict(err error) bool {
if err == nil {
return false
}
_, isConflictRevision := err.(kbfsmd.ServerErrorConflictRevision)
_, isConflictPrevRoot := err.(kbfsmd.ServerErrorConflictPrevRoot)
_, isConflictDiskUsage := err.(kbfsmd.ServerErrorConflictDiskUsage)
_, isConditionFailed := err.(kbfsmd.ServerErrorConditionFailed)
_, isConflictFolderMapping := err.(kbfsmd.ServerErrorConflictFolderMapping)
_, isJournal := err.(MDJournalConflictError)
return isConflictRevision || isConflictPrevRoot ||
isConflictDiskUsage || isConditionFailed ||
isConflictFolderMapping || isJournal
} | go | func isRevisionConflict(err error) bool {
if err == nil {
return false
}
_, isConflictRevision := err.(kbfsmd.ServerErrorConflictRevision)
_, isConflictPrevRoot := err.(kbfsmd.ServerErrorConflictPrevRoot)
_, isConflictDiskUsage := err.(kbfsmd.ServerErrorConflictDiskUsage)
_, isConditionFailed := err.(kbfsmd.ServerErrorConditionFailed)
_, isConflictFolderMapping := err.(kbfsmd.ServerErrorConflictFolderMapping)
_, isJournal := err.(MDJournalConflictError)
return isConflictRevision || isConflictPrevRoot ||
isConflictDiskUsage || isConditionFailed ||
isConflictFolderMapping || isJournal
} | [
"func",
"isRevisionConflict",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"_",
",",
"isConflictRevision",
":=",
"err",
".",
"(",
"kbfsmd",
".",
"ServerErrorConflictRevision",
")",
"\n",
"_",
",",
"isConflictPrevRoot",
":=",
"err",
".",
"(",
"kbfsmd",
".",
"ServerErrorConflictPrevRoot",
")",
"\n",
"_",
",",
"isConflictDiskUsage",
":=",
"err",
".",
"(",
"kbfsmd",
".",
"ServerErrorConflictDiskUsage",
")",
"\n",
"_",
",",
"isConditionFailed",
":=",
"err",
".",
"(",
"kbfsmd",
".",
"ServerErrorConditionFailed",
")",
"\n",
"_",
",",
"isConflictFolderMapping",
":=",
"err",
".",
"(",
"kbfsmd",
".",
"ServerErrorConflictFolderMapping",
")",
"\n",
"_",
",",
"isJournal",
":=",
"err",
".",
"(",
"MDJournalConflictError",
")",
"\n",
"return",
"isConflictRevision",
"||",
"isConflictPrevRoot",
"||",
"isConflictDiskUsage",
"||",
"isConditionFailed",
"||",
"isConflictFolderMapping",
"||",
"isJournal",
"\n",
"}"
] | // Returns true if the passed error indicates a revision conflict. | [
"Returns",
"true",
"if",
"the",
"passed",
"error",
"indicates",
"a",
"revision",
"conflict",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L3476-L3489 |
161,434 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | PathType | func (fbo *folderBranchOps) PathType() tlfhandle.PathType {
switch fbo.folderBranch.Tlf.Type() {
case tlf.Public:
return tlfhandle.PublicPathType
case tlf.Private:
return tlfhandle.PrivatePathType
case tlf.SingleTeam:
return tlfhandle.SingleTeamPathType
default:
panic(fmt.Sprintf("Unknown TLF type: %s", fbo.folderBranch.Tlf.Type()))
}
} | go | func (fbo *folderBranchOps) PathType() tlfhandle.PathType {
switch fbo.folderBranch.Tlf.Type() {
case tlf.Public:
return tlfhandle.PublicPathType
case tlf.Private:
return tlfhandle.PrivatePathType
case tlf.SingleTeam:
return tlfhandle.SingleTeamPathType
default:
panic(fmt.Sprintf("Unknown TLF type: %s", fbo.folderBranch.Tlf.Type()))
}
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"PathType",
"(",
")",
"tlfhandle",
".",
"PathType",
"{",
"switch",
"fbo",
".",
"folderBranch",
".",
"Tlf",
".",
"Type",
"(",
")",
"{",
"case",
"tlf",
".",
"Public",
":",
"return",
"tlfhandle",
".",
"PublicPathType",
"\n",
"case",
"tlf",
".",
"Private",
":",
"return",
"tlfhandle",
".",
"PrivatePathType",
"\n",
"case",
"tlf",
".",
"SingleTeam",
":",
"return",
"tlfhandle",
".",
"SingleTeamPathType",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"fbo",
".",
"folderBranch",
".",
"Tlf",
".",
"Type",
"(",
")",
")",
")",
"\n",
"}",
"\n",
"}"
] | // PathType returns path type | [
"PathType",
"returns",
"path",
"type"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L4076-L4087 |
161,435 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | canonicalPath | func (fbo *folderBranchOps) canonicalPath(ctx context.Context, dir Node, name string) (string, error) {
dirPath, err := fbo.pathFromNodeForRead(dir)
if err != nil {
return "", err
}
return tlfhandle.BuildCanonicalPath(
fbo.PathType(), dirPath.String(), name), nil
} | go | func (fbo *folderBranchOps) canonicalPath(ctx context.Context, dir Node, name string) (string, error) {
dirPath, err := fbo.pathFromNodeForRead(dir)
if err != nil {
return "", err
}
return tlfhandle.BuildCanonicalPath(
fbo.PathType(), dirPath.String(), name), nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"canonicalPath",
"(",
"ctx",
"context",
".",
"Context",
",",
"dir",
"Node",
",",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"dirPath",
",",
"err",
":=",
"fbo",
".",
"pathFromNodeForRead",
"(",
"dir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"tlfhandle",
".",
"BuildCanonicalPath",
"(",
"fbo",
".",
"PathType",
"(",
")",
",",
"dirPath",
".",
"String",
"(",
")",
",",
"name",
")",
",",
"nil",
"\n",
"}"
] | // canonicalPath returns full canonical path for dir node and name. | [
"canonicalPath",
"returns",
"full",
"canonical",
"path",
"for",
"dir",
"node",
"and",
"name",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L4090-L4097 |
161,436 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | notifyAndSyncOrSignal | func (fbo *folderBranchOps) notifyAndSyncOrSignal(
ctx context.Context, lState *kbfssync.LockState, undoFn dirCacheUndoFn,
nodesToDirty []Node, op op, md ReadOnlyRootMetadata) (err error) {
fbo.dirOps = append(fbo.dirOps, cachedDirOp{op, nodesToDirty})
var addedNodes []Node
for _, n := range nodesToDirty {
added := fbo.status.addDirtyNode(n)
if added {
addedNodes = append(addedNodes, n)
}
}
defer func() {
if err != nil {
for _, n := range addedNodes {
fbo.status.rmDirtyNode(n)
}
fbo.dirOps = fbo.dirOps[:len(fbo.dirOps)-1]
if undoFn != nil {
undoFn(lState)
}
}
}()
// It's safe to notify before we've synced, since it is only
// sending invalidation notifications. At worst the upper layer
// will just have to refresh its cache needlessly.
err = fbo.notifyOneOp(ctx, lState, op, md, false)
if err != nil {
return err
}
return fbo.syncDirUpdateOrSignal(ctx, lState)
} | go | func (fbo *folderBranchOps) notifyAndSyncOrSignal(
ctx context.Context, lState *kbfssync.LockState, undoFn dirCacheUndoFn,
nodesToDirty []Node, op op, md ReadOnlyRootMetadata) (err error) {
fbo.dirOps = append(fbo.dirOps, cachedDirOp{op, nodesToDirty})
var addedNodes []Node
for _, n := range nodesToDirty {
added := fbo.status.addDirtyNode(n)
if added {
addedNodes = append(addedNodes, n)
}
}
defer func() {
if err != nil {
for _, n := range addedNodes {
fbo.status.rmDirtyNode(n)
}
fbo.dirOps = fbo.dirOps[:len(fbo.dirOps)-1]
if undoFn != nil {
undoFn(lState)
}
}
}()
// It's safe to notify before we've synced, since it is only
// sending invalidation notifications. At worst the upper layer
// will just have to refresh its cache needlessly.
err = fbo.notifyOneOp(ctx, lState, op, md, false)
if err != nil {
return err
}
return fbo.syncDirUpdateOrSignal(ctx, lState)
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"notifyAndSyncOrSignal",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"undoFn",
"dirCacheUndoFn",
",",
"nodesToDirty",
"[",
"]",
"Node",
",",
"op",
"op",
",",
"md",
"ReadOnlyRootMetadata",
")",
"(",
"err",
"error",
")",
"{",
"fbo",
".",
"dirOps",
"=",
"append",
"(",
"fbo",
".",
"dirOps",
",",
"cachedDirOp",
"{",
"op",
",",
"nodesToDirty",
"}",
")",
"\n",
"var",
"addedNodes",
"[",
"]",
"Node",
"\n",
"for",
"_",
",",
"n",
":=",
"range",
"nodesToDirty",
"{",
"added",
":=",
"fbo",
".",
"status",
".",
"addDirtyNode",
"(",
"n",
")",
"\n",
"if",
"added",
"{",
"addedNodes",
"=",
"append",
"(",
"addedNodes",
",",
"n",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"for",
"_",
",",
"n",
":=",
"range",
"addedNodes",
"{",
"fbo",
".",
"status",
".",
"rmDirtyNode",
"(",
"n",
")",
"\n",
"}",
"\n",
"fbo",
".",
"dirOps",
"=",
"fbo",
".",
"dirOps",
"[",
":",
"len",
"(",
"fbo",
".",
"dirOps",
")",
"-",
"1",
"]",
"\n",
"if",
"undoFn",
"!=",
"nil",
"{",
"undoFn",
"(",
"lState",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"// It's safe to notify before we've synced, since it is only",
"// sending invalidation notifications. At worst the upper layer",
"// will just have to refresh its cache needlessly.",
"err",
"=",
"fbo",
".",
"notifyOneOp",
"(",
"ctx",
",",
"lState",
",",
"op",
",",
"md",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"fbo",
".",
"syncDirUpdateOrSignal",
"(",
"ctx",
",",
"lState",
")",
"\n",
"}"
] | // notifyAndSyncOrSignal caches an op in memory and dirties the
// relevant node, and then sends a notification for it. If batching
// is on, it signals the write; otherwise it syncs the change. It
// should only be called as the final instruction that can fail in a
// method. | [
"notifyAndSyncOrSignal",
"caches",
"an",
"op",
"in",
"memory",
"and",
"dirties",
"the",
"relevant",
"node",
"and",
"then",
"sends",
"a",
"notification",
"for",
"it",
".",
"If",
"batching",
"is",
"on",
"it",
"signals",
"the",
"write",
";",
"otherwise",
"it",
"syncs",
"the",
"change",
".",
"It",
"should",
"only",
"be",
"called",
"as",
"the",
"final",
"instruction",
"that",
"can",
"fail",
"in",
"a",
"method",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L4548-L4581 |
161,437 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | unrefEntryLocked | func (fbo *folderBranchOps) unrefEntryLocked(ctx context.Context,
lState *kbfssync.LockState, kmd libkey.KeyMetadata, ro op, dir data.Path, de data.DirEntry,
name string) error {
fbo.mdWriterLock.AssertLocked(lState)
if de.Type == data.Sym {
return nil
}
unrefsToAdd := make(map[data.BlockPointer]bool)
fbo.prepper.cacheBlockInfos([]data.BlockInfo{de.BlockInfo})
unrefsToAdd[de.BlockPointer] = true
// construct a path for the child so we can unlink with it.
childPath := dir.ChildPath(name, de.BlockPointer)
// If this is an indirect block, we need to delete all of its
// children as well. NOTE: non-empty directories can't be
// removed, so no need to check for indirect directory blocks
// here.
if de.Type == data.File || de.Type == data.Exec {
blockInfos, err := fbo.blocks.GetIndirectFileBlockInfos(
ctx, lState, kmd, childPath)
if isRecoverableBlockErrorForRemoval(err) {
msg := fmt.Sprintf("Recoverable block error encountered for unrefEntry(%v); continuing", childPath)
fbo.log.CWarningf(ctx, "%s", msg)
fbo.log.CDebugf(ctx, "%s (err=%v)", msg, err)
} else if err != nil {
return err
}
fbo.prepper.cacheBlockInfos(blockInfos)
for _, blockInfo := range blockInfos {
unrefsToAdd[blockInfo.BlockPointer] = true
}
}
// Any referenced blocks that were unreferenced since the last
// sync can just be forgotten about. Note that any updated
// pointers that are unreferenced will be fixed up during syncing.
for _, dirOp := range fbo.dirOps {
for i := len(dirOp.dirOp.Refs()) - 1; i >= 0; i-- {
ref := dirOp.dirOp.Refs()[i]
if _, ok := unrefsToAdd[ref]; ok {
dirOp.dirOp.DelRefBlock(ref)
delete(unrefsToAdd, ref)
}
}
}
for unref := range unrefsToAdd {
ro.AddUnrefBlock(unref)
}
return nil
} | go | func (fbo *folderBranchOps) unrefEntryLocked(ctx context.Context,
lState *kbfssync.LockState, kmd libkey.KeyMetadata, ro op, dir data.Path, de data.DirEntry,
name string) error {
fbo.mdWriterLock.AssertLocked(lState)
if de.Type == data.Sym {
return nil
}
unrefsToAdd := make(map[data.BlockPointer]bool)
fbo.prepper.cacheBlockInfos([]data.BlockInfo{de.BlockInfo})
unrefsToAdd[de.BlockPointer] = true
// construct a path for the child so we can unlink with it.
childPath := dir.ChildPath(name, de.BlockPointer)
// If this is an indirect block, we need to delete all of its
// children as well. NOTE: non-empty directories can't be
// removed, so no need to check for indirect directory blocks
// here.
if de.Type == data.File || de.Type == data.Exec {
blockInfos, err := fbo.blocks.GetIndirectFileBlockInfos(
ctx, lState, kmd, childPath)
if isRecoverableBlockErrorForRemoval(err) {
msg := fmt.Sprintf("Recoverable block error encountered for unrefEntry(%v); continuing", childPath)
fbo.log.CWarningf(ctx, "%s", msg)
fbo.log.CDebugf(ctx, "%s (err=%v)", msg, err)
} else if err != nil {
return err
}
fbo.prepper.cacheBlockInfos(blockInfos)
for _, blockInfo := range blockInfos {
unrefsToAdd[blockInfo.BlockPointer] = true
}
}
// Any referenced blocks that were unreferenced since the last
// sync can just be forgotten about. Note that any updated
// pointers that are unreferenced will be fixed up during syncing.
for _, dirOp := range fbo.dirOps {
for i := len(dirOp.dirOp.Refs()) - 1; i >= 0; i-- {
ref := dirOp.dirOp.Refs()[i]
if _, ok := unrefsToAdd[ref]; ok {
dirOp.dirOp.DelRefBlock(ref)
delete(unrefsToAdd, ref)
}
}
}
for unref := range unrefsToAdd {
ro.AddUnrefBlock(unref)
}
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"unrefEntryLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"kmd",
"libkey",
".",
"KeyMetadata",
",",
"ro",
"op",
",",
"dir",
"data",
".",
"Path",
",",
"de",
"data",
".",
"DirEntry",
",",
"name",
"string",
")",
"error",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n",
"if",
"de",
".",
"Type",
"==",
"data",
".",
"Sym",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"unrefsToAdd",
":=",
"make",
"(",
"map",
"[",
"data",
".",
"BlockPointer",
"]",
"bool",
")",
"\n",
"fbo",
".",
"prepper",
".",
"cacheBlockInfos",
"(",
"[",
"]",
"data",
".",
"BlockInfo",
"{",
"de",
".",
"BlockInfo",
"}",
")",
"\n",
"unrefsToAdd",
"[",
"de",
".",
"BlockPointer",
"]",
"=",
"true",
"\n",
"// construct a path for the child so we can unlink with it.",
"childPath",
":=",
"dir",
".",
"ChildPath",
"(",
"name",
",",
"de",
".",
"BlockPointer",
")",
"\n\n",
"// If this is an indirect block, we need to delete all of its",
"// children as well. NOTE: non-empty directories can't be",
"// removed, so no need to check for indirect directory blocks",
"// here.",
"if",
"de",
".",
"Type",
"==",
"data",
".",
"File",
"||",
"de",
".",
"Type",
"==",
"data",
".",
"Exec",
"{",
"blockInfos",
",",
"err",
":=",
"fbo",
".",
"blocks",
".",
"GetIndirectFileBlockInfos",
"(",
"ctx",
",",
"lState",
",",
"kmd",
",",
"childPath",
")",
"\n",
"if",
"isRecoverableBlockErrorForRemoval",
"(",
"err",
")",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"childPath",
")",
"\n",
"fbo",
".",
"log",
".",
"CWarningf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"msg",
")",
"\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"msg",
",",
"err",
")",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"fbo",
".",
"prepper",
".",
"cacheBlockInfos",
"(",
"blockInfos",
")",
"\n",
"for",
"_",
",",
"blockInfo",
":=",
"range",
"blockInfos",
"{",
"unrefsToAdd",
"[",
"blockInfo",
".",
"BlockPointer",
"]",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Any referenced blocks that were unreferenced since the last",
"// sync can just be forgotten about. Note that any updated",
"// pointers that are unreferenced will be fixed up during syncing.",
"for",
"_",
",",
"dirOp",
":=",
"range",
"fbo",
".",
"dirOps",
"{",
"for",
"i",
":=",
"len",
"(",
"dirOp",
".",
"dirOp",
".",
"Refs",
"(",
")",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"ref",
":=",
"dirOp",
".",
"dirOp",
".",
"Refs",
"(",
")",
"[",
"i",
"]",
"\n",
"if",
"_",
",",
"ok",
":=",
"unrefsToAdd",
"[",
"ref",
"]",
";",
"ok",
"{",
"dirOp",
".",
"dirOp",
".",
"DelRefBlock",
"(",
"ref",
")",
"\n",
"delete",
"(",
"unrefsToAdd",
",",
"ref",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"unref",
":=",
"range",
"unrefsToAdd",
"{",
"ro",
".",
"AddUnrefBlock",
"(",
"unref",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // unrefEntry modifies md to unreference all relevant blocks for the
// given entry. | [
"unrefEntry",
"modifies",
"md",
"to",
"unreference",
"all",
"relevant",
"blocks",
"for",
"the",
"given",
"entry",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L4694-L4745 |
161,438 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | SyncAll | func (fbo *folderBranchOps) SyncAll(
ctx context.Context, folderBranch data.FolderBranch) (err error) {
startTime, timer := fbo.startOp(ctx, "SyncAll")
defer func() {
fbo.endOp(ctx, startTime, timer, "SyncAll done: %+v", err)
}()
if folderBranch != fbo.folderBranch {
return WrongOpsError{fbo.folderBranch, folderBranch}
}
return fbo.doMDWriteWithRetryUnlessCanceled(ctx,
func(lState *kbfssync.LockState) error {
return fbo.syncAllLocked(ctx, lState, NoExcl)
})
} | go | func (fbo *folderBranchOps) SyncAll(
ctx context.Context, folderBranch data.FolderBranch) (err error) {
startTime, timer := fbo.startOp(ctx, "SyncAll")
defer func() {
fbo.endOp(ctx, startTime, timer, "SyncAll done: %+v", err)
}()
if folderBranch != fbo.folderBranch {
return WrongOpsError{fbo.folderBranch, folderBranch}
}
return fbo.doMDWriteWithRetryUnlessCanceled(ctx,
func(lState *kbfssync.LockState) error {
return fbo.syncAllLocked(ctx, lState, NoExcl)
})
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"SyncAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"folderBranch",
"data",
".",
"FolderBranch",
")",
"(",
"err",
"error",
")",
"{",
"startTime",
",",
"timer",
":=",
"fbo",
".",
"startOp",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fbo",
".",
"endOp",
"(",
"ctx",
",",
"startTime",
",",
"timer",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"if",
"folderBranch",
"!=",
"fbo",
".",
"folderBranch",
"{",
"return",
"WrongOpsError",
"{",
"fbo",
".",
"folderBranch",
",",
"folderBranch",
"}",
"\n",
"}",
"\n\n",
"return",
"fbo",
".",
"doMDWriteWithRetryUnlessCanceled",
"(",
"ctx",
",",
"func",
"(",
"lState",
"*",
"kbfssync",
".",
"LockState",
")",
"error",
"{",
"return",
"fbo",
".",
"syncAllLocked",
"(",
"ctx",
",",
"lState",
",",
"NoExcl",
")",
"\n",
"}",
")",
"\n",
"}"
] | // SyncAll implements the KBFSOps interface for folderBranchOps. | [
"SyncAll",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L5931-L5946 |
161,439 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | notifyBatchLocked | func (fbo *folderBranchOps) notifyBatchLocked(
ctx context.Context, lState *kbfssync.LockState,
md ImmutableRootMetadata) error {
fbo.headLock.AssertLocked(lState)
for _, op := range md.data.Changes.Ops {
err := fbo.notifyOneOpLocked(ctx, lState, op, md.ReadOnly(), false)
if err != nil {
return err
}
}
return nil
} | go | func (fbo *folderBranchOps) notifyBatchLocked(
ctx context.Context, lState *kbfssync.LockState,
md ImmutableRootMetadata) error {
fbo.headLock.AssertLocked(lState)
for _, op := range md.data.Changes.Ops {
err := fbo.notifyOneOpLocked(ctx, lState, op, md.ReadOnly(), false)
if err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"notifyBatchLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"ImmutableRootMetadata",
")",
"error",
"{",
"fbo",
".",
"headLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n\n",
"for",
"_",
",",
"op",
":=",
"range",
"md",
".",
"data",
".",
"Changes",
".",
"Ops",
"{",
"err",
":=",
"fbo",
".",
"notifyOneOpLocked",
"(",
"ctx",
",",
"lState",
",",
"op",
",",
"md",
".",
"ReadOnly",
"(",
")",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // notifyBatchLocked sends out a notification for all the ops in md. | [
"notifyBatchLocked",
"sends",
"out",
"a",
"notification",
"for",
"all",
"the",
"ops",
"in",
"md",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L5987-L5999 |
161,440 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | searchForNode | func (fbo *folderBranchOps) searchForNode(ctx context.Context,
ptr data.BlockPointer, md ReadOnlyRootMetadata) (Node, error) {
// Record which pointers are new to this update, and thus worth
// searching.
newPtrs := make(map[data.BlockPointer]bool)
for _, op := range md.data.Changes.Ops {
for _, update := range op.allUpdates() {
newPtrs[update.Ref] = true
}
for _, ref := range op.Refs() {
newPtrs[ref] = true
}
}
nodeMap, _, err := fbo.blocks.SearchForNodes(ctx, fbo.nodeCache,
[]data.BlockPointer{ptr}, newPtrs, md, md.data.Dir.BlockPointer)
if err != nil {
return nil, err
}
n, ok := nodeMap[ptr]
if !ok {
return nil, NodeNotFoundError{ptr}
}
return n, nil
} | go | func (fbo *folderBranchOps) searchForNode(ctx context.Context,
ptr data.BlockPointer, md ReadOnlyRootMetadata) (Node, error) {
// Record which pointers are new to this update, and thus worth
// searching.
newPtrs := make(map[data.BlockPointer]bool)
for _, op := range md.data.Changes.Ops {
for _, update := range op.allUpdates() {
newPtrs[update.Ref] = true
}
for _, ref := range op.Refs() {
newPtrs[ref] = true
}
}
nodeMap, _, err := fbo.blocks.SearchForNodes(ctx, fbo.nodeCache,
[]data.BlockPointer{ptr}, newPtrs, md, md.data.Dir.BlockPointer)
if err != nil {
return nil, err
}
n, ok := nodeMap[ptr]
if !ok {
return nil, NodeNotFoundError{ptr}
}
return n, nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"searchForNode",
"(",
"ctx",
"context",
".",
"Context",
",",
"ptr",
"data",
".",
"BlockPointer",
",",
"md",
"ReadOnlyRootMetadata",
")",
"(",
"Node",
",",
"error",
")",
"{",
"// Record which pointers are new to this update, and thus worth",
"// searching.",
"newPtrs",
":=",
"make",
"(",
"map",
"[",
"data",
".",
"BlockPointer",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"op",
":=",
"range",
"md",
".",
"data",
".",
"Changes",
".",
"Ops",
"{",
"for",
"_",
",",
"update",
":=",
"range",
"op",
".",
"allUpdates",
"(",
")",
"{",
"newPtrs",
"[",
"update",
".",
"Ref",
"]",
"=",
"true",
"\n",
"}",
"\n",
"for",
"_",
",",
"ref",
":=",
"range",
"op",
".",
"Refs",
"(",
")",
"{",
"newPtrs",
"[",
"ref",
"]",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"nodeMap",
",",
"_",
",",
"err",
":=",
"fbo",
".",
"blocks",
".",
"SearchForNodes",
"(",
"ctx",
",",
"fbo",
".",
"nodeCache",
",",
"[",
"]",
"data",
".",
"BlockPointer",
"{",
"ptr",
"}",
",",
"newPtrs",
",",
"md",
",",
"md",
".",
"data",
".",
"Dir",
".",
"BlockPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"n",
",",
"ok",
":=",
"nodeMap",
"[",
"ptr",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"NodeNotFoundError",
"{",
"ptr",
"}",
"\n",
"}",
"\n\n",
"return",
"n",
",",
"nil",
"\n",
"}"
] | // searchForNode tries to figure out the path to the given
// blockPointer, using only the block updates that happened as part of
// a given MD update operation. | [
"searchForNode",
"tries",
"to",
"figure",
"out",
"the",
"path",
"to",
"the",
"given",
"blockPointer",
"using",
"only",
"the",
"block",
"updates",
"that",
"happened",
"as",
"part",
"of",
"a",
"given",
"MD",
"update",
"operation",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L6004-L6030 |
161,441 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | getAndApplyMDUpdates | func (fbo *folderBranchOps) getAndApplyMDUpdates(ctx context.Context,
lState *kbfssync.LockState, lockBeforeGet *keybase1.LockID,
applyFunc applyMDUpdatesFunc) error {
// first look up all MD revisions newer than my current head
start := fbo.getLatestMergedRevision(lState) + 1
rmds, err := getMergedMDUpdates(ctx,
fbo.config, fbo.id(), start, lockBeforeGet)
if err != nil {
return err
}
err = applyFunc(ctx, lState, rmds)
if err != nil {
return err
}
return nil
} | go | func (fbo *folderBranchOps) getAndApplyMDUpdates(ctx context.Context,
lState *kbfssync.LockState, lockBeforeGet *keybase1.LockID,
applyFunc applyMDUpdatesFunc) error {
// first look up all MD revisions newer than my current head
start := fbo.getLatestMergedRevision(lState) + 1
rmds, err := getMergedMDUpdates(ctx,
fbo.config, fbo.id(), start, lockBeforeGet)
if err != nil {
return err
}
err = applyFunc(ctx, lState, rmds)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"getAndApplyMDUpdates",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"lockBeforeGet",
"*",
"keybase1",
".",
"LockID",
",",
"applyFunc",
"applyMDUpdatesFunc",
")",
"error",
"{",
"// first look up all MD revisions newer than my current head",
"start",
":=",
"fbo",
".",
"getLatestMergedRevision",
"(",
"lState",
")",
"+",
"1",
"\n",
"rmds",
",",
"err",
":=",
"getMergedMDUpdates",
"(",
"ctx",
",",
"fbo",
".",
"config",
",",
"fbo",
".",
"id",
"(",
")",
",",
"start",
",",
"lockBeforeGet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"applyFunc",
"(",
"ctx",
",",
"lState",
",",
"rmds",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Assumes all necessary locking is either already done by caller, or
// is done by applyFunc. | [
"Assumes",
"all",
"necessary",
"locking",
"is",
"either",
"already",
"done",
"by",
"caller",
"or",
"is",
"done",
"by",
"applyFunc",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L6635-L6651 |
161,442 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | getUnmergedMDUpdates | func (fbo *folderBranchOps) getUnmergedMDUpdates(
ctx context.Context, lState *kbfssync.LockState) (
kbfsmd.Revision, []ImmutableRootMetadata, error) {
// acquire mdWriterLock to read the current branch ID.
unmergedBID := func() kbfsmd.BranchID {
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.unmergedBID
}()
return getUnmergedMDUpdates(ctx, fbo.config, fbo.id(),
unmergedBID, fbo.getCurrMDRevision(lState))
} | go | func (fbo *folderBranchOps) getUnmergedMDUpdates(
ctx context.Context, lState *kbfssync.LockState) (
kbfsmd.Revision, []ImmutableRootMetadata, error) {
// acquire mdWriterLock to read the current branch ID.
unmergedBID := func() kbfsmd.BranchID {
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.unmergedBID
}()
return getUnmergedMDUpdates(ctx, fbo.config, fbo.id(),
unmergedBID, fbo.getCurrMDRevision(lState))
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"getUnmergedMDUpdates",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
")",
"(",
"kbfsmd",
".",
"Revision",
",",
"[",
"]",
"ImmutableRootMetadata",
",",
"error",
")",
"{",
"// acquire mdWriterLock to read the current branch ID.",
"unmergedBID",
":=",
"func",
"(",
")",
"kbfsmd",
".",
"BranchID",
"{",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"return",
"fbo",
".",
"unmergedBID",
"\n",
"}",
"(",
")",
"\n",
"return",
"getUnmergedMDUpdates",
"(",
"ctx",
",",
"fbo",
".",
"config",
",",
"fbo",
".",
"id",
"(",
")",
",",
"unmergedBID",
",",
"fbo",
".",
"getCurrMDRevision",
"(",
"lState",
")",
")",
"\n",
"}"
] | // getUnmergedMDUpdates returns a slice of the unmerged MDs for this
// TLF's current unmerged branch and unmerged branch, between the
// merge point for the branch and the current head. The returned MDs
// are the same instances that are stored in the MD cache, so they
// should be modified with care. | [
"getUnmergedMDUpdates",
"returns",
"a",
"slice",
"of",
"the",
"unmerged",
"MDs",
"for",
"this",
"TLF",
"s",
"current",
"unmerged",
"branch",
"and",
"unmerged",
"branch",
"between",
"the",
"merge",
"point",
"for",
"the",
"branch",
"and",
"the",
"current",
"head",
".",
"The",
"returned",
"MDs",
"are",
"the",
"same",
"instances",
"that",
"are",
"stored",
"in",
"the",
"MD",
"cache",
"so",
"they",
"should",
"be",
"modified",
"with",
"care",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L6700-L6711 |
161,443 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | undoUnmergedMDUpdatesLocked | func (fbo *folderBranchOps) undoUnmergedMDUpdatesLocked(
ctx context.Context, lState *kbfssync.LockState) ([]data.BlockPointer, error) {
fbo.mdWriterLock.AssertLocked(lState)
currHead, unmergedRmds, err := fbo.getUnmergedMDUpdatesLocked(ctx, lState)
if err != nil {
return nil, err
}
err = fbo.undoMDUpdatesLocked(ctx, lState, unmergedRmds)
if err != nil {
return nil, err
}
// We have arrived at the branch point. The new root is
// the previous revision from the current head. Find it
// and apply. TODO: somehow fake the current head into
// being currHead-1, so that future calls to
// applyMDUpdates will fetch this along with the rest of
// the updates.
fbo.setBranchIDLocked(lState, kbfsmd.NullBranchID)
rmd, err := getSingleMD(ctx, fbo.config, fbo.id(), kbfsmd.NullBranchID,
currHead, kbfsmd.Merged, nil)
if err != nil {
return nil, err
}
err = func() error {
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
err = fbo.setHeadPredecessorLocked(ctx, lState, rmd)
if err != nil {
return err
}
fbo.setLatestMergedRevisionLocked(ctx, lState, rmd.Revision(), true)
return nil
}()
if err != nil {
return nil, err
}
// Return all new refs
var unmergedPtrs []data.BlockPointer
for _, rmd := range unmergedRmds {
for _, op := range rmd.data.Changes.Ops {
for _, ptr := range op.Refs() {
if ptr != data.ZeroPtr {
unflushed, err := fbo.config.BlockServer().IsUnflushed(
ctx, rmd.tlfHandle.TlfID(), ptr.ID)
if err != nil {
return nil, err
}
if !unflushed {
unmergedPtrs = append(unmergedPtrs, ptr)
}
}
}
for _, update := range op.allUpdates() {
if update.Ref != data.ZeroPtr {
unflushed, err := fbo.config.BlockServer().IsUnflushed(
ctx, rmd.tlfHandle.TlfID(), update.Ref.ID)
if err != nil {
return nil, err
}
if !unflushed {
unmergedPtrs = append(unmergedPtrs, update.Ref)
}
}
}
}
}
return unmergedPtrs, nil
} | go | func (fbo *folderBranchOps) undoUnmergedMDUpdatesLocked(
ctx context.Context, lState *kbfssync.LockState) ([]data.BlockPointer, error) {
fbo.mdWriterLock.AssertLocked(lState)
currHead, unmergedRmds, err := fbo.getUnmergedMDUpdatesLocked(ctx, lState)
if err != nil {
return nil, err
}
err = fbo.undoMDUpdatesLocked(ctx, lState, unmergedRmds)
if err != nil {
return nil, err
}
// We have arrived at the branch point. The new root is
// the previous revision from the current head. Find it
// and apply. TODO: somehow fake the current head into
// being currHead-1, so that future calls to
// applyMDUpdates will fetch this along with the rest of
// the updates.
fbo.setBranchIDLocked(lState, kbfsmd.NullBranchID)
rmd, err := getSingleMD(ctx, fbo.config, fbo.id(), kbfsmd.NullBranchID,
currHead, kbfsmd.Merged, nil)
if err != nil {
return nil, err
}
err = func() error {
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
err = fbo.setHeadPredecessorLocked(ctx, lState, rmd)
if err != nil {
return err
}
fbo.setLatestMergedRevisionLocked(ctx, lState, rmd.Revision(), true)
return nil
}()
if err != nil {
return nil, err
}
// Return all new refs
var unmergedPtrs []data.BlockPointer
for _, rmd := range unmergedRmds {
for _, op := range rmd.data.Changes.Ops {
for _, ptr := range op.Refs() {
if ptr != data.ZeroPtr {
unflushed, err := fbo.config.BlockServer().IsUnflushed(
ctx, rmd.tlfHandle.TlfID(), ptr.ID)
if err != nil {
return nil, err
}
if !unflushed {
unmergedPtrs = append(unmergedPtrs, ptr)
}
}
}
for _, update := range op.allUpdates() {
if update.Ref != data.ZeroPtr {
unflushed, err := fbo.config.BlockServer().IsUnflushed(
ctx, rmd.tlfHandle.TlfID(), update.Ref.ID)
if err != nil {
return nil, err
}
if !unflushed {
unmergedPtrs = append(unmergedPtrs, update.Ref)
}
}
}
}
}
return unmergedPtrs, nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"undoUnmergedMDUpdatesLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
")",
"(",
"[",
"]",
"data",
".",
"BlockPointer",
",",
"error",
")",
"{",
"fbo",
".",
"mdWriterLock",
".",
"AssertLocked",
"(",
"lState",
")",
"\n\n",
"currHead",
",",
"unmergedRmds",
",",
"err",
":=",
"fbo",
".",
"getUnmergedMDUpdatesLocked",
"(",
"ctx",
",",
"lState",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"fbo",
".",
"undoMDUpdatesLocked",
"(",
"ctx",
",",
"lState",
",",
"unmergedRmds",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// We have arrived at the branch point. The new root is",
"// the previous revision from the current head. Find it",
"// and apply. TODO: somehow fake the current head into",
"// being currHead-1, so that future calls to",
"// applyMDUpdates will fetch this along with the rest of",
"// the updates.",
"fbo",
".",
"setBranchIDLocked",
"(",
"lState",
",",
"kbfsmd",
".",
"NullBranchID",
")",
"\n\n",
"rmd",
",",
"err",
":=",
"getSingleMD",
"(",
"ctx",
",",
"fbo",
".",
"config",
",",
"fbo",
".",
"id",
"(",
")",
",",
"kbfsmd",
".",
"NullBranchID",
",",
"currHead",
",",
"kbfsmd",
".",
"Merged",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"fbo",
".",
"headLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"headLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"err",
"=",
"fbo",
".",
"setHeadPredecessorLocked",
"(",
"ctx",
",",
"lState",
",",
"rmd",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"fbo",
".",
"setLatestMergedRevisionLocked",
"(",
"ctx",
",",
"lState",
",",
"rmd",
".",
"Revision",
"(",
")",
",",
"true",
")",
"\n",
"return",
"nil",
"\n",
"}",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Return all new refs",
"var",
"unmergedPtrs",
"[",
"]",
"data",
".",
"BlockPointer",
"\n",
"for",
"_",
",",
"rmd",
":=",
"range",
"unmergedRmds",
"{",
"for",
"_",
",",
"op",
":=",
"range",
"rmd",
".",
"data",
".",
"Changes",
".",
"Ops",
"{",
"for",
"_",
",",
"ptr",
":=",
"range",
"op",
".",
"Refs",
"(",
")",
"{",
"if",
"ptr",
"!=",
"data",
".",
"ZeroPtr",
"{",
"unflushed",
",",
"err",
":=",
"fbo",
".",
"config",
".",
"BlockServer",
"(",
")",
".",
"IsUnflushed",
"(",
"ctx",
",",
"rmd",
".",
"tlfHandle",
".",
"TlfID",
"(",
")",
",",
"ptr",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"unflushed",
"{",
"unmergedPtrs",
"=",
"append",
"(",
"unmergedPtrs",
",",
"ptr",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"_",
",",
"update",
":=",
"range",
"op",
".",
"allUpdates",
"(",
")",
"{",
"if",
"update",
".",
"Ref",
"!=",
"data",
".",
"ZeroPtr",
"{",
"unflushed",
",",
"err",
":=",
"fbo",
".",
"config",
".",
"BlockServer",
"(",
")",
".",
"IsUnflushed",
"(",
"ctx",
",",
"rmd",
".",
"tlfHandle",
".",
"TlfID",
"(",
")",
",",
"update",
".",
"Ref",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"unflushed",
"{",
"unmergedPtrs",
"=",
"append",
"(",
"unmergedPtrs",
",",
"update",
".",
"Ref",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"unmergedPtrs",
",",
"nil",
"\n",
"}"
] | // Returns a list of block pointers that were created during the
// staged era. | [
"Returns",
"a",
"list",
"of",
"block",
"pointers",
"that",
"were",
"created",
"during",
"the",
"staged",
"era",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L6724-L6797 |
161,444 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | finalizeResolution | func (fbo *folderBranchOps) finalizeResolution(ctx context.Context,
lState *kbfssync.LockState, md *RootMetadata, bps blockPutState,
newOps []op, blocksToDelete []kbfsblock.ID) error {
// Take the writer lock.
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.finalizeResolutionLocked(
ctx, lState, md, bps, newOps, blocksToDelete)
} | go | func (fbo *folderBranchOps) finalizeResolution(ctx context.Context,
lState *kbfssync.LockState, md *RootMetadata, bps blockPutState,
newOps []op, blocksToDelete []kbfsblock.ID) error {
// Take the writer lock.
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
return fbo.finalizeResolutionLocked(
ctx, lState, md, bps, newOps, blocksToDelete)
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"finalizeResolution",
"(",
"ctx",
"context",
".",
"Context",
",",
"lState",
"*",
"kbfssync",
".",
"LockState",
",",
"md",
"*",
"RootMetadata",
",",
"bps",
"blockPutState",
",",
"newOps",
"[",
"]",
"op",
",",
"blocksToDelete",
"[",
"]",
"kbfsblock",
".",
"ID",
")",
"error",
"{",
"// Take the writer lock.",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"return",
"fbo",
".",
"finalizeResolutionLocked",
"(",
"ctx",
",",
"lState",
",",
"md",
",",
"bps",
",",
"newOps",
",",
"blocksToDelete",
")",
"\n",
"}"
] | // finalizeResolution caches all the blocks, and writes the new MD to
// the merged branch, failing if there is a conflict. It also sends
// out the given newOps notifications locally. This is used for
// completing conflict resolution. | [
"finalizeResolution",
"caches",
"all",
"the",
"blocks",
"and",
"writes",
"the",
"new",
"MD",
"to",
"the",
"merged",
"branch",
"failing",
"if",
"there",
"is",
"a",
"conflict",
".",
"It",
"also",
"sends",
"out",
"the",
"given",
"newOps",
"notifications",
"locally",
".",
"This",
"is",
"used",
"for",
"completing",
"conflict",
"resolution",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L7857-L7865 |
161,445 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | TeamAbandoned | func (fbo *folderBranchOps) TeamAbandoned(
ctx context.Context, tid keybase1.TeamID) {
ctx, cancelFunc := fbo.newCtxWithFBOID()
defer cancelFunc()
fbo.log.CDebugf(ctx, "Abandoning team %s", tid)
fbo.locallyFinalizeTLF(ctx)
} | go | func (fbo *folderBranchOps) TeamAbandoned(
ctx context.Context, tid keybase1.TeamID) {
ctx, cancelFunc := fbo.newCtxWithFBOID()
defer cancelFunc()
fbo.log.CDebugf(ctx, "Abandoning team %s", tid)
fbo.locallyFinalizeTLF(ctx)
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"TeamAbandoned",
"(",
"ctx",
"context",
".",
"Context",
",",
"tid",
"keybase1",
".",
"TeamID",
")",
"{",
"ctx",
",",
"cancelFunc",
":=",
"fbo",
".",
"newCtxWithFBOID",
"(",
")",
"\n",
"defer",
"cancelFunc",
"(",
")",
"\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"tid",
")",
"\n",
"fbo",
".",
"locallyFinalizeTLF",
"(",
"ctx",
")",
"\n",
"}"
] | // TeamAbandoned implements the KBFSOps interface for folderBranchOps. | [
"TeamAbandoned",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8106-L8112 |
161,446 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | MigrateToImplicitTeam | func (fbo *folderBranchOps) MigrateToImplicitTeam(
ctx context.Context, id tlf.ID) (err error) {
// Only MasterBranch FBOs may be migrated.
fb := data.FolderBranch{Tlf: id, Branch: data.MasterBranch}
if fb != fbo.folderBranch {
// TODO: log instead of panic?
panic(WrongOpsError{fbo.folderBranch, fb})
}
fbo.log.CDebugf(ctx, "Starting migration of TLF %s", id)
defer func() {
fbo.log.CDebugf(ctx, "Finished migration of TLF %s, err=%+v", id, err)
}()
if id.Type() != tlf.Private && id.Type() != tlf.Public {
return errors.Errorf("Cannot migrate a TLF of type: %s", id.Type())
}
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
md, err := fbo.getMDForMigrationLocked(ctx, lState)
if err != nil {
return err
}
if md == (ImmutableRootMetadata{}) {
fbo.log.CDebugf(ctx, "Nothing to upgrade")
return nil
}
if md.IsFinal() {
fbo.log.CDebugf(ctx, "No need to upgrade a finalized TLF")
return nil
}
if md.TypeForKeying() == tlf.TeamKeying {
fbo.log.CDebugf(ctx, "Already migrated")
return nil
}
name := string(md.GetTlfHandle().GetCanonicalName())
fbo.log.CDebugf(ctx, "Looking up implicit team for %s", name)
newHandle, err := tlfhandle.ParseHandle(
ctx, fbo.config.KBPKI(), fbo.config.MDOps(), fbo.config,
name, id.Type())
if err != nil {
return err
}
// Make sure the new handle contains just a team.
if newHandle.TypeForKeying() != tlf.TeamKeying {
return errors.New("No corresponding implicit team yet")
}
session, err := fbo.config.KBPKI().GetCurrentSession(ctx)
if err != nil {
return err
}
isWriter := true // getMDForMigrationLocked already checked this.
newMD, err := md.MakeSuccessorWithNewHandle(
ctx, newHandle, fbo.config.MetadataVersion(), fbo.config.Codec(),
fbo.config.KeyManager(), fbo.config.KBPKI(), fbo.config.KBPKI(),
fbo.config, md.mdID, isWriter)
if err != nil {
return err
}
if newMD.TypeForKeying() != tlf.TeamKeying {
return errors.New("Migration failed")
}
// Add an empty operation to satisfy assumptions elsewhere.
newMD.AddOp(newRekeyOp())
return fbo.finalizeMDRekeyWriteLocked(
ctx, lState, newMD, session.VerifyingKey)
} | go | func (fbo *folderBranchOps) MigrateToImplicitTeam(
ctx context.Context, id tlf.ID) (err error) {
// Only MasterBranch FBOs may be migrated.
fb := data.FolderBranch{Tlf: id, Branch: data.MasterBranch}
if fb != fbo.folderBranch {
// TODO: log instead of panic?
panic(WrongOpsError{fbo.folderBranch, fb})
}
fbo.log.CDebugf(ctx, "Starting migration of TLF %s", id)
defer func() {
fbo.log.CDebugf(ctx, "Finished migration of TLF %s, err=%+v", id, err)
}()
if id.Type() != tlf.Private && id.Type() != tlf.Public {
return errors.Errorf("Cannot migrate a TLF of type: %s", id.Type())
}
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
md, err := fbo.getMDForMigrationLocked(ctx, lState)
if err != nil {
return err
}
if md == (ImmutableRootMetadata{}) {
fbo.log.CDebugf(ctx, "Nothing to upgrade")
return nil
}
if md.IsFinal() {
fbo.log.CDebugf(ctx, "No need to upgrade a finalized TLF")
return nil
}
if md.TypeForKeying() == tlf.TeamKeying {
fbo.log.CDebugf(ctx, "Already migrated")
return nil
}
name := string(md.GetTlfHandle().GetCanonicalName())
fbo.log.CDebugf(ctx, "Looking up implicit team for %s", name)
newHandle, err := tlfhandle.ParseHandle(
ctx, fbo.config.KBPKI(), fbo.config.MDOps(), fbo.config,
name, id.Type())
if err != nil {
return err
}
// Make sure the new handle contains just a team.
if newHandle.TypeForKeying() != tlf.TeamKeying {
return errors.New("No corresponding implicit team yet")
}
session, err := fbo.config.KBPKI().GetCurrentSession(ctx)
if err != nil {
return err
}
isWriter := true // getMDForMigrationLocked already checked this.
newMD, err := md.MakeSuccessorWithNewHandle(
ctx, newHandle, fbo.config.MetadataVersion(), fbo.config.Codec(),
fbo.config.KeyManager(), fbo.config.KBPKI(), fbo.config.KBPKI(),
fbo.config, md.mdID, isWriter)
if err != nil {
return err
}
if newMD.TypeForKeying() != tlf.TeamKeying {
return errors.New("Migration failed")
}
// Add an empty operation to satisfy assumptions elsewhere.
newMD.AddOp(newRekeyOp())
return fbo.finalizeMDRekeyWriteLocked(
ctx, lState, newMD, session.VerifyingKey)
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"MigrateToImplicitTeam",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"tlf",
".",
"ID",
")",
"(",
"err",
"error",
")",
"{",
"// Only MasterBranch FBOs may be migrated.",
"fb",
":=",
"data",
".",
"FolderBranch",
"{",
"Tlf",
":",
"id",
",",
"Branch",
":",
"data",
".",
"MasterBranch",
"}",
"\n",
"if",
"fb",
"!=",
"fbo",
".",
"folderBranch",
"{",
"// TODO: log instead of panic?",
"panic",
"(",
"WrongOpsError",
"{",
"fbo",
".",
"folderBranch",
",",
"fb",
"}",
")",
"\n",
"}",
"\n\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"id",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"if",
"id",
".",
"Type",
"(",
")",
"!=",
"tlf",
".",
"Private",
"&&",
"id",
".",
"Type",
"(",
")",
"!=",
"tlf",
".",
"Public",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"id",
".",
"Type",
"(",
")",
")",
"\n",
"}",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n\n",
"md",
",",
"err",
":=",
"fbo",
".",
"getMDForMigrationLocked",
"(",
"ctx",
",",
"lState",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"md",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"md",
".",
"IsFinal",
"(",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"md",
".",
"TypeForKeying",
"(",
")",
"==",
"tlf",
".",
"TeamKeying",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"name",
":=",
"string",
"(",
"md",
".",
"GetTlfHandle",
"(",
")",
".",
"GetCanonicalName",
"(",
")",
")",
"\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"newHandle",
",",
"err",
":=",
"tlfhandle",
".",
"ParseHandle",
"(",
"ctx",
",",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"fbo",
".",
"config",
".",
"MDOps",
"(",
")",
",",
"fbo",
".",
"config",
",",
"name",
",",
"id",
".",
"Type",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Make sure the new handle contains just a team.",
"if",
"newHandle",
".",
"TypeForKeying",
"(",
")",
"!=",
"tlf",
".",
"TeamKeying",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"session",
",",
"err",
":=",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
".",
"GetCurrentSession",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"isWriter",
":=",
"true",
"// getMDForMigrationLocked already checked this.",
"\n",
"newMD",
",",
"err",
":=",
"md",
".",
"MakeSuccessorWithNewHandle",
"(",
"ctx",
",",
"newHandle",
",",
"fbo",
".",
"config",
".",
"MetadataVersion",
"(",
")",
",",
"fbo",
".",
"config",
".",
"Codec",
"(",
")",
",",
"fbo",
".",
"config",
".",
"KeyManager",
"(",
")",
",",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"fbo",
".",
"config",
".",
"KBPKI",
"(",
")",
",",
"fbo",
".",
"config",
",",
"md",
".",
"mdID",
",",
"isWriter",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"newMD",
".",
"TypeForKeying",
"(",
")",
"!=",
"tlf",
".",
"TeamKeying",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Add an empty operation to satisfy assumptions elsewhere.",
"newMD",
".",
"AddOp",
"(",
"newRekeyOp",
"(",
")",
")",
"\n\n",
"return",
"fbo",
".",
"finalizeMDRekeyWriteLocked",
"(",
"ctx",
",",
"lState",
",",
"newMD",
",",
"session",
".",
"VerifyingKey",
")",
"\n",
"}"
] | // MigrateToImplicitTeam implements the KBFSOps interface for folderBranchOps. | [
"MigrateToImplicitTeam",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8143-L8222 |
161,447 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | GetEditHistory | func (fbo *folderBranchOps) GetEditHistory(
ctx context.Context, _ data.FolderBranch) (
tlfHistory keybase1.FSFolderEditHistory, err error) {
// Wait for any outstanding edit requests.
if err := fbo.editActivity.Wait(ctx); err != nil {
return keybase1.FSFolderEditHistory{}, err
}
lState := makeFBOLockState()
md, _ := fbo.getHead(ctx, lState, mdNoCommit)
name := md.GetTlfHandle().GetCanonicalName()
return fbo.config.UserHistory().GetTlfHistory(name, fbo.id().Type()), nil
} | go | func (fbo *folderBranchOps) GetEditHistory(
ctx context.Context, _ data.FolderBranch) (
tlfHistory keybase1.FSFolderEditHistory, err error) {
// Wait for any outstanding edit requests.
if err := fbo.editActivity.Wait(ctx); err != nil {
return keybase1.FSFolderEditHistory{}, err
}
lState := makeFBOLockState()
md, _ := fbo.getHead(ctx, lState, mdNoCommit)
name := md.GetTlfHandle().GetCanonicalName()
return fbo.config.UserHistory().GetTlfHistory(name, fbo.id().Type()), nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"GetEditHistory",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"data",
".",
"FolderBranch",
")",
"(",
"tlfHistory",
"keybase1",
".",
"FSFolderEditHistory",
",",
"err",
"error",
")",
"{",
"// Wait for any outstanding edit requests.",
"if",
"err",
":=",
"fbo",
".",
"editActivity",
".",
"Wait",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"FSFolderEditHistory",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"md",
",",
"_",
":=",
"fbo",
".",
"getHead",
"(",
"ctx",
",",
"lState",
",",
"mdNoCommit",
")",
"\n",
"name",
":=",
"md",
".",
"GetTlfHandle",
"(",
")",
".",
"GetCanonicalName",
"(",
")",
"\n",
"return",
"fbo",
".",
"config",
".",
"UserHistory",
"(",
")",
".",
"GetTlfHistory",
"(",
"name",
",",
"fbo",
".",
"id",
"(",
")",
".",
"Type",
"(",
")",
")",
",",
"nil",
"\n",
"}"
] | // GetEditHistory implements the KBFSOps interface for folderBranchOps | [
"GetEditHistory",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8291-L8303 |
161,448 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | ClearPrivateFolderMD | func (fbo *folderBranchOps) ClearPrivateFolderMD(ctx context.Context) {
func() {
// Cancel the edits goroutine and forget the old history, evem
// for public folders, since some of the state in the history
// is dependent on your login state.
fbo.editsLock.Lock()
defer fbo.editsLock.Unlock()
if fbo.cancelEdits != nil {
fbo.cancelEdits()
fbo.cancelEdits = nil
}
fbo.editHistory = kbfsedits.NewTlfHistory()
// Allow the edit monitor to be re-launched later whenever the
// MD is set again.
fbo.launchEditMonitor = sync.Once{}
fbo.convLock.Lock()
defer fbo.convLock.Unlock()
fbo.convID = nil
}()
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
fbo.blocks.ClearChargedTo(lState)
if fbo.folderBranch.Tlf.Type() == tlf.Public {
return
}
if fbo.head == (ImmutableRootMetadata{}) {
// Nothing to clear.
return
}
fbo.log.CDebugf(ctx, "Clearing folder MD")
// First cancel the background goroutine that's registered for
// updates, because the next time we set the head in this FBO
// we'll launch another one.
fbo.cancelUpdatesLock.Lock()
defer fbo.cancelUpdatesLock.Unlock()
if fbo.cancelUpdates != nil {
fbo.cancelUpdates()
select {
case <-fbo.updateDoneChan:
case <-ctx.Done():
fbo.log.CDebugf(
ctx, "Context canceled before updater was canceled")
return
}
fbo.config.MDServer().CancelRegistration(ctx, fbo.id())
}
fbo.head = ImmutableRootMetadata{}
fbo.headStatus = headUntrusted
fbo.latestMergedRevision = kbfsmd.RevisionUninitialized
fbo.hasBeenCleared = true
} | go | func (fbo *folderBranchOps) ClearPrivateFolderMD(ctx context.Context) {
func() {
// Cancel the edits goroutine and forget the old history, evem
// for public folders, since some of the state in the history
// is dependent on your login state.
fbo.editsLock.Lock()
defer fbo.editsLock.Unlock()
if fbo.cancelEdits != nil {
fbo.cancelEdits()
fbo.cancelEdits = nil
}
fbo.editHistory = kbfsedits.NewTlfHistory()
// Allow the edit monitor to be re-launched later whenever the
// MD is set again.
fbo.launchEditMonitor = sync.Once{}
fbo.convLock.Lock()
defer fbo.convLock.Unlock()
fbo.convID = nil
}()
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
fbo.blocks.ClearChargedTo(lState)
if fbo.folderBranch.Tlf.Type() == tlf.Public {
return
}
if fbo.head == (ImmutableRootMetadata{}) {
// Nothing to clear.
return
}
fbo.log.CDebugf(ctx, "Clearing folder MD")
// First cancel the background goroutine that's registered for
// updates, because the next time we set the head in this FBO
// we'll launch another one.
fbo.cancelUpdatesLock.Lock()
defer fbo.cancelUpdatesLock.Unlock()
if fbo.cancelUpdates != nil {
fbo.cancelUpdates()
select {
case <-fbo.updateDoneChan:
case <-ctx.Done():
fbo.log.CDebugf(
ctx, "Context canceled before updater was canceled")
return
}
fbo.config.MDServer().CancelRegistration(ctx, fbo.id())
}
fbo.head = ImmutableRootMetadata{}
fbo.headStatus = headUntrusted
fbo.latestMergedRevision = kbfsmd.RevisionUninitialized
fbo.hasBeenCleared = true
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"ClearPrivateFolderMD",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"func",
"(",
")",
"{",
"// Cancel the edits goroutine and forget the old history, evem",
"// for public folders, since some of the state in the history",
"// is dependent on your login state.",
"fbo",
".",
"editsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fbo",
".",
"editsLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"fbo",
".",
"cancelEdits",
"!=",
"nil",
"{",
"fbo",
".",
"cancelEdits",
"(",
")",
"\n",
"fbo",
".",
"cancelEdits",
"=",
"nil",
"\n",
"}",
"\n",
"fbo",
".",
"editHistory",
"=",
"kbfsedits",
".",
"NewTlfHistory",
"(",
")",
"\n",
"// Allow the edit monitor to be re-launched later whenever the",
"// MD is set again.",
"fbo",
".",
"launchEditMonitor",
"=",
"sync",
".",
"Once",
"{",
"}",
"\n",
"fbo",
".",
"convLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fbo",
".",
"convLock",
".",
"Unlock",
"(",
")",
"\n",
"fbo",
".",
"convID",
"=",
"nil",
"\n",
"}",
"(",
")",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"headLock",
".",
"Unlock",
"(",
"lState",
")",
"\n\n",
"fbo",
".",
"blocks",
".",
"ClearChargedTo",
"(",
"lState",
")",
"\n\n",
"if",
"fbo",
".",
"folderBranch",
".",
"Tlf",
".",
"Type",
"(",
")",
"==",
"tlf",
".",
"Public",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"fbo",
".",
"head",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"// Nothing to clear.",
"return",
"\n",
"}",
"\n\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n\n",
"// First cancel the background goroutine that's registered for",
"// updates, because the next time we set the head in this FBO",
"// we'll launch another one.",
"fbo",
".",
"cancelUpdatesLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fbo",
".",
"cancelUpdatesLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"fbo",
".",
"cancelUpdates",
"!=",
"nil",
"{",
"fbo",
".",
"cancelUpdates",
"(",
")",
"\n",
"select",
"{",
"case",
"<-",
"fbo",
".",
"updateDoneChan",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"fbo",
".",
"config",
".",
"MDServer",
"(",
")",
".",
"CancelRegistration",
"(",
"ctx",
",",
"fbo",
".",
"id",
"(",
")",
")",
"\n",
"}",
"\n\n",
"fbo",
".",
"head",
"=",
"ImmutableRootMetadata",
"{",
"}",
"\n",
"fbo",
".",
"headStatus",
"=",
"headUntrusted",
"\n",
"fbo",
".",
"latestMergedRevision",
"=",
"kbfsmd",
".",
"RevisionUninitialized",
"\n",
"fbo",
".",
"hasBeenCleared",
"=",
"true",
"\n",
"}"
] | // ClearPrivateFolderMD implements the KBFSOps interface for
// folderBranchOps. | [
"ClearPrivateFolderMD",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8312-L8372 |
161,449 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | ForceFastForward | func (fbo *folderBranchOps) ForceFastForward(ctx context.Context) {
lState := makeFBOLockState()
fbo.headLock.RLock(lState)
defer fbo.headLock.RUnlock(lState)
if fbo.head != (ImmutableRootMetadata{}) {
// We're already up to date.
return
}
if !fbo.hasBeenCleared {
// No reason to fast-forward here if it hasn't ever been
// cleared.
return
}
fbo.hasBeenCleared = false
fbo.forcedFastForwards.Add(1)
fbo.goTracked(func() {
defer fbo.forcedFastForwards.Done()
ctx, cancelFunc := fbo.newCtxWithFBOID()
defer cancelFunc()
fbo.log.CDebugf(ctx, "Forcing a fast-forward")
var currHead ImmutableRootMetadata
var err error
getMD:
for i := 0; ; i++ {
currHead, err = fbo.config.MDOps().GetForTLF(ctx, fbo.id(), nil)
switch errors.Cause(err).(type) {
case nil:
break getMD
case kbfsmd.ServerErrorUnauthorized:
// The MD server connection might not be authorized
// yet, so give it a few chances to go through.
if i > 5 {
fbo.log.CDebugf(ctx,
"Still unauthorized for TLF %s; giving up fast-forward",
fbo.id())
return
}
if i == 0 {
fbo.log.CDebugf(
ctx, "Got unauthorized error when fast-forwarding %s; "+
"trying again after a delay", fbo.id())
}
time.Sleep(1 * time.Second)
default:
fbo.log.CDebugf(ctx, "Fast-forward failed: %+v", err)
return
}
}
if currHead == (ImmutableRootMetadata{}) {
fbo.log.CDebugf(ctx, "No MD yet")
return
}
fbo.log.CDebugf(ctx, "Current head is revision %d", currHead.Revision())
lState := makeFBOLockState()
// Kick off partial prefetching once the latest merged
// revision is set.
defer func() {
if err == nil {
fbo.kickOffPartialSyncIfNeeded(ctx, lState, currHead)
}
}()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
if fbo.head != (ImmutableRootMetadata{}) {
// We're already up to date.
fbo.log.CDebugf(ctx, "Already up-to-date: %v", err)
return
}
err = fbo.doFastForwardLocked(ctx, lState, currHead)
if err != nil {
fbo.log.CDebugf(ctx, "Fast-forward failed: %v", err)
}
})
} | go | func (fbo *folderBranchOps) ForceFastForward(ctx context.Context) {
lState := makeFBOLockState()
fbo.headLock.RLock(lState)
defer fbo.headLock.RUnlock(lState)
if fbo.head != (ImmutableRootMetadata{}) {
// We're already up to date.
return
}
if !fbo.hasBeenCleared {
// No reason to fast-forward here if it hasn't ever been
// cleared.
return
}
fbo.hasBeenCleared = false
fbo.forcedFastForwards.Add(1)
fbo.goTracked(func() {
defer fbo.forcedFastForwards.Done()
ctx, cancelFunc := fbo.newCtxWithFBOID()
defer cancelFunc()
fbo.log.CDebugf(ctx, "Forcing a fast-forward")
var currHead ImmutableRootMetadata
var err error
getMD:
for i := 0; ; i++ {
currHead, err = fbo.config.MDOps().GetForTLF(ctx, fbo.id(), nil)
switch errors.Cause(err).(type) {
case nil:
break getMD
case kbfsmd.ServerErrorUnauthorized:
// The MD server connection might not be authorized
// yet, so give it a few chances to go through.
if i > 5 {
fbo.log.CDebugf(ctx,
"Still unauthorized for TLF %s; giving up fast-forward",
fbo.id())
return
}
if i == 0 {
fbo.log.CDebugf(
ctx, "Got unauthorized error when fast-forwarding %s; "+
"trying again after a delay", fbo.id())
}
time.Sleep(1 * time.Second)
default:
fbo.log.CDebugf(ctx, "Fast-forward failed: %+v", err)
return
}
}
if currHead == (ImmutableRootMetadata{}) {
fbo.log.CDebugf(ctx, "No MD yet")
return
}
fbo.log.CDebugf(ctx, "Current head is revision %d", currHead.Revision())
lState := makeFBOLockState()
// Kick off partial prefetching once the latest merged
// revision is set.
defer func() {
if err == nil {
fbo.kickOffPartialSyncIfNeeded(ctx, lState, currHead)
}
}()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
if fbo.head != (ImmutableRootMetadata{}) {
// We're already up to date.
fbo.log.CDebugf(ctx, "Already up-to-date: %v", err)
return
}
err = fbo.doFastForwardLocked(ctx, lState, currHead)
if err != nil {
fbo.log.CDebugf(ctx, "Fast-forward failed: %v", err)
}
})
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"ForceFastForward",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"fbo",
".",
"headLock",
".",
"RLock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"headLock",
".",
"RUnlock",
"(",
"lState",
")",
"\n",
"if",
"fbo",
".",
"head",
"!=",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"// We're already up to date.",
"return",
"\n",
"}",
"\n",
"if",
"!",
"fbo",
".",
"hasBeenCleared",
"{",
"// No reason to fast-forward here if it hasn't ever been",
"// cleared.",
"return",
"\n",
"}",
"\n",
"fbo",
".",
"hasBeenCleared",
"=",
"false",
"\n\n",
"fbo",
".",
"forcedFastForwards",
".",
"Add",
"(",
"1",
")",
"\n",
"fbo",
".",
"goTracked",
"(",
"func",
"(",
")",
"{",
"defer",
"fbo",
".",
"forcedFastForwards",
".",
"Done",
"(",
")",
"\n",
"ctx",
",",
"cancelFunc",
":=",
"fbo",
".",
"newCtxWithFBOID",
"(",
")",
"\n",
"defer",
"cancelFunc",
"(",
")",
"\n\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"var",
"currHead",
"ImmutableRootMetadata",
"\n",
"var",
"err",
"error",
"\n",
"getMD",
":",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"currHead",
",",
"err",
"=",
"fbo",
".",
"config",
".",
"MDOps",
"(",
")",
".",
"GetForTLF",
"(",
"ctx",
",",
"fbo",
".",
"id",
"(",
")",
",",
"nil",
")",
"\n",
"switch",
"errors",
".",
"Cause",
"(",
"err",
")",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",
"break",
"getMD",
"\n",
"case",
"kbfsmd",
".",
"ServerErrorUnauthorized",
":",
"// The MD server connection might not be authorized",
"// yet, so give it a few chances to go through.",
"if",
"i",
">",
"5",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"fbo",
".",
"id",
"(",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"i",
"==",
"0",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"fbo",
".",
"id",
"(",
")",
")",
"\n",
"}",
"\n",
"time",
".",
"Sleep",
"(",
"1",
"*",
"time",
".",
"Second",
")",
"\n",
"default",
":",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"currHead",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"currHead",
".",
"Revision",
"(",
")",
")",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"// Kick off partial prefetching once the latest merged",
"// revision is set.",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"fbo",
".",
"kickOffPartialSyncIfNeeded",
"(",
"ctx",
",",
"lState",
",",
"currHead",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"headLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"if",
"fbo",
".",
"head",
"!=",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"// We're already up to date.",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"err",
"=",
"fbo",
".",
"doFastForwardLocked",
"(",
"ctx",
",",
"lState",
",",
"currHead",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}"
] | // ForceFastForward implements the KBFSOps interface for
// folderBranchOps. | [
"ForceFastForward",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8376-L8456 |
161,450 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | Reset | func (fbo *folderBranchOps) Reset(
ctx context.Context, handle *tlfhandle.Handle) error {
currHandle, err := fbo.GetTLFHandle(ctx, nil)
if err != nil {
return err
}
equal, err := currHandle.Equals(fbo.config.Codec(), *handle)
if err != nil {
return err
}
if !equal {
return errors.Errorf("Can't reset %#v given bad handle %#v",
currHandle, handle)
}
oldHandle := handle.DeepCopy()
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
fbo.log.CDebugf(ctx, "Resetting")
changes, affectedNodeIDs, err := fbo.blocks.GetInvalidationChangesForAll(
ctx, lState)
if err != nil {
return err
}
// Invalidate all the affected nodes.
if len(changes) > 0 {
fbo.observers.batchChanges(ctx, changes, affectedNodeIDs)
}
// Make up a finalized name for the old handle, and broadcast it
// to all observers. This is to move it out of the way of the
// next iteration of the folder.
now := fbo.config.Clock().Now()
finalizedInfo, err := tlf.NewHandleExtension(
tlf.HandleExtensionFinalized, 1, kbname.NormalizedUsername("<unknown>"),
now)
if err != nil {
return err
}
oldHandle.SetFinalizedInfo(finalizedInfo)
// FIXME: This can't be subject to the WaitGroup due to a potential
// deadlock, so we use a raw goroutine here instead of `goTracked`.
go fbo.observers.tlfHandleChange(ctx, oldHandle)
return nil
} | go | func (fbo *folderBranchOps) Reset(
ctx context.Context, handle *tlfhandle.Handle) error {
currHandle, err := fbo.GetTLFHandle(ctx, nil)
if err != nil {
return err
}
equal, err := currHandle.Equals(fbo.config.Codec(), *handle)
if err != nil {
return err
}
if !equal {
return errors.Errorf("Can't reset %#v given bad handle %#v",
currHandle, handle)
}
oldHandle := handle.DeepCopy()
lState := makeFBOLockState()
fbo.mdWriterLock.Lock(lState)
defer fbo.mdWriterLock.Unlock(lState)
fbo.headLock.Lock(lState)
defer fbo.headLock.Unlock(lState)
fbo.log.CDebugf(ctx, "Resetting")
changes, affectedNodeIDs, err := fbo.blocks.GetInvalidationChangesForAll(
ctx, lState)
if err != nil {
return err
}
// Invalidate all the affected nodes.
if len(changes) > 0 {
fbo.observers.batchChanges(ctx, changes, affectedNodeIDs)
}
// Make up a finalized name for the old handle, and broadcast it
// to all observers. This is to move it out of the way of the
// next iteration of the folder.
now := fbo.config.Clock().Now()
finalizedInfo, err := tlf.NewHandleExtension(
tlf.HandleExtensionFinalized, 1, kbname.NormalizedUsername("<unknown>"),
now)
if err != nil {
return err
}
oldHandle.SetFinalizedInfo(finalizedInfo)
// FIXME: This can't be subject to the WaitGroup due to a potential
// deadlock, so we use a raw goroutine here instead of `goTracked`.
go fbo.observers.tlfHandleChange(ctx, oldHandle)
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"Reset",
"(",
"ctx",
"context",
".",
"Context",
",",
"handle",
"*",
"tlfhandle",
".",
"Handle",
")",
"error",
"{",
"currHandle",
",",
"err",
":=",
"fbo",
".",
"GetTLFHandle",
"(",
"ctx",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"equal",
",",
"err",
":=",
"currHandle",
".",
"Equals",
"(",
"fbo",
".",
"config",
".",
"Codec",
"(",
")",
",",
"*",
"handle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"equal",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"currHandle",
",",
"handle",
")",
"\n",
"}",
"\n\n",
"oldHandle",
":=",
"handle",
".",
"DeepCopy",
"(",
")",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"fbo",
".",
"mdWriterLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"mdWriterLock",
".",
"Unlock",
"(",
"lState",
")",
"\n",
"fbo",
".",
"headLock",
".",
"Lock",
"(",
"lState",
")",
"\n",
"defer",
"fbo",
".",
"headLock",
".",
"Unlock",
"(",
"lState",
")",
"\n\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"changes",
",",
"affectedNodeIDs",
",",
"err",
":=",
"fbo",
".",
"blocks",
".",
"GetInvalidationChangesForAll",
"(",
"ctx",
",",
"lState",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Invalidate all the affected nodes.",
"if",
"len",
"(",
"changes",
")",
">",
"0",
"{",
"fbo",
".",
"observers",
".",
"batchChanges",
"(",
"ctx",
",",
"changes",
",",
"affectedNodeIDs",
")",
"\n",
"}",
"\n\n",
"// Make up a finalized name for the old handle, and broadcast it",
"// to all observers. This is to move it out of the way of the",
"// next iteration of the folder.",
"now",
":=",
"fbo",
".",
"config",
".",
"Clock",
"(",
")",
".",
"Now",
"(",
")",
"\n",
"finalizedInfo",
",",
"err",
":=",
"tlf",
".",
"NewHandleExtension",
"(",
"tlf",
".",
"HandleExtensionFinalized",
",",
"1",
",",
"kbname",
".",
"NormalizedUsername",
"(",
"\"",
"\"",
")",
",",
"now",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"oldHandle",
".",
"SetFinalizedInfo",
"(",
"finalizedInfo",
")",
"\n",
"// FIXME: This can't be subject to the WaitGroup due to a potential",
"// deadlock, so we use a raw goroutine here instead of `goTracked`.",
"go",
"fbo",
".",
"observers",
".",
"tlfHandleChange",
"(",
"ctx",
",",
"oldHandle",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Reset implements the KBFSOps interface for folderBranchOps. | [
"Reset",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8459-L8509 |
161,451 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | GetSyncConfig | func (fbo *folderBranchOps) GetSyncConfig(
ctx context.Context, tlfID tlf.ID) (keybase1.FolderSyncConfig, error) {
if tlfID != fbo.id() || fbo.branch() != data.MasterBranch {
return keybase1.FolderSyncConfig{}, WrongOpsError{
fbo.folderBranch, data.FolderBranch{
Tlf: tlfID,
Branch: data.MasterBranch,
}}
}
lState := makeFBOLockState()
md, _ := fbo.getHead(ctx, lState, mdNoCommit)
config, tlfPath, err := fbo.getProtocolSyncConfigUnlocked(ctx, lState, md)
if errors.Cause(err) == errNeedMDForPartialSyncConfig {
// This is a partially-synced TLF, so it should be initialized
// automatically by KBFSOps; we just need to wait for the MD.
var once sync.Once
for md == (ImmutableRootMetadata{}) {
once.Do(func() {
fbo.log.CDebugf(
ctx, "Waiting for head to be populated while getting "+
"sync config")
})
t := time.After(100 * time.Millisecond)
select {
case <-t:
case <-ctx.Done():
return keybase1.FolderSyncConfig{}, errors.WithStack(ctx.Err())
}
md, _ = fbo.getHead(ctx, lState, mdNoCommit)
}
config, tlfPath, err = fbo.getProtocolSyncConfigUnlocked(
ctx, lState, md)
}
if err != nil {
return keybase1.FolderSyncConfig{}, err
}
if config.Mode == keybase1.FolderSyncMode_DISABLED ||
md == (ImmutableRootMetadata{}) ||
md.GetTlfHandle().GetCanonicalPath() == tlfPath {
return config, nil
}
// This means either the config was originally written before we
// started saving TLF paths, or the TLF paths has changed due to
// an SBS resolution or a subteam rename. Calling `SetSyncConfig`
// will use the newest path from the MD's TlfHandle.
fbo.log.CDebugf(ctx, "Updating sync config TLF path from \"%s\" to \"%s\"",
tlfPath, md.GetTlfHandle().GetCanonicalPath())
_, err = fbo.SetSyncConfig(ctx, tlfID, config)
if err != nil {
fbo.log.CWarningf(ctx, "Couldn't update TLF path: %+v", err)
}
return config, nil
} | go | func (fbo *folderBranchOps) GetSyncConfig(
ctx context.Context, tlfID tlf.ID) (keybase1.FolderSyncConfig, error) {
if tlfID != fbo.id() || fbo.branch() != data.MasterBranch {
return keybase1.FolderSyncConfig{}, WrongOpsError{
fbo.folderBranch, data.FolderBranch{
Tlf: tlfID,
Branch: data.MasterBranch,
}}
}
lState := makeFBOLockState()
md, _ := fbo.getHead(ctx, lState, mdNoCommit)
config, tlfPath, err := fbo.getProtocolSyncConfigUnlocked(ctx, lState, md)
if errors.Cause(err) == errNeedMDForPartialSyncConfig {
// This is a partially-synced TLF, so it should be initialized
// automatically by KBFSOps; we just need to wait for the MD.
var once sync.Once
for md == (ImmutableRootMetadata{}) {
once.Do(func() {
fbo.log.CDebugf(
ctx, "Waiting for head to be populated while getting "+
"sync config")
})
t := time.After(100 * time.Millisecond)
select {
case <-t:
case <-ctx.Done():
return keybase1.FolderSyncConfig{}, errors.WithStack(ctx.Err())
}
md, _ = fbo.getHead(ctx, lState, mdNoCommit)
}
config, tlfPath, err = fbo.getProtocolSyncConfigUnlocked(
ctx, lState, md)
}
if err != nil {
return keybase1.FolderSyncConfig{}, err
}
if config.Mode == keybase1.FolderSyncMode_DISABLED ||
md == (ImmutableRootMetadata{}) ||
md.GetTlfHandle().GetCanonicalPath() == tlfPath {
return config, nil
}
// This means either the config was originally written before we
// started saving TLF paths, or the TLF paths has changed due to
// an SBS resolution or a subteam rename. Calling `SetSyncConfig`
// will use the newest path from the MD's TlfHandle.
fbo.log.CDebugf(ctx, "Updating sync config TLF path from \"%s\" to \"%s\"",
tlfPath, md.GetTlfHandle().GetCanonicalPath())
_, err = fbo.SetSyncConfig(ctx, tlfID, config)
if err != nil {
fbo.log.CWarningf(ctx, "Couldn't update TLF path: %+v", err)
}
return config, nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"GetSyncConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"tlfID",
"tlf",
".",
"ID",
")",
"(",
"keybase1",
".",
"FolderSyncConfig",
",",
"error",
")",
"{",
"if",
"tlfID",
"!=",
"fbo",
".",
"id",
"(",
")",
"||",
"fbo",
".",
"branch",
"(",
")",
"!=",
"data",
".",
"MasterBranch",
"{",
"return",
"keybase1",
".",
"FolderSyncConfig",
"{",
"}",
",",
"WrongOpsError",
"{",
"fbo",
".",
"folderBranch",
",",
"data",
".",
"FolderBranch",
"{",
"Tlf",
":",
"tlfID",
",",
"Branch",
":",
"data",
".",
"MasterBranch",
",",
"}",
"}",
"\n",
"}",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"md",
",",
"_",
":=",
"fbo",
".",
"getHead",
"(",
"ctx",
",",
"lState",
",",
"mdNoCommit",
")",
"\n",
"config",
",",
"tlfPath",
",",
"err",
":=",
"fbo",
".",
"getProtocolSyncConfigUnlocked",
"(",
"ctx",
",",
"lState",
",",
"md",
")",
"\n",
"if",
"errors",
".",
"Cause",
"(",
"err",
")",
"==",
"errNeedMDForPartialSyncConfig",
"{",
"// This is a partially-synced TLF, so it should be initialized",
"// automatically by KBFSOps; we just need to wait for the MD.",
"var",
"once",
"sync",
".",
"Once",
"\n",
"for",
"md",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"{",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
")",
"\n",
"}",
")",
"\n",
"t",
":=",
"time",
".",
"After",
"(",
"100",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"select",
"{",
"case",
"<-",
"t",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"keybase1",
".",
"FolderSyncConfig",
"{",
"}",
",",
"errors",
".",
"WithStack",
"(",
"ctx",
".",
"Err",
"(",
")",
")",
"\n",
"}",
"\n",
"md",
",",
"_",
"=",
"fbo",
".",
"getHead",
"(",
"ctx",
",",
"lState",
",",
"mdNoCommit",
")",
"\n",
"}",
"\n",
"config",
",",
"tlfPath",
",",
"err",
"=",
"fbo",
".",
"getProtocolSyncConfigUnlocked",
"(",
"ctx",
",",
"lState",
",",
"md",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"keybase1",
".",
"FolderSyncConfig",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"Mode",
"==",
"keybase1",
".",
"FolderSyncMode_DISABLED",
"||",
"md",
"==",
"(",
"ImmutableRootMetadata",
"{",
"}",
")",
"||",
"md",
".",
"GetTlfHandle",
"(",
")",
".",
"GetCanonicalPath",
"(",
")",
"==",
"tlfPath",
"{",
"return",
"config",
",",
"nil",
"\n",
"}",
"\n\n",
"// This means either the config was originally written before we",
"// started saving TLF paths, or the TLF paths has changed due to",
"// an SBS resolution or a subteam rename. Calling `SetSyncConfig`",
"// will use the newest path from the MD's TlfHandle.",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"tlfPath",
",",
"md",
".",
"GetTlfHandle",
"(",
")",
".",
"GetCanonicalPath",
"(",
")",
")",
"\n",
"_",
",",
"err",
"=",
"fbo",
".",
"SetSyncConfig",
"(",
"ctx",
",",
"tlfID",
",",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fbo",
".",
"log",
".",
"CWarningf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"config",
",",
"nil",
"\n",
"}"
] | // GetSyncConfig implements the KBFSOps interface for folderBranchOps. | [
"GetSyncConfig",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8512-L8567 |
161,452 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | InvalidateNodeAndChildren | func (fbo *folderBranchOps) InvalidateNodeAndChildren(
ctx context.Context, node Node) (err error) {
startTime, timer := fbo.startOp(ctx, "InvalidateNodeAndChildren %p", node)
defer func() {
fbo.endOp(
ctx, startTime, timer, "InvalidateNodeAndChildren %p done: %+v",
node, err)
}()
lState := makeFBOLockState()
changes, affectedNodeIDs, err := fbo.blocks.GetInvalidationChangesForNode(
ctx, lState, node)
if err != nil {
return err
}
if len(changes) > 0 {
fbo.observers.batchChanges(ctx, changes, affectedNodeIDs)
}
return nil
} | go | func (fbo *folderBranchOps) InvalidateNodeAndChildren(
ctx context.Context, node Node) (err error) {
startTime, timer := fbo.startOp(ctx, "InvalidateNodeAndChildren %p", node)
defer func() {
fbo.endOp(
ctx, startTime, timer, "InvalidateNodeAndChildren %p done: %+v",
node, err)
}()
lState := makeFBOLockState()
changes, affectedNodeIDs, err := fbo.blocks.GetInvalidationChangesForNode(
ctx, lState, node)
if err != nil {
return err
}
if len(changes) > 0 {
fbo.observers.batchChanges(ctx, changes, affectedNodeIDs)
}
return nil
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"InvalidateNodeAndChildren",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"Node",
")",
"(",
"err",
"error",
")",
"{",
"startTime",
",",
"timer",
":=",
"fbo",
".",
"startOp",
"(",
"ctx",
",",
"\"",
"\"",
",",
"node",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fbo",
".",
"endOp",
"(",
"ctx",
",",
"startTime",
",",
"timer",
",",
"\"",
"\"",
",",
"node",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"lState",
":=",
"makeFBOLockState",
"(",
")",
"\n",
"changes",
",",
"affectedNodeIDs",
",",
"err",
":=",
"fbo",
".",
"blocks",
".",
"GetInvalidationChangesForNode",
"(",
"ctx",
",",
"lState",
",",
"node",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"changes",
")",
">",
"0",
"{",
"fbo",
".",
"observers",
".",
"batchChanges",
"(",
"ctx",
",",
"changes",
",",
"affectedNodeIDs",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // InvalidateNodeAndChildren implements the KBFSOps interface for
// folderBranchOps. | [
"InvalidateNodeAndChildren",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8877-L8897 |
161,453 | keybase/client | go/kbfs/libkbfs/folder_branch_ops.go | NewNotificationChannel | func (fbo *folderBranchOps) NewNotificationChannel(
ctx context.Context, handle *tlfhandle.Handle, convID chat1.ConversationID,
channelName string) {
monitoringCh := fbo.getEditMonitoringChannel()
if monitoringCh == nil {
fbo.vlog.CLogf(
ctx, libkb.VLog1,
"Ignoring new notification channel while edits are unmonitored")
return
}
fbo.vlog.CLogf(
ctx, libkb.VLog1, "New notification channel: %s %s",
convID, channelName)
fbo.editActivity.Add(1)
select {
case fbo.editChannels <- editChannelActivity{convID, channelName, ""}:
case <-monitoringCh:
fbo.editActivity.Done()
fbo.log.CDebugf(ctx, "Edit monitoring stopped while trying to "+
"send new notification channel")
}
} | go | func (fbo *folderBranchOps) NewNotificationChannel(
ctx context.Context, handle *tlfhandle.Handle, convID chat1.ConversationID,
channelName string) {
monitoringCh := fbo.getEditMonitoringChannel()
if monitoringCh == nil {
fbo.vlog.CLogf(
ctx, libkb.VLog1,
"Ignoring new notification channel while edits are unmonitored")
return
}
fbo.vlog.CLogf(
ctx, libkb.VLog1, "New notification channel: %s %s",
convID, channelName)
fbo.editActivity.Add(1)
select {
case fbo.editChannels <- editChannelActivity{convID, channelName, ""}:
case <-monitoringCh:
fbo.editActivity.Done()
fbo.log.CDebugf(ctx, "Edit monitoring stopped while trying to "+
"send new notification channel")
}
} | [
"func",
"(",
"fbo",
"*",
"folderBranchOps",
")",
"NewNotificationChannel",
"(",
"ctx",
"context",
".",
"Context",
",",
"handle",
"*",
"tlfhandle",
".",
"Handle",
",",
"convID",
"chat1",
".",
"ConversationID",
",",
"channelName",
"string",
")",
"{",
"monitoringCh",
":=",
"fbo",
".",
"getEditMonitoringChannel",
"(",
")",
"\n",
"if",
"monitoringCh",
"==",
"nil",
"{",
"fbo",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"fbo",
".",
"vlog",
".",
"CLogf",
"(",
"ctx",
",",
"libkb",
".",
"VLog1",
",",
"\"",
"\"",
",",
"convID",
",",
"channelName",
")",
"\n",
"fbo",
".",
"editActivity",
".",
"Add",
"(",
"1",
")",
"\n",
"select",
"{",
"case",
"fbo",
".",
"editChannels",
"<-",
"editChannelActivity",
"{",
"convID",
",",
"channelName",
",",
"\"",
"\"",
"}",
":",
"case",
"<-",
"monitoringCh",
":",
"fbo",
".",
"editActivity",
".",
"Done",
"(",
")",
"\n",
"fbo",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // NewNotificationChannel implements the KBFSOps interface for
// folderBranchOps. | [
"NewNotificationChannel",
"implements",
"the",
"KBFSOps",
"interface",
"for",
"folderBranchOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/folder_branch_ops.go#L8907-L8929 |
161,454 | keybase/client | go/client/json_api_common.go | encodeReply | func encodeReply(call Call, reply Reply, wr io.Writer, indent bool) error {
// copy jsonrpc fields from call to reply
reply.Jsonrpc = call.Jsonrpc
reply.ID = call.ID
enc := json.NewEncoder(wr)
if indent {
enc.SetIndent("", " ")
}
return enc.Encode(reply)
} | go | func encodeReply(call Call, reply Reply, wr io.Writer, indent bool) error {
// copy jsonrpc fields from call to reply
reply.Jsonrpc = call.Jsonrpc
reply.ID = call.ID
enc := json.NewEncoder(wr)
if indent {
enc.SetIndent("", " ")
}
return enc.Encode(reply)
} | [
"func",
"encodeReply",
"(",
"call",
"Call",
",",
"reply",
"Reply",
",",
"wr",
"io",
".",
"Writer",
",",
"indent",
"bool",
")",
"error",
"{",
"// copy jsonrpc fields from call to reply",
"reply",
".",
"Jsonrpc",
"=",
"call",
".",
"Jsonrpc",
"\n",
"reply",
".",
"ID",
"=",
"call",
".",
"ID",
"\n\n",
"enc",
":=",
"json",
".",
"NewEncoder",
"(",
"wr",
")",
"\n",
"if",
"indent",
"{",
"enc",
".",
"SetIndent",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"enc",
".",
"Encode",
"(",
"reply",
")",
"\n",
"}"
] | // encodeReply JSON encodes all replies. | [
"encodeReply",
"JSON",
"encodes",
"all",
"replies",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/json_api_common.go#L226-L236 |
161,455 | keybase/client | go/client/json_api_common.go | unmarshalOptions | func unmarshalOptions(c Call, opts Checker) error {
if len(c.Params.Options) == 0 {
// still check the options in case any fields are required.
return opts.Check()
}
if err := json.Unmarshal(c.Params.Options, opts); err != nil {
return err
}
return opts.Check()
} | go | func unmarshalOptions(c Call, opts Checker) error {
if len(c.Params.Options) == 0 {
// still check the options in case any fields are required.
return opts.Check()
}
if err := json.Unmarshal(c.Params.Options, opts); err != nil {
return err
}
return opts.Check()
} | [
"func",
"unmarshalOptions",
"(",
"c",
"Call",
",",
"opts",
"Checker",
")",
"error",
"{",
"if",
"len",
"(",
"c",
".",
"Params",
".",
"Options",
")",
"==",
"0",
"{",
"// still check the options in case any fields are required.",
"return",
"opts",
".",
"Check",
"(",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"c",
".",
"Params",
".",
"Options",
",",
"opts",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"opts",
".",
"Check",
"(",
")",
"\n",
"}"
] | // unmarshalOptions unmarshals any options in Call into opts,
// and verify they pass the Checker checks. | [
"unmarshalOptions",
"unmarshals",
"any",
"options",
"in",
"Call",
"into",
"opts",
"and",
"verify",
"they",
"pass",
"the",
"Checker",
"checks",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/json_api_common.go#L240-L249 |
161,456 | keybase/client | go/protocol/kbgitkbfs1/disk_block_cache.go | GetBlock | func (c DiskBlockCacheClient) GetBlock(ctx context.Context, __arg GetBlockArg) (res GetBlockRes, err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.GetBlock", []interface{}{__arg}, &res)
return
} | go | func (c DiskBlockCacheClient) GetBlock(ctx context.Context, __arg GetBlockArg) (res GetBlockRes, err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.GetBlock", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"DiskBlockCacheClient",
")",
"GetBlock",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"GetBlockArg",
")",
"(",
"res",
"GetBlockRes",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // GetBlock gets a block from the disk cache. | [
"GetBlock",
"gets",
"a",
"block",
"from",
"the",
"disk",
"cache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/kbgitkbfs1/disk_block_cache.go#L207-L210 |
161,457 | keybase/client | go/protocol/kbgitkbfs1/disk_block_cache.go | GetPrefetchStatus | func (c DiskBlockCacheClient) GetPrefetchStatus(ctx context.Context, __arg GetPrefetchStatusArg) (res PrefetchStatus, err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.GetPrefetchStatus", []interface{}{__arg}, &res)
return
} | go | func (c DiskBlockCacheClient) GetPrefetchStatus(ctx context.Context, __arg GetPrefetchStatusArg) (res PrefetchStatus, err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.GetPrefetchStatus", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"DiskBlockCacheClient",
")",
"GetPrefetchStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"GetPrefetchStatusArg",
")",
"(",
"res",
"PrefetchStatus",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // GetPrefetchStatus gets the prefetch status from the disk cache. | [
"GetPrefetchStatus",
"gets",
"the",
"prefetch",
"status",
"from",
"the",
"disk",
"cache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/kbgitkbfs1/disk_block_cache.go#L213-L216 |
161,458 | keybase/client | go/protocol/kbgitkbfs1/disk_block_cache.go | PutBlock | func (c DiskBlockCacheClient) PutBlock(ctx context.Context, __arg PutBlockArg) (err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.PutBlock", []interface{}{__arg}, nil)
return
} | go | func (c DiskBlockCacheClient) PutBlock(ctx context.Context, __arg PutBlockArg) (err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.PutBlock", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"DiskBlockCacheClient",
")",
"PutBlock",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PutBlockArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // PutBlock puts a block into the disk cache. | [
"PutBlock",
"puts",
"a",
"block",
"into",
"the",
"disk",
"cache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/kbgitkbfs1/disk_block_cache.go#L219-L222 |
161,459 | keybase/client | go/protocol/kbgitkbfs1/disk_block_cache.go | DeleteBlocks | func (c DiskBlockCacheClient) DeleteBlocks(ctx context.Context, blockIDs [][]byte) (res DeleteBlocksRes, err error) {
__arg := DeleteBlocksArg{BlockIDs: blockIDs}
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.DeleteBlocks", []interface{}{__arg}, &res)
return
} | go | func (c DiskBlockCacheClient) DeleteBlocks(ctx context.Context, blockIDs [][]byte) (res DeleteBlocksRes, err error) {
__arg := DeleteBlocksArg{BlockIDs: blockIDs}
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.DeleteBlocks", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"DiskBlockCacheClient",
")",
"DeleteBlocks",
"(",
"ctx",
"context",
".",
"Context",
",",
"blockIDs",
"[",
"]",
"[",
"]",
"byte",
")",
"(",
"res",
"DeleteBlocksRes",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"DeleteBlocksArg",
"{",
"BlockIDs",
":",
"blockIDs",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // DeleteBlocks deletes a set of blocks from the disk cache. | [
"DeleteBlocks",
"deletes",
"a",
"set",
"of",
"blocks",
"from",
"the",
"disk",
"cache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/kbgitkbfs1/disk_block_cache.go#L225-L229 |
161,460 | keybase/client | go/protocol/kbgitkbfs1/disk_block_cache.go | UpdateBlockMetadata | func (c DiskBlockCacheClient) UpdateBlockMetadata(ctx context.Context, __arg UpdateBlockMetadataArg) (err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.UpdateBlockMetadata", []interface{}{__arg}, nil)
return
} | go | func (c DiskBlockCacheClient) UpdateBlockMetadata(ctx context.Context, __arg UpdateBlockMetadataArg) (err error) {
err = c.Cli.Call(ctx, "kbgitkbfs.1.DiskBlockCache.UpdateBlockMetadata", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"DiskBlockCacheClient",
")",
"UpdateBlockMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"UpdateBlockMetadataArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // UpdateBlockMetadata updates the metadata for a block in the disk cache. | [
"UpdateBlockMetadata",
"updates",
"the",
"metadata",
"for",
"a",
"block",
"in",
"the",
"disk",
"cache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/kbgitkbfs1/disk_block_cache.go#L232-L235 |
161,461 | keybase/client | go/client/cmd_wallet_history.go | filterNote | func (c *cmdWalletHistory) filterNote(note string) string {
lines := strings.Split(strings.TrimSpace(note), "\n")
if len(lines) < 1 {
return ""
}
return strings.TrimSpace(lines[0])
} | go | func (c *cmdWalletHistory) filterNote(note string) string {
lines := strings.Split(strings.TrimSpace(note), "\n")
if len(lines) < 1 {
return ""
}
return strings.TrimSpace(lines[0])
} | [
"func",
"(",
"c",
"*",
"cmdWalletHistory",
")",
"filterNote",
"(",
"note",
"string",
")",
"string",
"{",
"lines",
":=",
"strings",
".",
"Split",
"(",
"strings",
".",
"TrimSpace",
"(",
"note",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"if",
"len",
"(",
"lines",
")",
"<",
"1",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"strings",
".",
"TrimSpace",
"(",
"lines",
"[",
"0",
"]",
")",
"\n",
"}"
] | // Pare down the note so that it's less likely to contain tricks.
// Such as newlines and fake transactions.
// Shows only the first line. | [
"Pare",
"down",
"the",
"note",
"so",
"that",
"it",
"s",
"less",
"likely",
"to",
"contain",
"tricks",
".",
"Such",
"as",
"newlines",
"and",
"fake",
"transactions",
".",
"Shows",
"only",
"the",
"first",
"line",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_wallet_history.go#L97-L103 |
161,462 | keybase/client | go/client/cmd_status.go | execToString | func (c *CmdStatus) execToString(bin string, args []string) (string, error) {
result, err := exec.Command(bin, args...).Output()
if err != nil {
return "", err
}
if result == nil {
return "", fmt.Errorf("Nil result")
}
return strings.TrimSpace(string(result)), nil
} | go | func (c *CmdStatus) execToString(bin string, args []string) (string, error) {
result, err := exec.Command(bin, args...).Output()
if err != nil {
return "", err
}
if result == nil {
return "", fmt.Errorf("Nil result")
}
return strings.TrimSpace(string(result)), nil
} | [
"func",
"(",
"c",
"*",
"CmdStatus",
")",
"execToString",
"(",
"bin",
"string",
",",
"args",
"[",
"]",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"bin",
",",
"args",
"...",
")",
".",
"Output",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"if",
"result",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"strings",
".",
"TrimSpace",
"(",
"string",
"(",
"result",
")",
")",
",",
"nil",
"\n",
"}"
] | // execToString returns the space-trimmed output of a command or an error. | [
"execToString",
"returns",
"the",
"space",
"-",
"trimmed",
"output",
"of",
"a",
"command",
"or",
"an",
"error",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_status.go#L404-L413 |
161,463 | keybase/client | go/kbfs/libfuse/mounter.go | Mount | func (m *mounter) Mount() (err error) {
defer func() {
if err != nil {
msg := fmt.Sprintf("KBFS failed to FUSE mount at %s: %s", m.options.MountPoint, err)
fmt.Println(msg)
m.log.Warning(msg)
}
}()
m.c, err = fuseMountDir(m.options.MountPoint, m.options.PlatformParams)
// Exit if we were successful or we are not a force mounting on error.
// Otherwise, try unmounting and mounting again.
if err == nil || !m.options.ForceMount {
return err
}
// Mount failed, let's try to unmount and then try mounting again, even
// if unmounting errors here.
m.Unmount()
// In case we are on darwin, ask the installer to reinstall the mount dir
// and try again as the last resort. This specifically fixes a situation
// where /keybase gets created and owned by root after Keybase app is
// started, and `kbfs` later fails to mount because of a permission error.
m.reinstallMountDirIfPossible()
m.c, err = fuseMountDir(m.options.MountPoint, m.options.PlatformParams)
return err
} | go | func (m *mounter) Mount() (err error) {
defer func() {
if err != nil {
msg := fmt.Sprintf("KBFS failed to FUSE mount at %s: %s", m.options.MountPoint, err)
fmt.Println(msg)
m.log.Warning(msg)
}
}()
m.c, err = fuseMountDir(m.options.MountPoint, m.options.PlatformParams)
// Exit if we were successful or we are not a force mounting on error.
// Otherwise, try unmounting and mounting again.
if err == nil || !m.options.ForceMount {
return err
}
// Mount failed, let's try to unmount and then try mounting again, even
// if unmounting errors here.
m.Unmount()
// In case we are on darwin, ask the installer to reinstall the mount dir
// and try again as the last resort. This specifically fixes a situation
// where /keybase gets created and owned by root after Keybase app is
// started, and `kbfs` later fails to mount because of a permission error.
m.reinstallMountDirIfPossible()
m.c, err = fuseMountDir(m.options.MountPoint, m.options.PlatformParams)
return err
} | [
"func",
"(",
"m",
"*",
"mounter",
")",
"Mount",
"(",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"m",
".",
"options",
".",
"MountPoint",
",",
"err",
")",
"\n",
"fmt",
".",
"Println",
"(",
"msg",
")",
"\n",
"m",
".",
"log",
".",
"Warning",
"(",
"msg",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"m",
".",
"c",
",",
"err",
"=",
"fuseMountDir",
"(",
"m",
".",
"options",
".",
"MountPoint",
",",
"m",
".",
"options",
".",
"PlatformParams",
")",
"\n",
"// Exit if we were successful or we are not a force mounting on error.",
"// Otherwise, try unmounting and mounting again.",
"if",
"err",
"==",
"nil",
"||",
"!",
"m",
".",
"options",
".",
"ForceMount",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Mount failed, let's try to unmount and then try mounting again, even",
"// if unmounting errors here.",
"m",
".",
"Unmount",
"(",
")",
"\n\n",
"// In case we are on darwin, ask the installer to reinstall the mount dir",
"// and try again as the last resort. This specifically fixes a situation",
"// where /keybase gets created and owned by root after Keybase app is",
"// started, and `kbfs` later fails to mount because of a permission error.",
"m",
".",
"reinstallMountDirIfPossible",
"(",
")",
"\n",
"m",
".",
"c",
",",
"err",
"=",
"fuseMountDir",
"(",
"m",
".",
"options",
".",
"MountPoint",
",",
"m",
".",
"options",
".",
"PlatformParams",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] | // fuseMount tries to mount the mountpoint.
// On a force mount then unmount, re-mount if unsuccessful | [
"fuseMount",
"tries",
"to",
"mount",
"the",
"mountpoint",
".",
"On",
"a",
"force",
"mount",
"then",
"unmount",
"re",
"-",
"mount",
"if",
"unsuccessful"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/mounter.go#L35-L63 |
161,464 | keybase/client | go/kbfs/libkbfs/block_getter.go | getBlock | func (bg *realBlockGetter) getBlock(
ctx context.Context, kmd libkey.KeyMetadata, blockPtr data.BlockPointer,
block data.Block, cacheType DiskBlockCacheType) error {
bserv := bg.config.BlockServer()
buf, blockServerHalf, err := bserv.Get(
ctx, kmd.TlfID(), blockPtr.ID, blockPtr.Context, cacheType)
if err != nil {
// Temporary code to track down bad block
// requests. Remove when not needed anymore.
if _, ok := err.(kbfsblock.ServerErrorBadRequest); ok {
panic(fmt.Sprintf("Bad BServer request detected: err=%s, blockPtr=%s",
err, blockPtr))
}
return err
}
return assembleBlock(
ctx, bg.config.keyGetter(), bg.config.Codec(), bg.config.cryptoPure(),
kmd, blockPtr, block, buf, blockServerHalf)
} | go | func (bg *realBlockGetter) getBlock(
ctx context.Context, kmd libkey.KeyMetadata, blockPtr data.BlockPointer,
block data.Block, cacheType DiskBlockCacheType) error {
bserv := bg.config.BlockServer()
buf, blockServerHalf, err := bserv.Get(
ctx, kmd.TlfID(), blockPtr.ID, blockPtr.Context, cacheType)
if err != nil {
// Temporary code to track down bad block
// requests. Remove when not needed anymore.
if _, ok := err.(kbfsblock.ServerErrorBadRequest); ok {
panic(fmt.Sprintf("Bad BServer request detected: err=%s, blockPtr=%s",
err, blockPtr))
}
return err
}
return assembleBlock(
ctx, bg.config.keyGetter(), bg.config.Codec(), bg.config.cryptoPure(),
kmd, blockPtr, block, buf, blockServerHalf)
} | [
"func",
"(",
"bg",
"*",
"realBlockGetter",
")",
"getBlock",
"(",
"ctx",
"context",
".",
"Context",
",",
"kmd",
"libkey",
".",
"KeyMetadata",
",",
"blockPtr",
"data",
".",
"BlockPointer",
",",
"block",
"data",
".",
"Block",
",",
"cacheType",
"DiskBlockCacheType",
")",
"error",
"{",
"bserv",
":=",
"bg",
".",
"config",
".",
"BlockServer",
"(",
")",
"\n",
"buf",
",",
"blockServerHalf",
",",
"err",
":=",
"bserv",
".",
"Get",
"(",
"ctx",
",",
"kmd",
".",
"TlfID",
"(",
")",
",",
"blockPtr",
".",
"ID",
",",
"blockPtr",
".",
"Context",
",",
"cacheType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Temporary code to track down bad block",
"// requests. Remove when not needed anymore.",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"kbfsblock",
".",
"ServerErrorBadRequest",
")",
";",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"err",
",",
"blockPtr",
")",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"assembleBlock",
"(",
"ctx",
",",
"bg",
".",
"config",
".",
"keyGetter",
"(",
")",
",",
"bg",
".",
"config",
".",
"Codec",
"(",
")",
",",
"bg",
".",
"config",
".",
"cryptoPure",
"(",
")",
",",
"kmd",
",",
"blockPtr",
",",
"block",
",",
"buf",
",",
"blockServerHalf",
")",
"\n",
"}"
] | // getBlock implements the interface for realBlockGetter. | [
"getBlock",
"implements",
"the",
"interface",
"for",
"realBlockGetter",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/block_getter.go#L32-L52 |
161,465 | keybase/client | go/kbfs/libkbfs/node_cache.go | forgetLocked | func (ncs *nodeCacheStandard) forgetLocked(core *nodeCore) {
ref := core.pathNode.Ref()
entry, ok := ncs.nodes[ref]
if !ok {
return
}
if entry.core != core {
return
}
entry.refCount--
if entry.refCount <= 0 {
delete(ncs.nodes, ref)
}
} | go | func (ncs *nodeCacheStandard) forgetLocked(core *nodeCore) {
ref := core.pathNode.Ref()
entry, ok := ncs.nodes[ref]
if !ok {
return
}
if entry.core != core {
return
}
entry.refCount--
if entry.refCount <= 0 {
delete(ncs.nodes, ref)
}
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"forgetLocked",
"(",
"core",
"*",
"nodeCore",
")",
"{",
"ref",
":=",
"core",
".",
"pathNode",
".",
"Ref",
"(",
")",
"\n\n",
"entry",
",",
"ok",
":=",
"ncs",
".",
"nodes",
"[",
"ref",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"if",
"entry",
".",
"core",
"!=",
"core",
"{",
"return",
"\n",
"}",
"\n\n",
"entry",
".",
"refCount",
"--",
"\n",
"if",
"entry",
".",
"refCount",
"<=",
"0",
"{",
"delete",
"(",
"ncs",
".",
"nodes",
",",
"ref",
")",
"\n",
"}",
"\n",
"}"
] | // lock must be locked for writing by the caller | [
"lock",
"must",
"be",
"locked",
"for",
"writing",
"by",
"the",
"caller"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L40-L55 |
161,466 | keybase/client | go/kbfs/libkbfs/node_cache.go | newChildForParentLocked | func (ncs *nodeCacheStandard) newChildForParentLocked(parent Node) (*nodeStandard, error) {
nodeStandard, ok := parent.Unwrap().(*nodeStandard)
if !ok {
return nil, ParentNodeNotFoundError{data.BlockRef{}}
}
ref := nodeStandard.core.pathNode.Ref()
entry, ok := ncs.nodes[ref]
if !ok {
return nil, ParentNodeNotFoundError{ref}
}
if nodeStandard.core != entry.core {
return nil, ParentNodeNotFoundError{ref}
}
return nodeStandard, nil
} | go | func (ncs *nodeCacheStandard) newChildForParentLocked(parent Node) (*nodeStandard, error) {
nodeStandard, ok := parent.Unwrap().(*nodeStandard)
if !ok {
return nil, ParentNodeNotFoundError{data.BlockRef{}}
}
ref := nodeStandard.core.pathNode.Ref()
entry, ok := ncs.nodes[ref]
if !ok {
return nil, ParentNodeNotFoundError{ref}
}
if nodeStandard.core != entry.core {
return nil, ParentNodeNotFoundError{ref}
}
return nodeStandard, nil
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"newChildForParentLocked",
"(",
"parent",
"Node",
")",
"(",
"*",
"nodeStandard",
",",
"error",
")",
"{",
"nodeStandard",
",",
"ok",
":=",
"parent",
".",
"Unwrap",
"(",
")",
".",
"(",
"*",
"nodeStandard",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ParentNodeNotFoundError",
"{",
"data",
".",
"BlockRef",
"{",
"}",
"}",
"\n",
"}",
"\n\n",
"ref",
":=",
"nodeStandard",
".",
"core",
".",
"pathNode",
".",
"Ref",
"(",
")",
"\n",
"entry",
",",
"ok",
":=",
"ncs",
".",
"nodes",
"[",
"ref",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ParentNodeNotFoundError",
"{",
"ref",
"}",
"\n",
"}",
"\n",
"if",
"nodeStandard",
".",
"core",
"!=",
"entry",
".",
"core",
"{",
"return",
"nil",
",",
"ParentNodeNotFoundError",
"{",
"ref",
"}",
"\n",
"}",
"\n",
"return",
"nodeStandard",
",",
"nil",
"\n",
"}"
] | // lock must be held for writing by the caller | [
"lock",
"must",
"be",
"held",
"for",
"writing",
"by",
"the",
"caller"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L65-L80 |
161,467 | keybase/client | go/kbfs/libkbfs/node_cache.go | GetOrCreate | func (ncs *nodeCacheStandard) GetOrCreate(
ptr data.BlockPointer, name string, parent Node, et data.EntryType) (
n Node, err error) {
var rootWrappers []func(Node) Node
defer func() {
if n != nil {
n = ncs.wrapNodeStandard(n, rootWrappers, parent)
}
}()
if !ptr.IsValid() {
// Temporary code to track down bad block
// pointers. Remove when not needed anymore.
panic(InvalidBlockRefError{ptr.Ref()})
}
if name == "" {
return nil, EmptyNameError{ptr.Ref()}
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
rootWrappers = ncs.rootWrappers
entry, ok := ncs.nodes[ptr.Ref()]
if ok {
// If the entry happens to be unlinked, we may be in a
// situation where a node got unlinked and then recreated, but
// someone held onto a node the whole time and so it never got
// removed from the cache. In that case, forcibly remove it
// from the cache to make room for the new node.
if parent != nil && entry.core.parent == nil {
delete(ncs.nodes, ptr.Ref())
} else {
return ncs.makeNodeStandardForEntryLocked(entry), nil
}
}
if parent != nil {
// Make sure a child can be made for this parent.
_, err := ncs.newChildForParentLocked(parent)
if err != nil {
return nil, err
}
}
entry = &nodeCacheEntry{
core: newNodeCore(ptr, name, parent, ncs, et),
}
ncs.nodes[ptr.Ref()] = entry
return ncs.makeNodeStandardForEntryLocked(entry), nil
} | go | func (ncs *nodeCacheStandard) GetOrCreate(
ptr data.BlockPointer, name string, parent Node, et data.EntryType) (
n Node, err error) {
var rootWrappers []func(Node) Node
defer func() {
if n != nil {
n = ncs.wrapNodeStandard(n, rootWrappers, parent)
}
}()
if !ptr.IsValid() {
// Temporary code to track down bad block
// pointers. Remove when not needed anymore.
panic(InvalidBlockRefError{ptr.Ref()})
}
if name == "" {
return nil, EmptyNameError{ptr.Ref()}
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
rootWrappers = ncs.rootWrappers
entry, ok := ncs.nodes[ptr.Ref()]
if ok {
// If the entry happens to be unlinked, we may be in a
// situation where a node got unlinked and then recreated, but
// someone held onto a node the whole time and so it never got
// removed from the cache. In that case, forcibly remove it
// from the cache to make room for the new node.
if parent != nil && entry.core.parent == nil {
delete(ncs.nodes, ptr.Ref())
} else {
return ncs.makeNodeStandardForEntryLocked(entry), nil
}
}
if parent != nil {
// Make sure a child can be made for this parent.
_, err := ncs.newChildForParentLocked(parent)
if err != nil {
return nil, err
}
}
entry = &nodeCacheEntry{
core: newNodeCore(ptr, name, parent, ncs, et),
}
ncs.nodes[ptr.Ref()] = entry
return ncs.makeNodeStandardForEntryLocked(entry), nil
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"GetOrCreate",
"(",
"ptr",
"data",
".",
"BlockPointer",
",",
"name",
"string",
",",
"parent",
"Node",
",",
"et",
"data",
".",
"EntryType",
")",
"(",
"n",
"Node",
",",
"err",
"error",
")",
"{",
"var",
"rootWrappers",
"[",
"]",
"func",
"(",
"Node",
")",
"Node",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"n",
"!=",
"nil",
"{",
"n",
"=",
"ncs",
".",
"wrapNodeStandard",
"(",
"n",
",",
"rootWrappers",
",",
"parent",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"if",
"!",
"ptr",
".",
"IsValid",
"(",
")",
"{",
"// Temporary code to track down bad block",
"// pointers. Remove when not needed anymore.",
"panic",
"(",
"InvalidBlockRefError",
"{",
"ptr",
".",
"Ref",
"(",
")",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"EmptyNameError",
"{",
"ptr",
".",
"Ref",
"(",
")",
"}",
"\n",
"}",
"\n\n",
"ncs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"rootWrappers",
"=",
"ncs",
".",
"rootWrappers",
"\n",
"entry",
",",
"ok",
":=",
"ncs",
".",
"nodes",
"[",
"ptr",
".",
"Ref",
"(",
")",
"]",
"\n",
"if",
"ok",
"{",
"// If the entry happens to be unlinked, we may be in a",
"// situation where a node got unlinked and then recreated, but",
"// someone held onto a node the whole time and so it never got",
"// removed from the cache. In that case, forcibly remove it",
"// from the cache to make room for the new node.",
"if",
"parent",
"!=",
"nil",
"&&",
"entry",
".",
"core",
".",
"parent",
"==",
"nil",
"{",
"delete",
"(",
"ncs",
".",
"nodes",
",",
"ptr",
".",
"Ref",
"(",
")",
")",
"\n",
"}",
"else",
"{",
"return",
"ncs",
".",
"makeNodeStandardForEntryLocked",
"(",
"entry",
")",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"parent",
"!=",
"nil",
"{",
"// Make sure a child can be made for this parent.",
"_",
",",
"err",
":=",
"ncs",
".",
"newChildForParentLocked",
"(",
"parent",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"entry",
"=",
"&",
"nodeCacheEntry",
"{",
"core",
":",
"newNodeCore",
"(",
"ptr",
",",
"name",
",",
"parent",
",",
"ncs",
",",
"et",
")",
",",
"}",
"\n",
"ncs",
".",
"nodes",
"[",
"ptr",
".",
"Ref",
"(",
")",
"]",
"=",
"entry",
"\n",
"return",
"ncs",
".",
"makeNodeStandardForEntryLocked",
"(",
"entry",
")",
",",
"nil",
"\n",
"}"
] | // GetOrCreate implements the NodeCache interface for nodeCacheStandard. | [
"GetOrCreate",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L99-L149 |
161,468 | keybase/client | go/kbfs/libkbfs/node_cache.go | Get | func (ncs *nodeCacheStandard) Get(ref data.BlockRef) (n Node) {
if ref == (data.BlockRef{}) {
return nil
}
// Temporary code to track down bad block pointers. Remove (or
// return an error) when not needed anymore.
if !ref.IsValid() {
panic(InvalidBlockRefError{ref})
}
var rootWrappers []func(Node) Node
var parent Node
defer func() {
if n != nil {
n = ncs.wrapNodeStandard(n, rootWrappers, parent)
}
}()
ncs.lock.Lock()
defer ncs.lock.Unlock()
rootWrappers = ncs.rootWrappers
entry, ok := ncs.nodes[ref]
if !ok {
return nil
}
ns := ncs.makeNodeStandardForEntryLocked(entry)
parent = ns.core.parent // get while under lock
return ns
} | go | func (ncs *nodeCacheStandard) Get(ref data.BlockRef) (n Node) {
if ref == (data.BlockRef{}) {
return nil
}
// Temporary code to track down bad block pointers. Remove (or
// return an error) when not needed anymore.
if !ref.IsValid() {
panic(InvalidBlockRefError{ref})
}
var rootWrappers []func(Node) Node
var parent Node
defer func() {
if n != nil {
n = ncs.wrapNodeStandard(n, rootWrappers, parent)
}
}()
ncs.lock.Lock()
defer ncs.lock.Unlock()
rootWrappers = ncs.rootWrappers
entry, ok := ncs.nodes[ref]
if !ok {
return nil
}
ns := ncs.makeNodeStandardForEntryLocked(entry)
parent = ns.core.parent // get while under lock
return ns
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"Get",
"(",
"ref",
"data",
".",
"BlockRef",
")",
"(",
"n",
"Node",
")",
"{",
"if",
"ref",
"==",
"(",
"data",
".",
"BlockRef",
"{",
"}",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Temporary code to track down bad block pointers. Remove (or",
"// return an error) when not needed anymore.",
"if",
"!",
"ref",
".",
"IsValid",
"(",
")",
"{",
"panic",
"(",
"InvalidBlockRefError",
"{",
"ref",
"}",
")",
"\n",
"}",
"\n\n",
"var",
"rootWrappers",
"[",
"]",
"func",
"(",
"Node",
")",
"Node",
"\n",
"var",
"parent",
"Node",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"n",
"!=",
"nil",
"{",
"n",
"=",
"ncs",
".",
"wrapNodeStandard",
"(",
"n",
",",
"rootWrappers",
",",
"parent",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"ncs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"rootWrappers",
"=",
"ncs",
".",
"rootWrappers",
"\n",
"entry",
",",
"ok",
":=",
"ncs",
".",
"nodes",
"[",
"ref",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"ns",
":=",
"ncs",
".",
"makeNodeStandardForEntryLocked",
"(",
"entry",
")",
"\n",
"parent",
"=",
"ns",
".",
"core",
".",
"parent",
"// get while under lock",
"\n",
"return",
"ns",
"\n",
"}"
] | // Get implements the NodeCache interface for nodeCacheStandard. | [
"Get",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L152-L181 |
161,469 | keybase/client | go/kbfs/libkbfs/node_cache.go | UpdatePointer | func (ncs *nodeCacheStandard) UpdatePointer(
oldRef data.BlockRef, newPtr data.BlockPointer) (updatedNode NodeID) {
if oldRef == (data.BlockRef{}) && newPtr == (data.BlockPointer{}) {
return nil
}
if !oldRef.IsValid() {
panic(fmt.Sprintf("invalid oldRef %s with newPtr %s", oldRef, newPtr))
}
if !newPtr.IsValid() {
panic(fmt.Sprintf("invalid newPtr %s with oldRef %s", newPtr, oldRef))
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
entry, ok := ncs.nodes[oldRef]
if !ok {
return nil
}
// Cannot update the pointer for an unlinked node.
if entry.core.cachedPath.IsValid() {
return nil
}
entry.core.pathNode.BlockPointer = newPtr
delete(ncs.nodes, oldRef)
ncs.nodes[newPtr.Ref()] = entry
return entry.core
} | go | func (ncs *nodeCacheStandard) UpdatePointer(
oldRef data.BlockRef, newPtr data.BlockPointer) (updatedNode NodeID) {
if oldRef == (data.BlockRef{}) && newPtr == (data.BlockPointer{}) {
return nil
}
if !oldRef.IsValid() {
panic(fmt.Sprintf("invalid oldRef %s with newPtr %s", oldRef, newPtr))
}
if !newPtr.IsValid() {
panic(fmt.Sprintf("invalid newPtr %s with oldRef %s", newPtr, oldRef))
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
entry, ok := ncs.nodes[oldRef]
if !ok {
return nil
}
// Cannot update the pointer for an unlinked node.
if entry.core.cachedPath.IsValid() {
return nil
}
entry.core.pathNode.BlockPointer = newPtr
delete(ncs.nodes, oldRef)
ncs.nodes[newPtr.Ref()] = entry
return entry.core
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"UpdatePointer",
"(",
"oldRef",
"data",
".",
"BlockRef",
",",
"newPtr",
"data",
".",
"BlockPointer",
")",
"(",
"updatedNode",
"NodeID",
")",
"{",
"if",
"oldRef",
"==",
"(",
"data",
".",
"BlockRef",
"{",
"}",
")",
"&&",
"newPtr",
"==",
"(",
"data",
".",
"BlockPointer",
"{",
"}",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"!",
"oldRef",
".",
"IsValid",
"(",
")",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"oldRef",
",",
"newPtr",
")",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"newPtr",
".",
"IsValid",
"(",
")",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"newPtr",
",",
"oldRef",
")",
")",
"\n",
"}",
"\n\n",
"ncs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"entry",
",",
"ok",
":=",
"ncs",
".",
"nodes",
"[",
"oldRef",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Cannot update the pointer for an unlinked node.",
"if",
"entry",
".",
"core",
".",
"cachedPath",
".",
"IsValid",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"entry",
".",
"core",
".",
"pathNode",
".",
"BlockPointer",
"=",
"newPtr",
"\n",
"delete",
"(",
"ncs",
".",
"nodes",
",",
"oldRef",
")",
"\n",
"ncs",
".",
"nodes",
"[",
"newPtr",
".",
"Ref",
"(",
")",
"]",
"=",
"entry",
"\n",
"return",
"entry",
".",
"core",
"\n",
"}"
] | // UpdatePointer implements the NodeCache interface for nodeCacheStandard. | [
"UpdatePointer",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L184-L214 |
161,470 | keybase/client | go/kbfs/libkbfs/node_cache.go | Move | func (ncs *nodeCacheStandard) Move(
ref data.BlockRef, newParent Node, newName string) (undoFn func(), err error) {
if ref == (data.BlockRef{}) {
return nil, nil
}
// Temporary code to track down bad block pointers. Remove (or
// return an error) when not needed anymore.
if !ref.IsValid() {
panic(InvalidBlockRefError{ref})
}
if newName == "" {
return nil, EmptyNameError{ref}
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
entry, ok := ncs.nodes[ref]
if !ok {
return nil, nil
}
newParentNS, err := ncs.newChildForParentLocked(newParent)
if err != nil {
return nil, err
}
oldParent := entry.core.parent
oldName := entry.core.pathNode.Name
entry.core.parent = newParentNS
entry.core.pathNode.Name = newName
return func() {
entry.core.parent = oldParent
entry.core.pathNode.Name = oldName
}, nil
} | go | func (ncs *nodeCacheStandard) Move(
ref data.BlockRef, newParent Node, newName string) (undoFn func(), err error) {
if ref == (data.BlockRef{}) {
return nil, nil
}
// Temporary code to track down bad block pointers. Remove (or
// return an error) when not needed anymore.
if !ref.IsValid() {
panic(InvalidBlockRefError{ref})
}
if newName == "" {
return nil, EmptyNameError{ref}
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
entry, ok := ncs.nodes[ref]
if !ok {
return nil, nil
}
newParentNS, err := ncs.newChildForParentLocked(newParent)
if err != nil {
return nil, err
}
oldParent := entry.core.parent
oldName := entry.core.pathNode.Name
entry.core.parent = newParentNS
entry.core.pathNode.Name = newName
return func() {
entry.core.parent = oldParent
entry.core.pathNode.Name = oldName
}, nil
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"Move",
"(",
"ref",
"data",
".",
"BlockRef",
",",
"newParent",
"Node",
",",
"newName",
"string",
")",
"(",
"undoFn",
"func",
"(",
")",
",",
"err",
"error",
")",
"{",
"if",
"ref",
"==",
"(",
"data",
".",
"BlockRef",
"{",
"}",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"// Temporary code to track down bad block pointers. Remove (or",
"// return an error) when not needed anymore.",
"if",
"!",
"ref",
".",
"IsValid",
"(",
")",
"{",
"panic",
"(",
"InvalidBlockRefError",
"{",
"ref",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"newName",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"EmptyNameError",
"{",
"ref",
"}",
"\n",
"}",
"\n\n",
"ncs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"entry",
",",
"ok",
":=",
"ncs",
".",
"nodes",
"[",
"ref",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"newParentNS",
",",
"err",
":=",
"ncs",
".",
"newChildForParentLocked",
"(",
"newParent",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"oldParent",
":=",
"entry",
".",
"core",
".",
"parent",
"\n",
"oldName",
":=",
"entry",
".",
"core",
".",
"pathNode",
".",
"Name",
"\n\n",
"entry",
".",
"core",
".",
"parent",
"=",
"newParentNS",
"\n",
"entry",
".",
"core",
".",
"pathNode",
".",
"Name",
"=",
"newName",
"\n\n",
"return",
"func",
"(",
")",
"{",
"entry",
".",
"core",
".",
"parent",
"=",
"oldParent",
"\n",
"entry",
".",
"core",
".",
"pathNode",
".",
"Name",
"=",
"oldName",
"\n",
"}",
",",
"nil",
"\n",
"}"
] | // Move implements the NodeCache interface for nodeCacheStandard. | [
"Move",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L217-L255 |
161,471 | keybase/client | go/kbfs/libkbfs/node_cache.go | Unlink | func (ncs *nodeCacheStandard) Unlink(
ref data.BlockRef, oldPath data.Path, oldDe data.DirEntry) (undoFn func()) {
if ref == (data.BlockRef{}) {
return nil
}
// Temporary code to track down bad block pointers. Remove (or
// return an error) when not needed anymore.
if !ref.IsValid() {
panic(InvalidBlockRefError{ref})
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
entry, ok := ncs.nodes[ref]
if !ok {
return nil
}
if entry.core.cachedPath.IsValid() {
// Already unlinked!
return nil
}
oldParent := entry.core.parent
oldName := entry.core.pathNode.Name
entry.core.cachedPath = oldPath
entry.core.cachedDe = oldDe
entry.core.parent = nil
entry.core.pathNode.Name = ""
return func() {
entry.core.cachedPath = data.Path{}
entry.core.cachedDe = data.DirEntry{}
entry.core.parent = oldParent
entry.core.pathNode.Name = oldName
}
} | go | func (ncs *nodeCacheStandard) Unlink(
ref data.BlockRef, oldPath data.Path, oldDe data.DirEntry) (undoFn func()) {
if ref == (data.BlockRef{}) {
return nil
}
// Temporary code to track down bad block pointers. Remove (or
// return an error) when not needed anymore.
if !ref.IsValid() {
panic(InvalidBlockRefError{ref})
}
ncs.lock.Lock()
defer ncs.lock.Unlock()
entry, ok := ncs.nodes[ref]
if !ok {
return nil
}
if entry.core.cachedPath.IsValid() {
// Already unlinked!
return nil
}
oldParent := entry.core.parent
oldName := entry.core.pathNode.Name
entry.core.cachedPath = oldPath
entry.core.cachedDe = oldDe
entry.core.parent = nil
entry.core.pathNode.Name = ""
return func() {
entry.core.cachedPath = data.Path{}
entry.core.cachedDe = data.DirEntry{}
entry.core.parent = oldParent
entry.core.pathNode.Name = oldName
}
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"Unlink",
"(",
"ref",
"data",
".",
"BlockRef",
",",
"oldPath",
"data",
".",
"Path",
",",
"oldDe",
"data",
".",
"DirEntry",
")",
"(",
"undoFn",
"func",
"(",
")",
")",
"{",
"if",
"ref",
"==",
"(",
"data",
".",
"BlockRef",
"{",
"}",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Temporary code to track down bad block pointers. Remove (or",
"// return an error) when not needed anymore.",
"if",
"!",
"ref",
".",
"IsValid",
"(",
")",
"{",
"panic",
"(",
"InvalidBlockRefError",
"{",
"ref",
"}",
")",
"\n",
"}",
"\n\n",
"ncs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"entry",
",",
"ok",
":=",
"ncs",
".",
"nodes",
"[",
"ref",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"entry",
".",
"core",
".",
"cachedPath",
".",
"IsValid",
"(",
")",
"{",
"// Already unlinked!",
"return",
"nil",
"\n",
"}",
"\n\n",
"oldParent",
":=",
"entry",
".",
"core",
".",
"parent",
"\n",
"oldName",
":=",
"entry",
".",
"core",
".",
"pathNode",
".",
"Name",
"\n\n",
"entry",
".",
"core",
".",
"cachedPath",
"=",
"oldPath",
"\n",
"entry",
".",
"core",
".",
"cachedDe",
"=",
"oldDe",
"\n",
"entry",
".",
"core",
".",
"parent",
"=",
"nil",
"\n",
"entry",
".",
"core",
".",
"pathNode",
".",
"Name",
"=",
"\"",
"\"",
"\n\n",
"return",
"func",
"(",
")",
"{",
"entry",
".",
"core",
".",
"cachedPath",
"=",
"data",
".",
"Path",
"{",
"}",
"\n",
"entry",
".",
"core",
".",
"cachedDe",
"=",
"data",
".",
"DirEntry",
"{",
"}",
"\n",
"entry",
".",
"core",
".",
"parent",
"=",
"oldParent",
"\n",
"entry",
".",
"core",
".",
"pathNode",
".",
"Name",
"=",
"oldName",
"\n",
"}",
"\n",
"}"
] | // Unlink implements the NodeCache interface for nodeCacheStandard. | [
"Unlink",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L258-L296 |
161,472 | keybase/client | go/kbfs/libkbfs/node_cache.go | IsUnlinked | func (ncs *nodeCacheStandard) IsUnlinked(node Node) bool {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
return false
}
return ns.core.cachedPath.IsValid()
} | go | func (ncs *nodeCacheStandard) IsUnlinked(node Node) bool {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
return false
}
return ns.core.cachedPath.IsValid()
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"IsUnlinked",
"(",
"node",
"Node",
")",
"bool",
"{",
"ncs",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"ns",
",",
"ok",
":=",
"node",
".",
"Unwrap",
"(",
")",
".",
"(",
"*",
"nodeStandard",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"ns",
".",
"core",
".",
"cachedPath",
".",
"IsValid",
"(",
")",
"\n",
"}"
] | // IsUnlinked implements the NodeCache interface for
// nodeCacheStandard. | [
"IsUnlinked",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L300-L310 |
161,473 | keybase/client | go/kbfs/libkbfs/node_cache.go | UnlinkedDirEntry | func (ncs *nodeCacheStandard) UnlinkedDirEntry(node Node) data.DirEntry {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
return data.DirEntry{}
}
return ns.core.cachedDe
} | go | func (ncs *nodeCacheStandard) UnlinkedDirEntry(node Node) data.DirEntry {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
return data.DirEntry{}
}
return ns.core.cachedDe
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"UnlinkedDirEntry",
"(",
"node",
"Node",
")",
"data",
".",
"DirEntry",
"{",
"ncs",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"ns",
",",
"ok",
":=",
"node",
".",
"Unwrap",
"(",
")",
".",
"(",
"*",
"nodeStandard",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"data",
".",
"DirEntry",
"{",
"}",
"\n",
"}",
"\n\n",
"return",
"ns",
".",
"core",
".",
"cachedDe",
"\n",
"}"
] | // UnlinkedDirEntry implements the NodeCache interface for
// nodeCacheStandard. | [
"UnlinkedDirEntry",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L314-L324 |
161,474 | keybase/client | go/kbfs/libkbfs/node_cache.go | UpdateUnlinkedDirEntry | func (ncs *nodeCacheStandard) UpdateUnlinkedDirEntry(
node Node, newDe data.DirEntry) {
ncs.lock.Lock()
defer ncs.lock.Unlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
return
}
ns.core.cachedDe = newDe
} | go | func (ncs *nodeCacheStandard) UpdateUnlinkedDirEntry(
node Node, newDe data.DirEntry) {
ncs.lock.Lock()
defer ncs.lock.Unlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
return
}
ns.core.cachedDe = newDe
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"UpdateUnlinkedDirEntry",
"(",
"node",
"Node",
",",
"newDe",
"data",
".",
"DirEntry",
")",
"{",
"ncs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"ns",
",",
"ok",
":=",
"node",
".",
"Unwrap",
"(",
")",
".",
"(",
"*",
"nodeStandard",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n\n",
"ns",
".",
"core",
".",
"cachedDe",
"=",
"newDe",
"\n",
"}"
] | // UpdateUnlinkedDirEntry implements the NodeCache interface for
// nodeCacheStandard. | [
"UpdateUnlinkedDirEntry",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L328-L339 |
161,475 | keybase/client | go/kbfs/libkbfs/node_cache.go | PathFromNode | func (ncs *nodeCacheStandard) PathFromNode(node Node) (p data.Path) {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
p.Path = nil
return
}
for ns != nil {
core := ns.core
if core.parent == nil && len(core.cachedPath.Path) > 0 {
// The node was unlinked, but is still in use, so use its
// cached path. The path is already reversed, so append
// it backwards one-by-one to the existing path. If this
// is the first node, we can just optimize by returning
// the complete cached path.
if len(p.Path) == 0 {
return core.cachedPath
}
for i := len(core.cachedPath.Path) - 1; i >= 0; i-- {
p.Path = append(p.Path, core.cachedPath.Path[i])
}
break
}
p.Path = append(p.Path, *core.pathNode)
if core.parent != nil {
ns = core.parent.Unwrap().(*nodeStandard)
} else {
break
}
}
// need to reverse the path nodes
for i := len(p.Path)/2 - 1; i >= 0; i-- {
opp := len(p.Path) - 1 - i
p.Path[i], p.Path[opp] = p.Path[opp], p.Path[i]
}
// TODO: would it make any sense to cache the constructed path?
p.FolderBranch = ncs.folderBranch
return
} | go | func (ncs *nodeCacheStandard) PathFromNode(node Node) (p data.Path) {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
ns, ok := node.Unwrap().(*nodeStandard)
if !ok {
p.Path = nil
return
}
for ns != nil {
core := ns.core
if core.parent == nil && len(core.cachedPath.Path) > 0 {
// The node was unlinked, but is still in use, so use its
// cached path. The path is already reversed, so append
// it backwards one-by-one to the existing path. If this
// is the first node, we can just optimize by returning
// the complete cached path.
if len(p.Path) == 0 {
return core.cachedPath
}
for i := len(core.cachedPath.Path) - 1; i >= 0; i-- {
p.Path = append(p.Path, core.cachedPath.Path[i])
}
break
}
p.Path = append(p.Path, *core.pathNode)
if core.parent != nil {
ns = core.parent.Unwrap().(*nodeStandard)
} else {
break
}
}
// need to reverse the path nodes
for i := len(p.Path)/2 - 1; i >= 0; i-- {
opp := len(p.Path) - 1 - i
p.Path[i], p.Path[opp] = p.Path[opp], p.Path[i]
}
// TODO: would it make any sense to cache the constructed path?
p.FolderBranch = ncs.folderBranch
return
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"PathFromNode",
"(",
"node",
"Node",
")",
"(",
"p",
"data",
".",
"Path",
")",
"{",
"ncs",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"ns",
",",
"ok",
":=",
"node",
".",
"Unwrap",
"(",
")",
".",
"(",
"*",
"nodeStandard",
")",
"\n",
"if",
"!",
"ok",
"{",
"p",
".",
"Path",
"=",
"nil",
"\n",
"return",
"\n",
"}",
"\n\n",
"for",
"ns",
"!=",
"nil",
"{",
"core",
":=",
"ns",
".",
"core",
"\n",
"if",
"core",
".",
"parent",
"==",
"nil",
"&&",
"len",
"(",
"core",
".",
"cachedPath",
".",
"Path",
")",
">",
"0",
"{",
"// The node was unlinked, but is still in use, so use its",
"// cached path. The path is already reversed, so append",
"// it backwards one-by-one to the existing path. If this",
"// is the first node, we can just optimize by returning",
"// the complete cached path.",
"if",
"len",
"(",
"p",
".",
"Path",
")",
"==",
"0",
"{",
"return",
"core",
".",
"cachedPath",
"\n",
"}",
"\n",
"for",
"i",
":=",
"len",
"(",
"core",
".",
"cachedPath",
".",
"Path",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"p",
".",
"Path",
"=",
"append",
"(",
"p",
".",
"Path",
",",
"core",
".",
"cachedPath",
".",
"Path",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"break",
"\n",
"}",
"\n\n",
"p",
".",
"Path",
"=",
"append",
"(",
"p",
".",
"Path",
",",
"*",
"core",
".",
"pathNode",
")",
"\n",
"if",
"core",
".",
"parent",
"!=",
"nil",
"{",
"ns",
"=",
"core",
".",
"parent",
".",
"Unwrap",
"(",
")",
".",
"(",
"*",
"nodeStandard",
")",
"\n",
"}",
"else",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"// need to reverse the path nodes",
"for",
"i",
":=",
"len",
"(",
"p",
".",
"Path",
")",
"/",
"2",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"opp",
":=",
"len",
"(",
"p",
".",
"Path",
")",
"-",
"1",
"-",
"i",
"\n",
"p",
".",
"Path",
"[",
"i",
"]",
",",
"p",
".",
"Path",
"[",
"opp",
"]",
"=",
"p",
".",
"Path",
"[",
"opp",
"]",
",",
"p",
".",
"Path",
"[",
"i",
"]",
"\n",
"}",
"\n\n",
"// TODO: would it make any sense to cache the constructed path?",
"p",
".",
"FolderBranch",
"=",
"ncs",
".",
"folderBranch",
"\n",
"return",
"\n",
"}"
] | // PathFromNode implements the NodeCache interface for nodeCacheStandard. | [
"PathFromNode",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L342-L386 |
161,476 | keybase/client | go/kbfs/libkbfs/node_cache.go | AllNodes | func (ncs *nodeCacheStandard) AllNodes() (nodes []Node) {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
nodes = make([]Node, 0, len(ncs.nodes))
for _, entry := range ncs.nodes {
nodes = append(nodes, ncs.makeNodeStandardForEntryLocked(entry))
}
return nodes
} | go | func (ncs *nodeCacheStandard) AllNodes() (nodes []Node) {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
nodes = make([]Node, 0, len(ncs.nodes))
for _, entry := range ncs.nodes {
nodes = append(nodes, ncs.makeNodeStandardForEntryLocked(entry))
}
return nodes
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"AllNodes",
"(",
")",
"(",
"nodes",
"[",
"]",
"Node",
")",
"{",
"ncs",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"nodes",
"=",
"make",
"(",
"[",
"]",
"Node",
",",
"0",
",",
"len",
"(",
"ncs",
".",
"nodes",
")",
")",
"\n",
"for",
"_",
",",
"entry",
":=",
"range",
"ncs",
".",
"nodes",
"{",
"nodes",
"=",
"append",
"(",
"nodes",
",",
"ncs",
".",
"makeNodeStandardForEntryLocked",
"(",
"entry",
")",
")",
"\n",
"}",
"\n",
"return",
"nodes",
"\n",
"}"
] | // AllNodes implements the NodeCache interface for nodeCacheStandard. | [
"AllNodes",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L389-L397 |
161,477 | keybase/client | go/kbfs/libkbfs/node_cache.go | AllNodeChildren | func (ncs *nodeCacheStandard) AllNodeChildren(n Node) (nodes []Node) {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
nodes = make([]Node, 0, len(ncs.nodes))
entryIDs := make(map[NodeID]bool)
for _, entry := range ncs.nodes {
var pathIDs []NodeID
parent := entry.core.parent
for parent != nil {
// If the node's parent is what we're looking for (or on
// the path to what we're looking for), include it in the
// list.
parentID := parent.GetID()
if parentID == n.GetID() || entryIDs[parentID] {
nodes = append(nodes, ncs.makeNodeStandardForEntryLocked(entry))
for _, id := range pathIDs {
entryIDs[id] = true
}
entryIDs[entry.core] = true
break
}
// Otherwise, remember this parent and continue back
// toward the root.
pathIDs = append(pathIDs, parentID)
ns, ok := parent.Unwrap().(*nodeStandard)
if !ok {
break
}
parent = ns.core.parent
}
}
return nodes
} | go | func (ncs *nodeCacheStandard) AllNodeChildren(n Node) (nodes []Node) {
ncs.lock.RLock()
defer ncs.lock.RUnlock()
nodes = make([]Node, 0, len(ncs.nodes))
entryIDs := make(map[NodeID]bool)
for _, entry := range ncs.nodes {
var pathIDs []NodeID
parent := entry.core.parent
for parent != nil {
// If the node's parent is what we're looking for (or on
// the path to what we're looking for), include it in the
// list.
parentID := parent.GetID()
if parentID == n.GetID() || entryIDs[parentID] {
nodes = append(nodes, ncs.makeNodeStandardForEntryLocked(entry))
for _, id := range pathIDs {
entryIDs[id] = true
}
entryIDs[entry.core] = true
break
}
// Otherwise, remember this parent and continue back
// toward the root.
pathIDs = append(pathIDs, parentID)
ns, ok := parent.Unwrap().(*nodeStandard)
if !ok {
break
}
parent = ns.core.parent
}
}
return nodes
} | [
"func",
"(",
"ncs",
"*",
"nodeCacheStandard",
")",
"AllNodeChildren",
"(",
"n",
"Node",
")",
"(",
"nodes",
"[",
"]",
"Node",
")",
"{",
"ncs",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ncs",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"nodes",
"=",
"make",
"(",
"[",
"]",
"Node",
",",
"0",
",",
"len",
"(",
"ncs",
".",
"nodes",
")",
")",
"\n",
"entryIDs",
":=",
"make",
"(",
"map",
"[",
"NodeID",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"entry",
":=",
"range",
"ncs",
".",
"nodes",
"{",
"var",
"pathIDs",
"[",
"]",
"NodeID",
"\n",
"parent",
":=",
"entry",
".",
"core",
".",
"parent",
"\n",
"for",
"parent",
"!=",
"nil",
"{",
"// If the node's parent is what we're looking for (or on",
"// the path to what we're looking for), include it in the",
"// list.",
"parentID",
":=",
"parent",
".",
"GetID",
"(",
")",
"\n",
"if",
"parentID",
"==",
"n",
".",
"GetID",
"(",
")",
"||",
"entryIDs",
"[",
"parentID",
"]",
"{",
"nodes",
"=",
"append",
"(",
"nodes",
",",
"ncs",
".",
"makeNodeStandardForEntryLocked",
"(",
"entry",
")",
")",
"\n",
"for",
"_",
",",
"id",
":=",
"range",
"pathIDs",
"{",
"entryIDs",
"[",
"id",
"]",
"=",
"true",
"\n",
"}",
"\n",
"entryIDs",
"[",
"entry",
".",
"core",
"]",
"=",
"true",
"\n",
"break",
"\n",
"}",
"\n\n",
"// Otherwise, remember this parent and continue back",
"// toward the root.",
"pathIDs",
"=",
"append",
"(",
"pathIDs",
",",
"parentID",
")",
"\n",
"ns",
",",
"ok",
":=",
"parent",
".",
"Unwrap",
"(",
")",
".",
"(",
"*",
"nodeStandard",
")",
"\n",
"if",
"!",
"ok",
"{",
"break",
"\n",
"}",
"\n",
"parent",
"=",
"ns",
".",
"core",
".",
"parent",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nodes",
"\n",
"}"
] | // AllNodeChildren implements the NodeCache interface for nodeCacheStandard. | [
"AllNodeChildren",
"implements",
"the",
"NodeCache",
"interface",
"for",
"nodeCacheStandard",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/node_cache.go#L400-L433 |
161,478 | keybase/client | go/kbfs/libfs/mode.go | IsWriter | func IsWriter(ctx context.Context, kbpki libkbfs.KBPKI,
osg idutil.OfflineStatusGetter, h *tlfhandle.Handle) (bool, error) {
session, err := idutil.GetCurrentSessionIfPossible(
ctx, kbpki, h.Type() == tlf.Public)
// We are using GetCurrentUserInfoIfPossible here so err is only non-nil if
// a real problem happened. If the user is logged out, we will get an empty
// username and uid, with a nil error.
if err != nil {
return false, err
}
if h.TypeForKeying() == tlf.TeamKeying {
tid, err := h.FirstResolvedWriter().AsTeam()
if err != nil {
return false, err
}
offline := keybase1.OfflineAvailability_NONE
if osg != nil {
offline = osg.OfflineAvailabilityForID(h.TlfID())
}
isWriter, err := kbpki.IsTeamWriter(
ctx, tid, session.UID, session.VerifyingKey, offline)
if err != nil {
return false, err
}
return isWriter, nil
}
return h.IsWriter(session.UID), nil
} | go | func IsWriter(ctx context.Context, kbpki libkbfs.KBPKI,
osg idutil.OfflineStatusGetter, h *tlfhandle.Handle) (bool, error) {
session, err := idutil.GetCurrentSessionIfPossible(
ctx, kbpki, h.Type() == tlf.Public)
// We are using GetCurrentUserInfoIfPossible here so err is only non-nil if
// a real problem happened. If the user is logged out, we will get an empty
// username and uid, with a nil error.
if err != nil {
return false, err
}
if h.TypeForKeying() == tlf.TeamKeying {
tid, err := h.FirstResolvedWriter().AsTeam()
if err != nil {
return false, err
}
offline := keybase1.OfflineAvailability_NONE
if osg != nil {
offline = osg.OfflineAvailabilityForID(h.TlfID())
}
isWriter, err := kbpki.IsTeamWriter(
ctx, tid, session.UID, session.VerifyingKey, offline)
if err != nil {
return false, err
}
return isWriter, nil
}
return h.IsWriter(session.UID), nil
} | [
"func",
"IsWriter",
"(",
"ctx",
"context",
".",
"Context",
",",
"kbpki",
"libkbfs",
".",
"KBPKI",
",",
"osg",
"idutil",
".",
"OfflineStatusGetter",
",",
"h",
"*",
"tlfhandle",
".",
"Handle",
")",
"(",
"bool",
",",
"error",
")",
"{",
"session",
",",
"err",
":=",
"idutil",
".",
"GetCurrentSessionIfPossible",
"(",
"ctx",
",",
"kbpki",
",",
"h",
".",
"Type",
"(",
")",
"==",
"tlf",
".",
"Public",
")",
"\n",
"// We are using GetCurrentUserInfoIfPossible here so err is only non-nil if",
"// a real problem happened. If the user is logged out, we will get an empty",
"// username and uid, with a nil error.",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"if",
"h",
".",
"TypeForKeying",
"(",
")",
"==",
"tlf",
".",
"TeamKeying",
"{",
"tid",
",",
"err",
":=",
"h",
".",
"FirstResolvedWriter",
"(",
")",
".",
"AsTeam",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"offline",
":=",
"keybase1",
".",
"OfflineAvailability_NONE",
"\n",
"if",
"osg",
"!=",
"nil",
"{",
"offline",
"=",
"osg",
".",
"OfflineAvailabilityForID",
"(",
"h",
".",
"TlfID",
"(",
")",
")",
"\n",
"}",
"\n",
"isWriter",
",",
"err",
":=",
"kbpki",
".",
"IsTeamWriter",
"(",
"ctx",
",",
"tid",
",",
"session",
".",
"UID",
",",
"session",
".",
"VerifyingKey",
",",
"offline",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"isWriter",
",",
"nil",
"\n",
"}",
"\n",
"return",
"h",
".",
"IsWriter",
"(",
"session",
".",
"UID",
")",
",",
"nil",
"\n",
"}"
] | // IsWriter returns whether or not the currently logged-in user is a
// valid writer for the folder described by `h`. | [
"IsWriter",
"returns",
"whether",
"or",
"not",
"the",
"currently",
"logged",
"-",
"in",
"user",
"is",
"a",
"valid",
"writer",
"for",
"the",
"folder",
"described",
"by",
"h",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/mode.go#L20-L47 |
161,479 | keybase/client | go/kbfs/libfs/mode.go | WritePermMode | func WritePermMode(
ctx context.Context, node libkbfs.Node, original os.FileMode,
kbpki libkbfs.KBPKI, osg idutil.OfflineStatusGetter,
h *tlfhandle.Handle) (os.FileMode, error) {
original &^= os.FileMode(0222) // clear write perm bits
if node != nil && node.Readonly(ctx) {
return original, nil
}
isWriter, err := IsWriter(ctx, kbpki, osg, h)
if err != nil {
return 0, err
}
if isWriter {
original |= 0200
}
return original, nil
} | go | func WritePermMode(
ctx context.Context, node libkbfs.Node, original os.FileMode,
kbpki libkbfs.KBPKI, osg idutil.OfflineStatusGetter,
h *tlfhandle.Handle) (os.FileMode, error) {
original &^= os.FileMode(0222) // clear write perm bits
if node != nil && node.Readonly(ctx) {
return original, nil
}
isWriter, err := IsWriter(ctx, kbpki, osg, h)
if err != nil {
return 0, err
}
if isWriter {
original |= 0200
}
return original, nil
} | [
"func",
"WritePermMode",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"libkbfs",
".",
"Node",
",",
"original",
"os",
".",
"FileMode",
",",
"kbpki",
"libkbfs",
".",
"KBPKI",
",",
"osg",
"idutil",
".",
"OfflineStatusGetter",
",",
"h",
"*",
"tlfhandle",
".",
"Handle",
")",
"(",
"os",
".",
"FileMode",
",",
"error",
")",
"{",
"original",
"&^=",
"os",
".",
"FileMode",
"(",
"0222",
")",
"// clear write perm bits",
"\n\n",
"if",
"node",
"!=",
"nil",
"&&",
"node",
".",
"Readonly",
"(",
"ctx",
")",
"{",
"return",
"original",
",",
"nil",
"\n",
"}",
"\n\n",
"isWriter",
",",
"err",
":=",
"IsWriter",
"(",
"ctx",
",",
"kbpki",
",",
"osg",
",",
"h",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"isWriter",
"{",
"original",
"|=",
"0200",
"\n",
"}",
"\n\n",
"return",
"original",
",",
"nil",
"\n",
"}"
] | // WritePermMode fills in original based on whether or not the
// currently logged-in user is a valid writer for the folder described
// by `h`. | [
"WritePermMode",
"fills",
"in",
"original",
"based",
"on",
"whether",
"or",
"not",
"the",
"currently",
"logged",
"-",
"in",
"user",
"is",
"a",
"valid",
"writer",
"for",
"the",
"folder",
"described",
"by",
"h",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/mode.go#L52-L71 |
161,480 | keybase/client | go/kbfs/libkbfs/journal_md_ops.go | convertImmutableBareRMDToIRMD | func (j journalMDOps) convertImmutableBareRMDToIRMD(ctx context.Context,
ibrmd ImmutableBareRootMetadata, handle *tlfhandle.Handle,
uid keybase1.UID, key kbfscrypto.VerifyingKey) (
ImmutableRootMetadata, error) {
// TODO: Avoid having to do this type assertion.
brmd, ok := ibrmd.RootMetadata.(kbfsmd.MutableRootMetadata)
if !ok {
return ImmutableRootMetadata{}, kbfsmd.MutableRootMetadataNoImplError{}
}
rmd := makeRootMetadata(brmd, ibrmd.extra, handle)
config := j.jManager.config
pmd, err := decryptMDPrivateData(ctx, config.Codec(), config.Crypto(),
config.BlockCache(), config.BlockOps(), config.KeyManager(),
config.KBPKI(), config, config.Mode(), uid,
rmd.GetSerializedPrivateMetadata(), rmd, rmd, j.jManager.log)
if err != nil {
return ImmutableRootMetadata{}, err
}
rmd.data = pmd
irmd := MakeImmutableRootMetadata(
rmd, key, ibrmd.mdID, ibrmd.localTimestamp, false)
return irmd, nil
} | go | func (j journalMDOps) convertImmutableBareRMDToIRMD(ctx context.Context,
ibrmd ImmutableBareRootMetadata, handle *tlfhandle.Handle,
uid keybase1.UID, key kbfscrypto.VerifyingKey) (
ImmutableRootMetadata, error) {
// TODO: Avoid having to do this type assertion.
brmd, ok := ibrmd.RootMetadata.(kbfsmd.MutableRootMetadata)
if !ok {
return ImmutableRootMetadata{}, kbfsmd.MutableRootMetadataNoImplError{}
}
rmd := makeRootMetadata(brmd, ibrmd.extra, handle)
config := j.jManager.config
pmd, err := decryptMDPrivateData(ctx, config.Codec(), config.Crypto(),
config.BlockCache(), config.BlockOps(), config.KeyManager(),
config.KBPKI(), config, config.Mode(), uid,
rmd.GetSerializedPrivateMetadata(), rmd, rmd, j.jManager.log)
if err != nil {
return ImmutableRootMetadata{}, err
}
rmd.data = pmd
irmd := MakeImmutableRootMetadata(
rmd, key, ibrmd.mdID, ibrmd.localTimestamp, false)
return irmd, nil
} | [
"func",
"(",
"j",
"journalMDOps",
")",
"convertImmutableBareRMDToIRMD",
"(",
"ctx",
"context",
".",
"Context",
",",
"ibrmd",
"ImmutableBareRootMetadata",
",",
"handle",
"*",
"tlfhandle",
".",
"Handle",
",",
"uid",
"keybase1",
".",
"UID",
",",
"key",
"kbfscrypto",
".",
"VerifyingKey",
")",
"(",
"ImmutableRootMetadata",
",",
"error",
")",
"{",
"// TODO: Avoid having to do this type assertion.",
"brmd",
",",
"ok",
":=",
"ibrmd",
".",
"RootMetadata",
".",
"(",
"kbfsmd",
".",
"MutableRootMetadata",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"kbfsmd",
".",
"MutableRootMetadataNoImplError",
"{",
"}",
"\n",
"}",
"\n\n",
"rmd",
":=",
"makeRootMetadata",
"(",
"brmd",
",",
"ibrmd",
".",
"extra",
",",
"handle",
")",
"\n\n",
"config",
":=",
"j",
".",
"jManager",
".",
"config",
"\n",
"pmd",
",",
"err",
":=",
"decryptMDPrivateData",
"(",
"ctx",
",",
"config",
".",
"Codec",
"(",
")",
",",
"config",
".",
"Crypto",
"(",
")",
",",
"config",
".",
"BlockCache",
"(",
")",
",",
"config",
".",
"BlockOps",
"(",
")",
",",
"config",
".",
"KeyManager",
"(",
")",
",",
"config",
".",
"KBPKI",
"(",
")",
",",
"config",
",",
"config",
".",
"Mode",
"(",
")",
",",
"uid",
",",
"rmd",
".",
"GetSerializedPrivateMetadata",
"(",
")",
",",
"rmd",
",",
"rmd",
",",
"j",
".",
"jManager",
".",
"log",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ImmutableRootMetadata",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"rmd",
".",
"data",
"=",
"pmd",
"\n",
"irmd",
":=",
"MakeImmutableRootMetadata",
"(",
"rmd",
",",
"key",
",",
"ibrmd",
".",
"mdID",
",",
"ibrmd",
".",
"localTimestamp",
",",
"false",
")",
"\n",
"return",
"irmd",
",",
"nil",
"\n",
"}"
] | // convertImmutableBareRMDToIRMD decrypts the bare MD into a
// full-fledged RMD. The MD is assumed to have been read from the
// journal. | [
"convertImmutableBareRMDToIRMD",
"decrypts",
"the",
"bare",
"MD",
"into",
"a",
"full",
"-",
"fledged",
"RMD",
".",
"The",
"MD",
"is",
"assumed",
"to",
"have",
"been",
"read",
"from",
"the",
"journal",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/journal_md_ops.go#L47-L72 |
161,481 | keybase/client | go/kbfs/libkbfs/journal_md_ops.go | GetIDForHandle | func (j journalMDOps) GetIDForHandle(
ctx context.Context, handle *tlfhandle.Handle) (id tlf.ID, err error) {
id, err = j.MDOps.GetIDForHandle(ctx, handle)
if err != nil {
return tlf.NullID, err
}
if id == tlf.NullID {
return id, nil
}
// Create the journal if needed, while we have access to `handle`.
_, _ = j.jManager.getTLFJournal(id, handle)
return id, nil
} | go | func (j journalMDOps) GetIDForHandle(
ctx context.Context, handle *tlfhandle.Handle) (id tlf.ID, err error) {
id, err = j.MDOps.GetIDForHandle(ctx, handle)
if err != nil {
return tlf.NullID, err
}
if id == tlf.NullID {
return id, nil
}
// Create the journal if needed, while we have access to `handle`.
_, _ = j.jManager.getTLFJournal(id, handle)
return id, nil
} | [
"func",
"(",
"j",
"journalMDOps",
")",
"GetIDForHandle",
"(",
"ctx",
"context",
".",
"Context",
",",
"handle",
"*",
"tlfhandle",
".",
"Handle",
")",
"(",
"id",
"tlf",
".",
"ID",
",",
"err",
"error",
")",
"{",
"id",
",",
"err",
"=",
"j",
".",
"MDOps",
".",
"GetIDForHandle",
"(",
"ctx",
",",
"handle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"tlf",
".",
"NullID",
",",
"err",
"\n",
"}",
"\n",
"if",
"id",
"==",
"tlf",
".",
"NullID",
"{",
"return",
"id",
",",
"nil",
"\n",
"}",
"\n",
"// Create the journal if needed, while we have access to `handle`.",
"_",
",",
"_",
"=",
"j",
".",
"jManager",
".",
"getTLFJournal",
"(",
"id",
",",
"handle",
")",
"\n",
"return",
"id",
",",
"nil",
"\n",
"}"
] | // GetIDForHandle implements the MDOps interface for journalMDOps. | [
"GetIDForHandle",
"implements",
"the",
"MDOps",
"interface",
"for",
"journalMDOps",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/journal_md_ops.go#L234-L246 |
161,482 | keybase/client | go/libkb/user.go | GetActivePGPKeys | func (u *User) GetActivePGPKeys(sibkey bool) (ret []*PGPKeyBundle) {
if ckf := u.GetComputedKeyFamily(); ckf != nil {
ret = ckf.GetActivePGPKeys(sibkey)
}
return
} | go | func (u *User) GetActivePGPKeys(sibkey bool) (ret []*PGPKeyBundle) {
if ckf := u.GetComputedKeyFamily(); ckf != nil {
ret = ckf.GetActivePGPKeys(sibkey)
}
return
} | [
"func",
"(",
"u",
"*",
"User",
")",
"GetActivePGPKeys",
"(",
"sibkey",
"bool",
")",
"(",
"ret",
"[",
"]",
"*",
"PGPKeyBundle",
")",
"{",
"if",
"ckf",
":=",
"u",
".",
"GetComputedKeyFamily",
"(",
")",
";",
"ckf",
"!=",
"nil",
"{",
"ret",
"=",
"ckf",
".",
"GetActivePGPKeys",
"(",
"sibkey",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetActivePGPKeys looks into the user's ComputedKeyFamily and
// returns only the active PGP keys. If you want only sibkeys, then
// specify sibkey=true. | [
"GetActivePGPKeys",
"looks",
"into",
"the",
"user",
"s",
"ComputedKeyFamily",
"and",
"returns",
"only",
"the",
"active",
"PGP",
"keys",
".",
"If",
"you",
"want",
"only",
"sibkeys",
"then",
"specify",
"sibkey",
"=",
"true",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L222-L227 |
161,483 | keybase/client | go/libkb/user.go | FilterActivePGPKeys | func (u *User) FilterActivePGPKeys(sibkey bool, query string) []*PGPKeyBundle {
keys := u.GetActivePGPKeys(sibkey)
var res []*PGPKeyBundle
for _, k := range keys {
if KeyMatchesQuery(k, query, false) {
res = append(res, k)
}
}
return res
} | go | func (u *User) FilterActivePGPKeys(sibkey bool, query string) []*PGPKeyBundle {
keys := u.GetActivePGPKeys(sibkey)
var res []*PGPKeyBundle
for _, k := range keys {
if KeyMatchesQuery(k, query, false) {
res = append(res, k)
}
}
return res
} | [
"func",
"(",
"u",
"*",
"User",
")",
"FilterActivePGPKeys",
"(",
"sibkey",
"bool",
",",
"query",
"string",
")",
"[",
"]",
"*",
"PGPKeyBundle",
"{",
"keys",
":=",
"u",
".",
"GetActivePGPKeys",
"(",
"sibkey",
")",
"\n",
"var",
"res",
"[",
"]",
"*",
"PGPKeyBundle",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"keys",
"{",
"if",
"KeyMatchesQuery",
"(",
"k",
",",
"query",
",",
"false",
")",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"k",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] | // FilterActivePGPKeys returns the active pgp keys that match
// query. | [
"FilterActivePGPKeys",
"returns",
"the",
"active",
"pgp",
"keys",
"that",
"match",
"query",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L231-L240 |
161,484 | keybase/client | go/libkb/user.go | AllSyncedSecretKeys | func (u *User) AllSyncedSecretKeys(m MetaContext) (keys []*SKB, err error) {
defer m.Trace("User#AllSyncedSecretKeys", func() error { return err })()
m.Dump()
ss, err := m.SyncSecretsForUID(u.GetUID())
if err != nil {
return nil, err
}
ckf := u.GetComputedKeyFamily()
if ckf == nil {
m.Debug("| short-circuit; no Computed key family")
return nil, nil
}
keys = ss.AllActiveKeys(ckf)
return keys, nil
} | go | func (u *User) AllSyncedSecretKeys(m MetaContext) (keys []*SKB, err error) {
defer m.Trace("User#AllSyncedSecretKeys", func() error { return err })()
m.Dump()
ss, err := m.SyncSecretsForUID(u.GetUID())
if err != nil {
return nil, err
}
ckf := u.GetComputedKeyFamily()
if ckf == nil {
m.Debug("| short-circuit; no Computed key family")
return nil, nil
}
keys = ss.AllActiveKeys(ckf)
return keys, nil
} | [
"func",
"(",
"u",
"*",
"User",
")",
"AllSyncedSecretKeys",
"(",
"m",
"MetaContext",
")",
"(",
"keys",
"[",
"]",
"*",
"SKB",
",",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"m",
".",
"Dump",
"(",
")",
"\n\n",
"ss",
",",
"err",
":=",
"m",
".",
"SyncSecretsForUID",
"(",
"u",
".",
"GetUID",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"ckf",
":=",
"u",
".",
"GetComputedKeyFamily",
"(",
")",
"\n",
"if",
"ckf",
"==",
"nil",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"keys",
"=",
"ss",
".",
"AllActiveKeys",
"(",
"ckf",
")",
"\n",
"return",
"keys",
",",
"nil",
"\n",
"}"
] | // AllSyncedSecretKeys returns all the PGP key blocks that were
// synced to API server. LoginContext can be nil if this isn't
// used while logging in, signing up. | [
"AllSyncedSecretKeys",
"returns",
"all",
"the",
"PGP",
"key",
"blocks",
"that",
"were",
"synced",
"to",
"API",
"server",
".",
"LoginContext",
"can",
"be",
"nil",
"if",
"this",
"isn",
"t",
"used",
"while",
"logging",
"in",
"signing",
"up",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L428-L445 |
161,485 | keybase/client | go/libkb/user.go | GetHighLinkSeqnos | func (u *User) GetHighLinkSeqnos(mctx MetaContext) (res []keybase1.Seqno, err error) {
sigChain := u.sigChain()
if sigChain == nil {
return nil, fmt.Errorf("no user sigchain")
}
for _, c := range sigChain.chainLinks {
high, err := c.IsHighUserLink(mctx, u.GetUID())
if err != nil {
return nil, fmt.Errorf("error determining link %v", c.GetSeqno())
}
if high {
res = append(res, c.GetSeqno())
}
}
return res, nil
} | go | func (u *User) GetHighLinkSeqnos(mctx MetaContext) (res []keybase1.Seqno, err error) {
sigChain := u.sigChain()
if sigChain == nil {
return nil, fmt.Errorf("no user sigchain")
}
for _, c := range sigChain.chainLinks {
high, err := c.IsHighUserLink(mctx, u.GetUID())
if err != nil {
return nil, fmt.Errorf("error determining link %v", c.GetSeqno())
}
if high {
res = append(res, c.GetSeqno())
}
}
return res, nil
} | [
"func",
"(",
"u",
"*",
"User",
")",
"GetHighLinkSeqnos",
"(",
"mctx",
"MetaContext",
")",
"(",
"res",
"[",
"]",
"keybase1",
".",
"Seqno",
",",
"err",
"error",
")",
"{",
"sigChain",
":=",
"u",
".",
"sigChain",
"(",
")",
"\n",
"if",
"sigChain",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"sigChain",
".",
"chainLinks",
"{",
"high",
",",
"err",
":=",
"c",
".",
"IsHighUserLink",
"(",
"mctx",
",",
"u",
".",
"GetUID",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"c",
".",
"GetSeqno",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"high",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"c",
".",
"GetSeqno",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // GetHighLinkSeqnos gets the list of all high links in the user's sigchain ascending. | [
"GetHighLinkSeqnos",
"gets",
"the",
"list",
"of",
"all",
"high",
"links",
"in",
"the",
"user",
"s",
"sigchain",
"ascending",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L495-L510 |
161,486 | keybase/client | go/libkb/user.go | localDelegateKey | func (u *User) localDelegateKey(key GenericKey, sigID keybase1.SigID, kid keybase1.KID, isSibkey bool, isEldest bool, merkleHashMeta keybase1.HashMeta, firstAppearedUnverified keybase1.Seqno) (err error) {
if err = u.keyFamily.LocalDelegate(key); err != nil {
return
}
if u.sigChain() == nil {
err = NoSigChainError{}
return
}
err = u.sigChain().LocalDelegate(u.keyFamily, key, sigID, kid, isSibkey, merkleHashMeta, firstAppearedUnverified)
if isEldest {
eldestKID := key.GetKID()
u.leaf.eldest = eldestKID
}
return
} | go | func (u *User) localDelegateKey(key GenericKey, sigID keybase1.SigID, kid keybase1.KID, isSibkey bool, isEldest bool, merkleHashMeta keybase1.HashMeta, firstAppearedUnverified keybase1.Seqno) (err error) {
if err = u.keyFamily.LocalDelegate(key); err != nil {
return
}
if u.sigChain() == nil {
err = NoSigChainError{}
return
}
err = u.sigChain().LocalDelegate(u.keyFamily, key, sigID, kid, isSibkey, merkleHashMeta, firstAppearedUnverified)
if isEldest {
eldestKID := key.GetKID()
u.leaf.eldest = eldestKID
}
return
} | [
"func",
"(",
"u",
"*",
"User",
")",
"localDelegateKey",
"(",
"key",
"GenericKey",
",",
"sigID",
"keybase1",
".",
"SigID",
",",
"kid",
"keybase1",
".",
"KID",
",",
"isSibkey",
"bool",
",",
"isEldest",
"bool",
",",
"merkleHashMeta",
"keybase1",
".",
"HashMeta",
",",
"firstAppearedUnverified",
"keybase1",
".",
"Seqno",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"u",
".",
"keyFamily",
".",
"LocalDelegate",
"(",
"key",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"u",
".",
"sigChain",
"(",
")",
"==",
"nil",
"{",
"err",
"=",
"NoSigChainError",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"err",
"=",
"u",
".",
"sigChain",
"(",
")",
".",
"LocalDelegate",
"(",
"u",
".",
"keyFamily",
",",
"key",
",",
"sigID",
",",
"kid",
",",
"isSibkey",
",",
"merkleHashMeta",
",",
"firstAppearedUnverified",
")",
"\n",
"if",
"isEldest",
"{",
"eldestKID",
":=",
"key",
".",
"GetKID",
"(",
")",
"\n",
"u",
".",
"leaf",
".",
"eldest",
"=",
"eldestKID",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // localDelegateKey takes the given GenericKey and provisions it locally so that
// we can use the key without needing a refresh from the server. The eventual
// refresh we do get from the server will clobber our work here. | [
"localDelegateKey",
"takes",
"the",
"given",
"GenericKey",
"and",
"provisions",
"it",
"locally",
"so",
"that",
"we",
"can",
"use",
"the",
"key",
"without",
"needing",
"a",
"refresh",
"from",
"the",
"server",
".",
"The",
"eventual",
"refresh",
"we",
"do",
"get",
"from",
"the",
"server",
"will",
"clobber",
"our",
"work",
"here",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L645-L659 |
161,487 | keybase/client | go/libkb/user.go | SigChainBump | func (u *User) SigChainBump(linkID LinkID, sigID keybase1.SigID, isHighDelegator bool) {
u.SigChainBumpMT(MerkleTriple{LinkID: linkID, SigID: sigID}, isHighDelegator)
} | go | func (u *User) SigChainBump(linkID LinkID, sigID keybase1.SigID, isHighDelegator bool) {
u.SigChainBumpMT(MerkleTriple{LinkID: linkID, SigID: sigID}, isHighDelegator)
} | [
"func",
"(",
"u",
"*",
"User",
")",
"SigChainBump",
"(",
"linkID",
"LinkID",
",",
"sigID",
"keybase1",
".",
"SigID",
",",
"isHighDelegator",
"bool",
")",
"{",
"u",
".",
"SigChainBumpMT",
"(",
"MerkleTriple",
"{",
"LinkID",
":",
"linkID",
",",
"SigID",
":",
"sigID",
"}",
",",
"isHighDelegator",
")",
"\n",
"}"
] | // SigChainBump is called during a multikey post to update the correct seqno, hash, and
// high skip. When a delegator posts a high link, they specify isHighDelegator=true
// in order to set the new high skip pointer to the delegator's link, so subsequent
// keys in the multikey will supply the correct high skip. | [
"SigChainBump",
"is",
"called",
"during",
"a",
"multikey",
"post",
"to",
"update",
"the",
"correct",
"seqno",
"hash",
"and",
"high",
"skip",
".",
"When",
"a",
"delegator",
"posts",
"a",
"high",
"link",
"they",
"specify",
"isHighDelegator",
"=",
"true",
"in",
"order",
"to",
"set",
"the",
"new",
"high",
"skip",
"pointer",
"to",
"the",
"delegator",
"s",
"link",
"so",
"subsequent",
"keys",
"in",
"the",
"multikey",
"will",
"supply",
"the",
"correct",
"high",
"skip",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L680-L682 |
161,488 | keybase/client | go/libkb/user.go | HasDeviceInCurrentInstall | func (u *User) HasDeviceInCurrentInstall(did keybase1.DeviceID) bool {
ckf := u.GetComputedKeyFamily()
if ckf == nil {
return false
}
_, err := ckf.GetSibkeyForDevice(did)
if err != nil {
return false
}
return true
} | go | func (u *User) HasDeviceInCurrentInstall(did keybase1.DeviceID) bool {
ckf := u.GetComputedKeyFamily()
if ckf == nil {
return false
}
_, err := ckf.GetSibkeyForDevice(did)
if err != nil {
return false
}
return true
} | [
"func",
"(",
"u",
"*",
"User",
")",
"HasDeviceInCurrentInstall",
"(",
"did",
"keybase1",
".",
"DeviceID",
")",
"bool",
"{",
"ckf",
":=",
"u",
".",
"GetComputedKeyFamily",
"(",
")",
"\n",
"if",
"ckf",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"_",
",",
"err",
":=",
"ckf",
".",
"GetSibkeyForDevice",
"(",
"did",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // Returns whether or not the current install has an active device
// sibkey. | [
"Returns",
"whether",
"or",
"not",
"the",
"current",
"install",
"has",
"an",
"active",
"device",
"sibkey",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L720-L731 |
161,489 | keybase/client | go/libkb/user.go | PartialCopy | func (u User) PartialCopy() *User {
ret := &User{
Contextified: NewContextified(u.G()),
id: u.id,
name: u.name,
leaf: u.leaf,
dirty: false,
}
if ckf := u.GetComputedKeyFamily(); ckf != nil {
ret.ckfShallowCopy = ckf.ShallowCopy()
ret.keyFamily = ckf.kf
} else if u.keyFamily != nil {
ret.keyFamily = u.keyFamily.ShallowCopy()
}
return ret
} | go | func (u User) PartialCopy() *User {
ret := &User{
Contextified: NewContextified(u.G()),
id: u.id,
name: u.name,
leaf: u.leaf,
dirty: false,
}
if ckf := u.GetComputedKeyFamily(); ckf != nil {
ret.ckfShallowCopy = ckf.ShallowCopy()
ret.keyFamily = ckf.kf
} else if u.keyFamily != nil {
ret.keyFamily = u.keyFamily.ShallowCopy()
}
return ret
} | [
"func",
"(",
"u",
"User",
")",
"PartialCopy",
"(",
")",
"*",
"User",
"{",
"ret",
":=",
"&",
"User",
"{",
"Contextified",
":",
"NewContextified",
"(",
"u",
".",
"G",
"(",
")",
")",
",",
"id",
":",
"u",
".",
"id",
",",
"name",
":",
"u",
".",
"name",
",",
"leaf",
":",
"u",
".",
"leaf",
",",
"dirty",
":",
"false",
",",
"}",
"\n",
"if",
"ckf",
":=",
"u",
".",
"GetComputedKeyFamily",
"(",
")",
";",
"ckf",
"!=",
"nil",
"{",
"ret",
".",
"ckfShallowCopy",
"=",
"ckf",
".",
"ShallowCopy",
"(",
")",
"\n",
"ret",
".",
"keyFamily",
"=",
"ckf",
".",
"kf",
"\n",
"}",
"else",
"if",
"u",
".",
"keyFamily",
"!=",
"nil",
"{",
"ret",
".",
"keyFamily",
"=",
"u",
".",
"keyFamily",
".",
"ShallowCopy",
"(",
")",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
] | // PartialCopy copies some fields of the User object, but not all.
// For instance, it doesn't copy the SigChain or IDTable, and it only
// makes a shallow copy of the ComputedKeyFamily. | [
"PartialCopy",
"copies",
"some",
"fields",
"of",
"the",
"User",
"object",
"but",
"not",
"all",
".",
"For",
"instance",
"it",
"doesn",
"t",
"copy",
"the",
"SigChain",
"or",
"IDTable",
"and",
"it",
"only",
"makes",
"a",
"shallow",
"copy",
"of",
"the",
"ComputedKeyFamily",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/user.go#L900-L915 |
161,490 | keybase/client | go/protocol/keybase1/identify.go | ResolveImplicitTeam | func (c IdentifyClient) ResolveImplicitTeam(ctx context.Context, __arg ResolveImplicitTeamArg) (res Folder, err error) {
err = c.Cli.Call(ctx, "keybase.1.identify.resolveImplicitTeam", []interface{}{__arg}, &res)
return
} | go | func (c IdentifyClient) ResolveImplicitTeam(ctx context.Context, __arg ResolveImplicitTeamArg) (res Folder, err error) {
err = c.Cli.Call(ctx, "keybase.1.identify.resolveImplicitTeam", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"IdentifyClient",
")",
"ResolveImplicitTeam",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"ResolveImplicitTeamArg",
")",
"(",
"res",
"Folder",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // resolveImplicitTeam returns a TLF display name given a teamID. The publicness
// of the team is inferred from the TeamID. | [
"resolveImplicitTeam",
"returns",
"a",
"TLF",
"display",
"name",
"given",
"a",
"teamID",
".",
"The",
"publicness",
"of",
"the",
"team",
"is",
"inferred",
"from",
"the",
"TeamID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/identify.go#L351-L354 |
161,491 | keybase/client | go/client/cmd_log_profile.go | NewCmdLogProfile | func NewCmdLogProfile(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "profile",
Usage: "Analyze timed traces from logs.",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdLogProfile{Contextified: libkb.NewContextified(g)}, "profile", c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "p, path",
Usage: "Path of logfile to process.",
},
},
}
} | go | func NewCmdLogProfile(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "profile",
Usage: "Analyze timed traces from logs.",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdLogProfile{Contextified: libkb.NewContextified(g)}, "profile", c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "p, path",
Usage: "Path of logfile to process.",
},
},
}
} | [
"func",
"NewCmdLogProfile",
"(",
"cl",
"*",
"libcmdline",
".",
"CommandLine",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"cli",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"Action",
":",
"func",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"cl",
".",
"ChooseCommand",
"(",
"&",
"CmdLogProfile",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
"}",
",",
"\"",
"\"",
",",
"c",
")",
"\n",
"}",
",",
"Flags",
":",
"[",
"]",
"cli",
".",
"Flag",
"{",
"cli",
".",
"StringFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"}",
",",
"}",
",",
"}",
"\n",
"}"
] | // This is a devel-only cmd which can be used to see how long different
// g.CTraceTimed calls are taking. | [
"This",
"is",
"a",
"devel",
"-",
"only",
"cmd",
"which",
"can",
"be",
"used",
"to",
"see",
"how",
"long",
"different",
"g",
".",
"CTraceTimed",
"calls",
"are",
"taking",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_log_profile.go#L15-L29 |
161,492 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | NewKeybaseServiceMeasured | func NewKeybaseServiceMeasured(delegate KeybaseService, r metrics.Registry) KeybaseServiceMeasured {
resolveTimer := metrics.GetOrRegisterTimer("KeybaseService.Resolve", r)
identifyTimer := metrics.GetOrRegisterTimer("KeybaseService.Identify", r)
normalizeSocialAssertionTimer := metrics.GetOrRegisterTimer("KeybaseService.NormalizeSocialAssertion", r)
resolveIdentifyImplicitTeamTimer := metrics.GetOrRegisterTimer(
"KeybaseService.ResolveIdentifyImplicitTeam", r)
resolveImplicitTeamByIDTimer := metrics.GetOrRegisterTimer(
"KeybaseService.ResolveImplicitTeamByID", r)
loadUserPlusKeysTimer := metrics.GetOrRegisterTimer("KeybaseService.LoadUserPlusKeys", r)
loadTeamPlusKeysTimer := metrics.GetOrRegisterTimer("KeybaseService.LoadTeamPlusKeys", r)
createTeamTLFTimer := metrics.GetOrRegisterTimer("KeybaseService.CreateTeamTLF", r)
getTeamSettingsTimer := metrics.GetOrRegisterTimer("KeybaseService.GetTeamSettings", r)
getCurrentMerkleRootTimer := metrics.GetOrRegisterTimer("KeybaseService.GetCurrentMerkleRoot", r)
verifyMerkleRootTimer := metrics.GetOrRegisterTimer("KeybaseService.VerifyMerkleRoot", r)
currentSessionTimer := metrics.GetOrRegisterTimer("KeybaseService.CurrentSession", r)
favoriteAddTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteAdd", r)
favoriteDeleteTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteDelete", r)
favoriteListTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteList", r)
encryptFavoritesTimer := metrics.GetOrRegisterTimer("KeybaseService."+
"EncryptFavorites", r)
decryptFavoritesTimer := metrics.GetOrRegisterTimer("KeybaseService."+
"DecryptFavorites", r)
notifyTimer := metrics.GetOrRegisterTimer("KeybaseService.Notify", r)
notifyPathUpdatedTimer := metrics.GetOrRegisterTimer("KeybaseService.NotifyPathUpdated", r)
putGitMetadataTimer := metrics.GetOrRegisterTimer(
"KeybaseService.PutGitMetadata", r)
return KeybaseServiceMeasured{
delegate: delegate,
resolveTimer: resolveTimer,
identifyTimer: identifyTimer,
normalizeSocialAssertionTimer: normalizeSocialAssertionTimer,
resolveIdentifyImplicitTeamTimer: resolveIdentifyImplicitTeamTimer,
resolveImplicitTeamByIDTimer: resolveImplicitTeamByIDTimer,
loadUserPlusKeysTimer: loadUserPlusKeysTimer,
loadTeamPlusKeysTimer: loadTeamPlusKeysTimer,
createTeamTLFTimer: createTeamTLFTimer,
getTeamSettingsTimer: getTeamSettingsTimer,
getCurrentMerkleRootTimer: getCurrentMerkleRootTimer,
verifyMerkleRootTimer: verifyMerkleRootTimer,
currentSessionTimer: currentSessionTimer,
favoriteAddTimer: favoriteAddTimer,
favoriteDeleteTimer: favoriteDeleteTimer,
favoriteListTimer: favoriteListTimer,
encryptFavoritesTimer: encryptFavoritesTimer,
decryptFavoritesTimer: decryptFavoritesTimer,
notifyTimer: notifyTimer,
notifyPathUpdatedTimer: notifyPathUpdatedTimer,
putGitMetadataTimer: putGitMetadataTimer,
}
} | go | func NewKeybaseServiceMeasured(delegate KeybaseService, r metrics.Registry) KeybaseServiceMeasured {
resolveTimer := metrics.GetOrRegisterTimer("KeybaseService.Resolve", r)
identifyTimer := metrics.GetOrRegisterTimer("KeybaseService.Identify", r)
normalizeSocialAssertionTimer := metrics.GetOrRegisterTimer("KeybaseService.NormalizeSocialAssertion", r)
resolveIdentifyImplicitTeamTimer := metrics.GetOrRegisterTimer(
"KeybaseService.ResolveIdentifyImplicitTeam", r)
resolveImplicitTeamByIDTimer := metrics.GetOrRegisterTimer(
"KeybaseService.ResolveImplicitTeamByID", r)
loadUserPlusKeysTimer := metrics.GetOrRegisterTimer("KeybaseService.LoadUserPlusKeys", r)
loadTeamPlusKeysTimer := metrics.GetOrRegisterTimer("KeybaseService.LoadTeamPlusKeys", r)
createTeamTLFTimer := metrics.GetOrRegisterTimer("KeybaseService.CreateTeamTLF", r)
getTeamSettingsTimer := metrics.GetOrRegisterTimer("KeybaseService.GetTeamSettings", r)
getCurrentMerkleRootTimer := metrics.GetOrRegisterTimer("KeybaseService.GetCurrentMerkleRoot", r)
verifyMerkleRootTimer := metrics.GetOrRegisterTimer("KeybaseService.VerifyMerkleRoot", r)
currentSessionTimer := metrics.GetOrRegisterTimer("KeybaseService.CurrentSession", r)
favoriteAddTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteAdd", r)
favoriteDeleteTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteDelete", r)
favoriteListTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteList", r)
encryptFavoritesTimer := metrics.GetOrRegisterTimer("KeybaseService."+
"EncryptFavorites", r)
decryptFavoritesTimer := metrics.GetOrRegisterTimer("KeybaseService."+
"DecryptFavorites", r)
notifyTimer := metrics.GetOrRegisterTimer("KeybaseService.Notify", r)
notifyPathUpdatedTimer := metrics.GetOrRegisterTimer("KeybaseService.NotifyPathUpdated", r)
putGitMetadataTimer := metrics.GetOrRegisterTimer(
"KeybaseService.PutGitMetadata", r)
return KeybaseServiceMeasured{
delegate: delegate,
resolveTimer: resolveTimer,
identifyTimer: identifyTimer,
normalizeSocialAssertionTimer: normalizeSocialAssertionTimer,
resolveIdentifyImplicitTeamTimer: resolveIdentifyImplicitTeamTimer,
resolveImplicitTeamByIDTimer: resolveImplicitTeamByIDTimer,
loadUserPlusKeysTimer: loadUserPlusKeysTimer,
loadTeamPlusKeysTimer: loadTeamPlusKeysTimer,
createTeamTLFTimer: createTeamTLFTimer,
getTeamSettingsTimer: getTeamSettingsTimer,
getCurrentMerkleRootTimer: getCurrentMerkleRootTimer,
verifyMerkleRootTimer: verifyMerkleRootTimer,
currentSessionTimer: currentSessionTimer,
favoriteAddTimer: favoriteAddTimer,
favoriteDeleteTimer: favoriteDeleteTimer,
favoriteListTimer: favoriteListTimer,
encryptFavoritesTimer: encryptFavoritesTimer,
decryptFavoritesTimer: decryptFavoritesTimer,
notifyTimer: notifyTimer,
notifyPathUpdatedTimer: notifyPathUpdatedTimer,
putGitMetadataTimer: putGitMetadataTimer,
}
} | [
"func",
"NewKeybaseServiceMeasured",
"(",
"delegate",
"KeybaseService",
",",
"r",
"metrics",
".",
"Registry",
")",
"KeybaseServiceMeasured",
"{",
"resolveTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"identifyTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"normalizeSocialAssertionTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"resolveIdentifyImplicitTeamTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"resolveImplicitTeamByIDTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"loadUserPlusKeysTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"loadTeamPlusKeysTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"createTeamTLFTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"getTeamSettingsTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"getCurrentMerkleRootTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"verifyMerkleRootTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"currentSessionTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"favoriteAddTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"favoriteDeleteTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"favoriteListTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"encryptFavoritesTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"r",
")",
"\n",
"decryptFavoritesTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"r",
")",
"\n",
"notifyTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"notifyPathUpdatedTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"putGitMetadataTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"return",
"KeybaseServiceMeasured",
"{",
"delegate",
":",
"delegate",
",",
"resolveTimer",
":",
"resolveTimer",
",",
"identifyTimer",
":",
"identifyTimer",
",",
"normalizeSocialAssertionTimer",
":",
"normalizeSocialAssertionTimer",
",",
"resolveIdentifyImplicitTeamTimer",
":",
"resolveIdentifyImplicitTeamTimer",
",",
"resolveImplicitTeamByIDTimer",
":",
"resolveImplicitTeamByIDTimer",
",",
"loadUserPlusKeysTimer",
":",
"loadUserPlusKeysTimer",
",",
"loadTeamPlusKeysTimer",
":",
"loadTeamPlusKeysTimer",
",",
"createTeamTLFTimer",
":",
"createTeamTLFTimer",
",",
"getTeamSettingsTimer",
":",
"getTeamSettingsTimer",
",",
"getCurrentMerkleRootTimer",
":",
"getCurrentMerkleRootTimer",
",",
"verifyMerkleRootTimer",
":",
"verifyMerkleRootTimer",
",",
"currentSessionTimer",
":",
"currentSessionTimer",
",",
"favoriteAddTimer",
":",
"favoriteAddTimer",
",",
"favoriteDeleteTimer",
":",
"favoriteDeleteTimer",
",",
"favoriteListTimer",
":",
"favoriteListTimer",
",",
"encryptFavoritesTimer",
":",
"encryptFavoritesTimer",
",",
"decryptFavoritesTimer",
":",
"decryptFavoritesTimer",
",",
"notifyTimer",
":",
"notifyTimer",
",",
"notifyPathUpdatedTimer",
":",
"notifyPathUpdatedTimer",
",",
"putGitMetadataTimer",
":",
"putGitMetadataTimer",
",",
"}",
"\n",
"}"
] | // NewKeybaseServiceMeasured creates and returns a new KeybaseServiceMeasured
// instance with the given delegate and registry. | [
"NewKeybaseServiceMeasured",
"creates",
"and",
"returns",
"a",
"new",
"KeybaseServiceMeasured",
"instance",
"with",
"the",
"given",
"delegate",
"and",
"registry",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L50-L99 |
161,493 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | Resolve | func (k KeybaseServiceMeasured) Resolve(
ctx context.Context, assertion string,
offline keybase1.OfflineAvailability) (
name kbname.NormalizedUsername, uid keybase1.UserOrTeamID, err error) {
k.resolveTimer.Time(func() {
name, uid, err = k.delegate.Resolve(ctx, assertion, offline)
})
return name, uid, err
} | go | func (k KeybaseServiceMeasured) Resolve(
ctx context.Context, assertion string,
offline keybase1.OfflineAvailability) (
name kbname.NormalizedUsername, uid keybase1.UserOrTeamID, err error) {
k.resolveTimer.Time(func() {
name, uid, err = k.delegate.Resolve(ctx, assertion, offline)
})
return name, uid, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"Resolve",
"(",
"ctx",
"context",
".",
"Context",
",",
"assertion",
"string",
",",
"offline",
"keybase1",
".",
"OfflineAvailability",
")",
"(",
"name",
"kbname",
".",
"NormalizedUsername",
",",
"uid",
"keybase1",
".",
"UserOrTeamID",
",",
"err",
"error",
")",
"{",
"k",
".",
"resolveTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"name",
",",
"uid",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"Resolve",
"(",
"ctx",
",",
"assertion",
",",
"offline",
")",
"\n",
"}",
")",
"\n",
"return",
"name",
",",
"uid",
",",
"err",
"\n",
"}"
] | // Resolve implements the KeybaseService interface for KeybaseServiceMeasured. | [
"Resolve",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L102-L110 |
161,494 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | Identify | func (k KeybaseServiceMeasured) Identify(
ctx context.Context, assertion, reason string,
offline keybase1.OfflineAvailability) (
name kbname.NormalizedUsername, id keybase1.UserOrTeamID, err error) {
k.identifyTimer.Time(func() {
name, id, err = k.delegate.Identify(ctx, assertion, reason, offline)
})
return name, id, err
} | go | func (k KeybaseServiceMeasured) Identify(
ctx context.Context, assertion, reason string,
offline keybase1.OfflineAvailability) (
name kbname.NormalizedUsername, id keybase1.UserOrTeamID, err error) {
k.identifyTimer.Time(func() {
name, id, err = k.delegate.Identify(ctx, assertion, reason, offline)
})
return name, id, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"Identify",
"(",
"ctx",
"context",
".",
"Context",
",",
"assertion",
",",
"reason",
"string",
",",
"offline",
"keybase1",
".",
"OfflineAvailability",
")",
"(",
"name",
"kbname",
".",
"NormalizedUsername",
",",
"id",
"keybase1",
".",
"UserOrTeamID",
",",
"err",
"error",
")",
"{",
"k",
".",
"identifyTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"name",
",",
"id",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"Identify",
"(",
"ctx",
",",
"assertion",
",",
"reason",
",",
"offline",
")",
"\n",
"}",
")",
"\n",
"return",
"name",
",",
"id",
",",
"err",
"\n",
"}"
] | // Identify implements the KeybaseService interface for KeybaseServiceMeasured. | [
"Identify",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L113-L121 |
161,495 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | NormalizeSocialAssertion | func (k KeybaseServiceMeasured) NormalizeSocialAssertion(
ctx context.Context, assertion string) (res keybase1.SocialAssertion, err error) {
k.normalizeSocialAssertionTimer.Time(func() {
res, err = k.delegate.NormalizeSocialAssertion(
ctx, assertion)
})
return res, err
} | go | func (k KeybaseServiceMeasured) NormalizeSocialAssertion(
ctx context.Context, assertion string) (res keybase1.SocialAssertion, err error) {
k.normalizeSocialAssertionTimer.Time(func() {
res, err = k.delegate.NormalizeSocialAssertion(
ctx, assertion)
})
return res, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"NormalizeSocialAssertion",
"(",
"ctx",
"context",
".",
"Context",
",",
"assertion",
"string",
")",
"(",
"res",
"keybase1",
".",
"SocialAssertion",
",",
"err",
"error",
")",
"{",
"k",
".",
"normalizeSocialAssertionTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"res",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"NormalizeSocialAssertion",
"(",
"ctx",
",",
"assertion",
")",
"\n",
"}",
")",
"\n",
"return",
"res",
",",
"err",
"\n",
"}"
] | // NormalizeSocialAssertion implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"NormalizeSocialAssertion",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L125-L132 |
161,496 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | ResolveIdentifyImplicitTeam | func (k KeybaseServiceMeasured) ResolveIdentifyImplicitTeam(
ctx context.Context, assertions, suffix string, tlfType tlf.Type,
doIdentifies bool, reason string, offline keybase1.OfflineAvailability) (
info idutil.ImplicitTeamInfo, err error) {
k.resolveIdentifyImplicitTeamTimer.Time(func() {
info, err = k.delegate.ResolveIdentifyImplicitTeam(
ctx, assertions, suffix, tlfType, doIdentifies, reason, offline)
})
return info, err
} | go | func (k KeybaseServiceMeasured) ResolveIdentifyImplicitTeam(
ctx context.Context, assertions, suffix string, tlfType tlf.Type,
doIdentifies bool, reason string, offline keybase1.OfflineAvailability) (
info idutil.ImplicitTeamInfo, err error) {
k.resolveIdentifyImplicitTeamTimer.Time(func() {
info, err = k.delegate.ResolveIdentifyImplicitTeam(
ctx, assertions, suffix, tlfType, doIdentifies, reason, offline)
})
return info, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"ResolveIdentifyImplicitTeam",
"(",
"ctx",
"context",
".",
"Context",
",",
"assertions",
",",
"suffix",
"string",
",",
"tlfType",
"tlf",
".",
"Type",
",",
"doIdentifies",
"bool",
",",
"reason",
"string",
",",
"offline",
"keybase1",
".",
"OfflineAvailability",
")",
"(",
"info",
"idutil",
".",
"ImplicitTeamInfo",
",",
"err",
"error",
")",
"{",
"k",
".",
"resolveIdentifyImplicitTeamTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"info",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"ResolveIdentifyImplicitTeam",
"(",
"ctx",
",",
"assertions",
",",
"suffix",
",",
"tlfType",
",",
"doIdentifies",
",",
"reason",
",",
"offline",
")",
"\n",
"}",
")",
"\n",
"return",
"info",
",",
"err",
"\n",
"}"
] | // ResolveIdentifyImplicitTeam implements the KeybaseService interface
// for KeybaseServiceMeasured. | [
"ResolveIdentifyImplicitTeam",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L136-L145 |
161,497 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | ResolveImplicitTeamByID | func (k KeybaseServiceMeasured) ResolveImplicitTeamByID(
ctx context.Context, teamID keybase1.TeamID) (name string, err error) {
k.resolveImplicitTeamByIDTimer.Time(func() {
name, err = k.delegate.ResolveImplicitTeamByID(ctx, teamID)
})
return name, err
} | go | func (k KeybaseServiceMeasured) ResolveImplicitTeamByID(
ctx context.Context, teamID keybase1.TeamID) (name string, err error) {
k.resolveImplicitTeamByIDTimer.Time(func() {
name, err = k.delegate.ResolveImplicitTeamByID(ctx, teamID)
})
return name, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"ResolveImplicitTeamByID",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamID",
"keybase1",
".",
"TeamID",
")",
"(",
"name",
"string",
",",
"err",
"error",
")",
"{",
"k",
".",
"resolveImplicitTeamByIDTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"name",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"ResolveImplicitTeamByID",
"(",
"ctx",
",",
"teamID",
")",
"\n",
"}",
")",
"\n",
"return",
"name",
",",
"err",
"\n",
"}"
] | // ResolveImplicitTeamByID implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"ResolveImplicitTeamByID",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L149-L155 |
161,498 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | LoadUserPlusKeys | func (k KeybaseServiceMeasured) LoadUserPlusKeys(
ctx context.Context, uid keybase1.UID, pollForKID keybase1.KID,
offline keybase1.OfflineAvailability) (userInfo idutil.UserInfo, err error) {
k.loadUserPlusKeysTimer.Time(func() {
userInfo, err = k.delegate.LoadUserPlusKeys(
ctx, uid, pollForKID, offline)
})
return userInfo, err
} | go | func (k KeybaseServiceMeasured) LoadUserPlusKeys(
ctx context.Context, uid keybase1.UID, pollForKID keybase1.KID,
offline keybase1.OfflineAvailability) (userInfo idutil.UserInfo, err error) {
k.loadUserPlusKeysTimer.Time(func() {
userInfo, err = k.delegate.LoadUserPlusKeys(
ctx, uid, pollForKID, offline)
})
return userInfo, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"LoadUserPlusKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
",",
"pollForKID",
"keybase1",
".",
"KID",
",",
"offline",
"keybase1",
".",
"OfflineAvailability",
")",
"(",
"userInfo",
"idutil",
".",
"UserInfo",
",",
"err",
"error",
")",
"{",
"k",
".",
"loadUserPlusKeysTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"userInfo",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"LoadUserPlusKeys",
"(",
"ctx",
",",
"uid",
",",
"pollForKID",
",",
"offline",
")",
"\n",
"}",
")",
"\n",
"return",
"userInfo",
",",
"err",
"\n",
"}"
] | // LoadUserPlusKeys implements the KeybaseService interface for KeybaseServiceMeasured. | [
"LoadUserPlusKeys",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L158-L166 |
161,499 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | LoadTeamPlusKeys | func (k KeybaseServiceMeasured) LoadTeamPlusKeys(ctx context.Context,
tid keybase1.TeamID, tlfType tlf.Type, desiredKeyGen kbfsmd.KeyGen,
desiredUser keybase1.UserVersion, desiredKey kbfscrypto.VerifyingKey,
desiredRole keybase1.TeamRole, offline keybase1.OfflineAvailability) (
teamInfo idutil.TeamInfo, err error) {
k.loadTeamPlusKeysTimer.Time(func() {
teamInfo, err = k.delegate.LoadTeamPlusKeys(
ctx, tid, tlfType, desiredKeyGen, desiredUser, desiredKey,
desiredRole, offline)
})
return teamInfo, err
} | go | func (k KeybaseServiceMeasured) LoadTeamPlusKeys(ctx context.Context,
tid keybase1.TeamID, tlfType tlf.Type, desiredKeyGen kbfsmd.KeyGen,
desiredUser keybase1.UserVersion, desiredKey kbfscrypto.VerifyingKey,
desiredRole keybase1.TeamRole, offline keybase1.OfflineAvailability) (
teamInfo idutil.TeamInfo, err error) {
k.loadTeamPlusKeysTimer.Time(func() {
teamInfo, err = k.delegate.LoadTeamPlusKeys(
ctx, tid, tlfType, desiredKeyGen, desiredUser, desiredKey,
desiredRole, offline)
})
return teamInfo, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"LoadTeamPlusKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"tid",
"keybase1",
".",
"TeamID",
",",
"tlfType",
"tlf",
".",
"Type",
",",
"desiredKeyGen",
"kbfsmd",
".",
"KeyGen",
",",
"desiredUser",
"keybase1",
".",
"UserVersion",
",",
"desiredKey",
"kbfscrypto",
".",
"VerifyingKey",
",",
"desiredRole",
"keybase1",
".",
"TeamRole",
",",
"offline",
"keybase1",
".",
"OfflineAvailability",
")",
"(",
"teamInfo",
"idutil",
".",
"TeamInfo",
",",
"err",
"error",
")",
"{",
"k",
".",
"loadTeamPlusKeysTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"teamInfo",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"LoadTeamPlusKeys",
"(",
"ctx",
",",
"tid",
",",
"tlfType",
",",
"desiredKeyGen",
",",
"desiredUser",
",",
"desiredKey",
",",
"desiredRole",
",",
"offline",
")",
"\n",
"}",
")",
"\n",
"return",
"teamInfo",
",",
"err",
"\n",
"}"
] | // LoadTeamPlusKeys implements the KeybaseService interface for KeybaseServiceMeasured. | [
"LoadTeamPlusKeys",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L169-L180 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.