mirror of
https://github.com/datarhei/core.git
synced 2025-10-16 21:10:41 +08:00
Fix using clusterfs for API fs operations
This commit is contained in:
@@ -25,7 +25,7 @@ type FSHandler struct {
|
|||||||
filesystems map[string]FSConfig
|
filesystems map[string]FSConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFS return a new FSHanlder type. You have to provide a filesystem to act on.
|
// NewFS return a new FSHandler type. You have to provide a filesystem to act on.
|
||||||
func NewFS(filesystems map[string]FSConfig) *FSHandler {
|
func NewFS(filesystems map[string]FSConfig) *FSHandler {
|
||||||
return &FSHandler{
|
return &FSHandler{
|
||||||
filesystems: filesystems,
|
filesystems: filesystems,
|
||||||
|
@@ -160,6 +160,7 @@ type filesystem struct {
|
|||||||
fs.FS
|
fs.FS
|
||||||
|
|
||||||
handler *handler.FSHandler
|
handler *handler.FSHandler
|
||||||
|
apihandler *handler.FSHandler
|
||||||
middleware echo.MiddlewareFunc
|
middleware echo.MiddlewareFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +197,8 @@ func NewServer(config Config) (Server, error) {
|
|||||||
|
|
||||||
corsPrefixes[httpfs.Mountpoint] = config.Cors.Origins
|
corsPrefixes[httpfs.Mountpoint] = config.Cors.Origins
|
||||||
|
|
||||||
|
apihttpfs := httpfs
|
||||||
|
|
||||||
if config.Cluster != nil {
|
if config.Cluster != nil {
|
||||||
if httpfs.Filesystem.Type() == "disk" || httpfs.Filesystem.Type() == "mem" {
|
if httpfs.Filesystem.Type() == "disk" || httpfs.Filesystem.Type() == "mem" {
|
||||||
httpfs.Filesystem = fs.NewClusterFS(httpfs.Filesystem.Name(), httpfs.Filesystem, config.Cluster.ProxyReader())
|
httpfs.Filesystem = fs.NewClusterFS(httpfs.Filesystem.Name(), httpfs.Filesystem, config.Cluster.ProxyReader())
|
||||||
@@ -205,6 +208,7 @@ func NewServer(config Config) (Server, error) {
|
|||||||
filesystem := &filesystem{
|
filesystem := &filesystem{
|
||||||
FS: httpfs,
|
FS: httpfs,
|
||||||
handler: handler.NewFS(httpfs),
|
handler: handler.NewFS(httpfs),
|
||||||
|
apihandler: handler.NewFS(apihttpfs),
|
||||||
}
|
}
|
||||||
|
|
||||||
if httpfs.Filesystem.Type() == "disk" {
|
if httpfs.Filesystem.Type() == "disk" {
|
||||||
@@ -639,7 +643,7 @@ func (s *server) setRoutesV3(v3 *echo.Group) {
|
|||||||
fshandlers[fs.Name] = api.FSConfig{
|
fshandlers[fs.Name] = api.FSConfig{
|
||||||
Type: fs.Filesystem.Type(),
|
Type: fs.Filesystem.Type(),
|
||||||
Mountpoint: fs.Mountpoint,
|
Mountpoint: fs.Mountpoint,
|
||||||
Handler: fs.handler,
|
Handler: fs.apihandler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user