Merge pull request #2199 from ishank011/webdav-ns-config

Make webdav namespace configurable across services
This commit is contained in:
Michael Barz
2021-06-25 11:39:36 +02:00
committed by GitHub
10 changed files with 52 additions and 19 deletions

View File

@@ -64,6 +64,7 @@ type Thumbnail struct {
FileSystemStorage FileSystemStorage
WebdavAllowInsecure bool
RevaGateway string
WebdavNamespace string
}
// New initializes a new configuration with or without defaults.

View File

@@ -162,6 +162,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
Usage: "--thumbnail-resolution 16x16 [--thumbnail-resolution 32x32]",
EnvVars: []string{"THUMBNAILS_RESOLUTIONS"},
},
&cli.StringFlag{
Name: "webdav-namespace",
Value: flags.OverrideDefaultString(cfg.Thumbnail.WebdavNamespace, "/home"),
Usage: "Namespace prefix for the webdav endpoint",
EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"},
Destination: &cfg.Thumbnail.WebdavNamespace,
},
}
}

View File

@@ -30,7 +30,8 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler {
logger.Fatal().Err(err).Msg("resolutions not configured correctly")
}
svc := Thumbnail{
serviceID: options.Config.Server.Namespace + "." + options.Config.Server.Name,
serviceID: options.Config.Server.Namespace + "." + options.Config.Server.Name,
webdavNamespace: options.Config.Thumbnail.WebdavNamespace,
manager: thumbnail.NewSimpleManager(
resolutions,
options.ThumbnailStorage,
@@ -47,12 +48,13 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler {
// Thumbnail implements the GRPC handler.
type Thumbnail struct {
serviceID string
manager thumbnail.Manager
webdavSource imgsource.Source
cs3Source imgsource.Source
logger log.Logger
cs3Client gateway.GatewayAPIClient
serviceID string
webdavNamespace string
manager thumbnail.Manager
webdavSource imgsource.Source
cs3Source imgsource.Source
logger log.Logger
cs3Client gateway.GatewayAPIClient
}
// GetThumbnail retrieves a thumbnail for an image
@@ -161,7 +163,7 @@ func (g Thumbnail) handleWebdavSource(ctx context.Context, req *v0proto.GetThumb
statPath = path.Join("/public", src.PublicLinkToken, req.Filepath)
} else {
auth = src.RevaAuthorization
statPath = path.Join("/home", req.Filepath)
statPath = path.Join(g.webdavNamespace, req.Filepath)
}
sRes, err := g.stat(statPath, auth)
if err != nil {