mirror of
https://github.com/luxfi/lpm.git
synced 2026-10-30 16:20:57 +00:00
Lux Partners Limited is the Isle of Man company. Lux Industries Inc, a Delaware C corporation, is the company these sites belong to, so it is the one they name — in metadata, copyright, and the press items that record who signed. The fund site names Lux Assets Management LLC, which is its own company. Two sentences were rewritten rather than renamed, because a name was doing work a name cannot do. One claimed an Isle of Man domicile the naming entity does not have. The other said a company acts on behalf of another; with one entity left it said a company acts on behalf of itself. The Isle of Man stays everywhere it is a JURISDICTION the product supports — the regulatory package, the jurisdiction guides, the compliance tables. Only this company's own identity changed.
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package state
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/luxfi/filesystem/perms"
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
const (
|
|
stateFile = "lpm.state"
|
|
)
|
|
|
|
func newEmpty(path string) File {
|
|
return File{
|
|
Sources: make(map[string]*SourceInfo),
|
|
InstallationRegistry: make(map[string]*InstallInfo),
|
|
path: filepath.Join(path, stateFile),
|
|
}
|
|
}
|
|
|
|
func New(path string) (File, error) {
|
|
result := newEmpty(path)
|
|
|
|
b, err := os.ReadFile(result.path)
|
|
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
|
return File{}, err
|
|
}
|
|
|
|
if err := yaml.Unmarshal(b, result); err != nil {
|
|
return File{}, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// File is the representation of the current LPM state.
|
|
// Not safe for concurrent use.
|
|
type File struct {
|
|
// Mapping of each tracked repository's alias to its metadata
|
|
Sources map[string]*SourceInfo `yaml:"sources"`
|
|
// Mapping of each installed vm's alias to the version installed
|
|
InstallationRegistry map[string]*InstallInfo `yaml:"installation-registry"`
|
|
|
|
path string
|
|
}
|
|
|
|
func (s *File) Commit() error {
|
|
bytes, err := yaml.Marshal(s)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return os.WriteFile(s.path, bytes, perms.ReadWrite)
|
|
}
|