MCPcopy
hub / github.com/tailscale/golink / Load

Method Load

db.go:98–115  ·  view source on GitHub ↗

Load returns a Link by its short name. It returns fs.ErrNotExist if the link does not exist. The caller owns the returned value.

(short string)

Source from the content-addressed store, hash-verified

96//
97// The caller owns the returned value.
98func (s *SQLiteDB) Load(short string) (*Link, error) {
99 s.mu.RLock()
100 defer s.mu.RUnlock()
101
102 link := new(Link)
103 var created, lastEdit int64
104 row := s.db.QueryRow("SELECT Short, Long, Created, LastEdit, Owner FROM Links WHERE ID = ?1 LIMIT 1", linkID(short))
105 err := row.Scan(&link.Short, &link.Long, &created, &lastEdit, &link.Owner)
106 if err != nil {
107 if errors.Is(err, sql.ErrNoRows) {
108 err = fs.ErrNotExist
109 }
110 return nil, err
111 }
112 link.Created = time.Unix(created, 0).UTC()
113 link.LastEdit = time.Unix(lastEdit, 0).UTC()
114 return link, nil
115}
116
117// Save saves a Link.
118func (s *SQLiteDB) Save(link *Link) error {

Callers 7

serveGoFunction · 0.80
serveDetailFunction · 0.80
serveDeleteFunction · 0.80
serveSaveFunction · 0.80
restoreLastSnapshotFunction · 0.80
resolveLinkFunction · 0.80

Calls 1

linkIDFunction · 0.85

Tested by 1