feat: implement multi-root virtual filesystem

This commit is contained in:
OpenClaw Agent
2026-09-21 13:29:50 +08:00
parent 8a82e48507
commit 633c833d1c
3 changed files with 149 additions and 11 deletions
+10 -6
View File
@@ -53,17 +53,21 @@ func main() {
}
root := cfg.Path[0]
if len(cfg.Path) > 1 {
log.Printf("warning: %d shared roots configured; v1 compatibility currently serves the first root %q", len(cfg.Path), root)
}
if err := os.MkdirAll(root, 0755); err != nil {
log.Fatal(err)
for _, p := range cfg.Path {
if err := os.MkdirAll(p, 0755); err != nil {
log.Fatal(err)
}
}
mgr, err := auth.ParseRules(cfg.Rules)
if err != nil {
log.Fatal(err)
}
srv := &api.Server{Store: storage.Local{Root: root}, Auth: mgr, Sessions: map[string]*auth.Account{}, WebDAVRoot: root, Allow: cfg.Allow}
multi := storage.NewMulti(cfg.Path)
store := storage.Storage(multi)
if len(cfg.Path) == 1 {
store = storage.Local{Root: root}
}
srv := &api.Server{Store: store, Auth: mgr, Sessions: map[string]*auth.Account{}, WebDAVRoot: root, Allow: cfg.Allow, MultiRoot: len(cfg.Path) > 1}
addr := ":" + itoa(cfg.Port)
log.Printf("chfs-ng listening on %s root=%s", addr, filepath.Clean(root))
if cfg.SSLCert != "" && cfg.SSLKey != "" {