CommitTime returns the time at which the AUM was committed. If the AUM does not exist, then os.ErrNotExist is returned.
(h AUMHash)
| 372 | // |
| 373 | // If the AUM does not exist, then os.ErrNotExist is returned. |
| 374 | func (c *FS) CommitTime(h AUMHash) (time.Time, error) { |
| 375 | c.mu.RLock() |
| 376 | defer c.mu.RUnlock() |
| 377 | |
| 378 | info, err := c.get(h) |
| 379 | if err != nil { |
| 380 | if os.IsNotExist(err) { |
| 381 | return time.Time{}, os.ErrNotExist |
| 382 | } |
| 383 | return time.Time{}, err |
| 384 | } |
| 385 | if info.PurgedUnix > 0 { |
| 386 | return time.Time{}, os.ErrNotExist |
| 387 | } |
| 388 | if info.CreatedUnix > 0 { |
| 389 | return time.Unix(info.CreatedUnix, 0), nil |
| 390 | } |
| 391 | |
| 392 | // If we got this far, the AUM exists but CreatedUnix is not |
| 393 | // set, presumably because this AUM was committed using a version |
| 394 | // of tailscaled that pre-dates the introduction of CreatedUnix. |
| 395 | // As such, we use the file modification time as a suitable analog. |
| 396 | dir, base := c.aumDir(h) |
| 397 | s, err := os.Stat(filepath.Join(dir, base)) |
| 398 | if err != nil { |
| 399 | return time.Time{}, nil |
| 400 | } |
| 401 | return s.ModTime(), nil |
| 402 | } |
| 403 | |
| 404 | // AUM returns any known AUMs with a specific parent hash. |
| 405 | func (c *FS) ChildAUMs(prevAUMHash AUMHash) ([]AUM, error) { |