MCPcopy
hub / github.com/syncthing/syncthing / writeEncryptionToken

Function writeEncryptionToken

lib/model/model.go:3443–3454  ·  view source on GitHub ↗
(token []byte, cfg config.FolderConfiguration)

Source from the content-addressed store, hash-verified

3441}
3442
3443func writeEncryptionToken(token []byte, cfg config.FolderConfiguration) error {
3444 tokenName := encryptionTokenPath(cfg)
3445 fd, err := cfg.Filesystem().OpenFile(tokenName, fs.OptReadWrite|fs.OptCreate, 0o666)
3446 if err != nil {
3447 return err
3448 }
3449 defer fd.Close()
3450 return json.NewEncoder(fd).Encode(storedEncryptionToken{
3451 FolderID: cfg.ID,
3452 Token: token,
3453 })
3454}
3455
3456func newFolderConfiguration(w config.Wrapper, id, label string, fsType config.FilesystemType, path string) config.FolderConfiguration {
3457 fcfg := w.DefaultFolder()

Callers 2

ccCheckEncryptionMethod · 0.85

Calls 4

encryptionTokenPathFunction · 0.85
FilesystemMethod · 0.80
OpenFileMethod · 0.65
CloseMethod · 0.65

Tested by 1