Download this file
| 1 | package hostfiles |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | // EnvItem is the host's env file (<host>.env) among the manifest's |
| 9 | // platform items. A release flush stages it beside the wake state so a |
| 10 | // relocation's prepared manifest carries it (region HA spec 1 §5.6: |
| 11 | // always continuous, whatever the setting); the local install restores it |
| 12 | // with ReadPlatform. |
| 13 | const EnvItem = "host.env" |
| 14 | |
| 15 | // StagePlatformDelete records that a platform item is gone: the next |
| 16 | // Commit publishes a revision without it, at a new sequence, so a reader |
| 17 | // of that revision gets os.ErrNotExist from ReadPlatform instead of the |
| 18 | // last bytes it published. Deleting an item the manifest does not hold |
| 19 | // is a no-op, like StageDelete. |
| 20 | func (p *Publisher) StagePlatformDelete(name string) error { |
| 21 | if name == "" || strings.ContainsAny(name, "/\x00") { |
| 22 | return fmt.Errorf("hostfiles: platform item %q is not a plain name", name) |
| 23 | } |
| 24 | p.mu.Lock() |
| 25 | defer p.mu.Unlock() |
| 26 | if _, ok := p.man.Platform[name]; !ok { |
| 27 | return nil |
| 28 | } |
| 29 | p.next++ |
| 30 | delete(p.man.Platform, name) |
| 31 | p.dirty = true |
| 32 | return nil |
| 33 | } |
| 34 | |