feat: implement multi-root virtual filesystem
This commit is contained in:
@@ -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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user