MCPcopy
hub / github.com/dosco/graphjin / NewLocal

Function NewLocal

core/fstable/local.go:34–50  ·  view source on GitHub ↗

NewLocal validates Root and returns a Local backend. Root must exist and be a directory; the backend never creates Root automatically because doing so masks misconfigured deployments (e.g. a stale directory inside a container).

(conf LocalConfig)

Source from the content-addressed store, hash-verified

32// because doing so masks misconfigured deployments (e.g. a stale
33// directory inside a container).
34func NewLocal(conf LocalConfig) (*Local, error) {
35 if conf.Root == "" {
36 return nil, errors.New("fstable/local: root directory is required")
37 }
38 abs, err := filepath.Abs(conf.Root)
39 if err != nil {
40 return nil, fmt.Errorf("fstable/local: resolve root: %w", err)
41 }
42 info, err := os.Stat(abs)
43 if err != nil {
44 return nil, fmt.Errorf("fstable/local: stat root %q: %w", abs, err)
45 }
46 if !info.IsDir() {
47 return nil, fmt.Errorf("fstable/local: root %q is not a directory", abs)
48 }
49 return &Local{root: abs}, nil
50}
51
52func (l *Local) Name() string { return "local" }
53

Callers 2

newLocalFunction · 0.85

Calls 1

StatMethod · 0.65

Tested by 2

newLocalFunction · 0.68