GetFile returns the path of a file given the name. Returns ErrNotFound if file is not found.
(name string)
| 630 | |
| 631 | // GetFile returns the path of a file given the name. Returns ErrNotFound if file is not found. |
| 632 | func (u *Updater) GetFile(name string) (*Artifact, error) { |
| 633 | u.indexLock.Lock() |
| 634 | defer u.indexLock.Unlock() |
| 635 | |
| 636 | // Check if any index is active. |
| 637 | if u.index == nil { |
| 638 | return nil, ErrNotFound |
| 639 | } |
| 640 | |
| 641 | for _, artifact := range u.index.Artifacts { |
| 642 | switch { |
| 643 | case artifact.Filename != name: |
| 644 | // Name does not match. |
| 645 | case artifact.Platform != "" && artifact.Platform != u.cfg.Platform: |
| 646 | // Platform is defined and does not match. |
| 647 | // Platforms are usually pre-filtered, but just to be sure. |
| 648 | default: |
| 649 | // Artifact matches! |
| 650 | return artifact.export(u.cfg.Directory, u.index.versionNum), nil |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | return nil, ErrNotFound |
| 655 | } |
| 656 | |
| 657 | // Stop stops the module. |
| 658 | func (u *Updater) Stop() error { |
no test coverage detected