From b3fd53d5a300f666ac5b6b1bb99adc9ac6c14080 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Wed, 21 Jun 2023 16:30:57 +0200 Subject: [PATCH 1/6] disable thumbnail service when web prevents previews Signed-off-by: Christian Richter --- ocis/pkg/runtime/service/service.go | 4 ++ services/web/pkg/config/options.go | 2 +- services/webdav/pkg/config/config.go | 1 + services/webdav/pkg/service/v0/service.go | 51 +++++++++++++---------- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index c8531b69b..51cb36ee0 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -433,6 +433,10 @@ func (s *Service) generateRunSet(cfg *ociscfg.Config) { delete(runset, name) } + // disable thumbnail service + if cfg.WebDAV.DisablePreviews || cfg.Web.Web.Config.Options.DisablePreviews { + delete(runset, "thumbnails") + } } // List running processes for the Service Controller. diff --git a/services/web/pkg/config/options.go b/services/web/pkg/config/options.go index bd9440090..5ea918c4b 100644 --- a/services/web/pkg/config/options.go +++ b/services/web/pkg/config/options.go @@ -4,7 +4,7 @@ package config type Options struct { HomeFolder string `json:"homeFolder,omitempty" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"Specifies a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory, it simply serves as a default location. A static location can be provided, or variables of the user object to come up with a user specific home path can be used. This uses the twig template variable style and allows picking a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` OpenAppsInTab bool `json:"openAppsInTab,omitempty" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions should generally open in a new tab. Defaults to false."` - DisablePreviews bool `json:"disablePreviews,omitempty" yaml:"disablePreviews" env:"WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` + DisablePreviews bool `json:"disablePreviews,omitempty" yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all." deprecationVersion:"3.1" removalVersion:"4.0.0" deprecationInfo:"WEB_OPTION_DISABLE_PREVIEWS is being replaced by a global variable" deprecationReplacement:"OCIS_DISABLE_PREVIEWS"` PreviewFileMimeTypes []string `json:"previewFileMimeTypes,omitempty" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the UI. For example to only preview jpg and text files, set this option to ['image/jpeg', 'text/plain']."` AccountEditLink *AccountEditLink `json:"accountEditLink,omitempty" yaml:"accountEditLink"` DisableFeedbackLink bool `json:"disableFeedbackLink,omitempty" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled by setting the value to 'false' or with the absence of the option, allows ownCloud to get feedback from your user base through a dedicated survey website."` diff --git a/services/webdav/pkg/config/config.go b/services/webdav/pkg/config/config.go index c4462833a..7317dc962 100644 --- a/services/webdav/pkg/config/config.go +++ b/services/webdav/pkg/config/config.go @@ -20,6 +20,7 @@ type Config struct { HTTP HTTP `yaml:"http"` + DisablePreviews bool `yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` OcisPublicURL string `yaml:"ocis_public_url" env:"OCIS_URL;OCIS_PUBLIC_URL" desc:"URL, where oCIS is reachable for users."` WebdavNamespace string `yaml:"webdav_namespace" env:"WEBDAV_WEBDAV_NAMESPACE" desc:"CS3 path layout to use when forwarding /webdav requests"` RevaGateway string `yaml:"reva_gateway" env:"OCIS_REVA_GATEWAY;REVA_GATEWAY" desc:"CS3 gateway used to look up user metadata" deprecationVersion:"3.0" removalVersion:"4.0.0" deprecationInfo:"REVA_GATEWAY changing name for consistency" deprecationReplacement:"OCIS_REVA_GATEWAY"` diff --git a/services/webdav/pkg/service/v0/service.go b/services/webdav/pkg/service/v0/service.go index a411a2968..f60b75a62 100644 --- a/services/webdav/pkg/service/v0/service.go +++ b/services/webdav/pkg/service/v0/service.go @@ -82,37 +82,42 @@ func NewService(opts ...Option) (Service, error) { gatewaySelector: gatewaySelector, } + if svc.config.DisablePreviews { + svc.thumbnailsClient = nil + } m.Route(options.Config.HTTP.Root, func(r chi.Router) { - r.Group(func(r chi.Router) { - r.Use(svc.DavUserContext()) + if !svc.config.DisablePreviews { + r.Group(func(r chi.Router) { + r.Use(svc.DavUserContext()) - r.Get("/remote.php/dav/spaces/{id}", svc.SpacesThumbnail) - r.Get("/remote.php/dav/spaces/{id}/*", svc.SpacesThumbnail) - r.Get("/dav/spaces/{id}", svc.SpacesThumbnail) - r.Get("/dav/spaces/{id}/*", svc.SpacesThumbnail) + r.Get("/remote.php/dav/spaces/{id}", svc.SpacesThumbnail) + r.Get("/remote.php/dav/spaces/{id}/*", svc.SpacesThumbnail) + r.Get("/dav/spaces/{id}", svc.SpacesThumbnail) + r.Get("/dav/spaces/{id}/*", svc.SpacesThumbnail) - r.Get("/remote.php/dav/files/{id}", svc.Thumbnail) - r.Get("/remote.php/dav/files/{id}/*", svc.Thumbnail) - r.Get("/dav/files/{id}", svc.Thumbnail) - r.Get("/dav/files/{id}/*", svc.Thumbnail) - }) + r.Get("/remote.php/dav/files/{id}", svc.Thumbnail) + r.Get("/remote.php/dav/files/{id}/*", svc.Thumbnail) + r.Get("/dav/files/{id}", svc.Thumbnail) + r.Get("/dav/files/{id}/*", svc.Thumbnail) + }) - r.Group(func(r chi.Router) { - r.Use(svc.DavPublicContext()) + r.Group(func(r chi.Router) { + r.Use(svc.DavPublicContext()) - r.Head("/remote.php/dav/public-files/{token}/*", svc.PublicThumbnailHead) - r.Head("/dav/public-files/{token}/*", svc.PublicThumbnailHead) + r.Head("/remote.php/dav/public-files/{token}/*", svc.PublicThumbnailHead) + r.Head("/dav/public-files/{token}/*", svc.PublicThumbnailHead) - r.Get("/remote.php/dav/public-files/{token}/*", svc.PublicThumbnail) - r.Get("/dav/public-files/{token}/*", svc.PublicThumbnail) - }) + r.Get("/remote.php/dav/public-files/{token}/*", svc.PublicThumbnail) + r.Get("/dav/public-files/{token}/*", svc.PublicThumbnail) + }) - r.Group(func(r chi.Router) { - r.Use(svc.WebDAVContext()) - r.Get("/remote.php/webdav/*", svc.Thumbnail) - r.Get("/webdav/*", svc.Thumbnail) - }) + r.Group(func(r chi.Router) { + r.Use(svc.WebDAVContext()) + r.Get("/remote.php/webdav/*", svc.Thumbnail) + r.Get("/webdav/*", svc.Thumbnail) + }) + } // r.MethodFunc("REPORT", "/remote.php/dav/files/{id}/*", svc.Search) From a63931a2e11f676f7e141889c06bbc48424346fd Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 22 Jun 2023 15:46:18 +0200 Subject: [PATCH 2/6] add changelog Signed-off-by: Christian Richter --- changelog/unreleased/disable-thumbnailer.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog/unreleased/disable-thumbnailer.md diff --git a/changelog/unreleased/disable-thumbnailer.md b/changelog/unreleased/disable-thumbnailer.md new file mode 100644 index 000000000..7c6336106 --- /dev/null +++ b/changelog/unreleased/disable-thumbnailer.md @@ -0,0 +1,7 @@ +Bugfix: Thumbnailer can be disabled globally now + +We added an env var `OCIS_DISABLE_PREVIEWS` to disable the thumbnailer globally. +The web-only local env-var `WEB_OPTION_DISABLE_PREVIEWS` will be deprecated. + +https://github.com/owncloud/ocis/pull/6577 +https://github.com/owncloud/ocis/issues/192 \ No newline at end of file From 15ced8a6df330a00f5d04e431f1b5e887232b951 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 23 Jun 2023 13:29:49 +0200 Subject: [PATCH 3/6] incorporate requested changes Signed-off-by: Christian Richter --- changelog/unreleased/disable-thumbnailer.md | 7 ++++--- ocis/pkg/runtime/service/service.go | 5 ----- services/web/pkg/config/options.go | 2 +- services/webdav/pkg/config/config.go | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/changelog/unreleased/disable-thumbnailer.md b/changelog/unreleased/disable-thumbnailer.md index 7c6336106..c32e1e8d1 100644 --- a/changelog/unreleased/disable-thumbnailer.md +++ b/changelog/unreleased/disable-thumbnailer.md @@ -1,7 +1,8 @@ -Bugfix: Thumbnailer can be disabled globally now +Enhancement: Thumbnails can be disabled for webdav & web now -We added an env var `OCIS_DISABLE_PREVIEWS` to disable the thumbnailer globally. -The web-only local env-var `WEB_OPTION_DISABLE_PREVIEWS` will be deprecated. +We added an env var `OCIS_DISABLE_PREVIEWS` to disable the thumbnails for web & webdav via a global setting. +For each service this behaviour can be disabled using the local env vars `WEB_OPTION_DISABLE_PREVIEWS` (old) +and `WEBDAV_OPTION_DISABLE_PREVIEWS` (new). https://github.com/owncloud/ocis/pull/6577 https://github.com/owncloud/ocis/issues/192 \ No newline at end of file diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 51cb36ee0..958d2d167 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -432,11 +432,6 @@ func (s *Service) generateRunSet(cfg *ociscfg.Config) { for _, name := range cfg.Runtime.Disabled { delete(runset, name) } - - // disable thumbnail service - if cfg.WebDAV.DisablePreviews || cfg.Web.Web.Config.Options.DisablePreviews { - delete(runset, "thumbnails") - } } // List running processes for the Service Controller. diff --git a/services/web/pkg/config/options.go b/services/web/pkg/config/options.go index 5ea918c4b..9e88c176a 100644 --- a/services/web/pkg/config/options.go +++ b/services/web/pkg/config/options.go @@ -4,7 +4,7 @@ package config type Options struct { HomeFolder string `json:"homeFolder,omitempty" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"Specifies a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory, it simply serves as a default location. A static location can be provided, or variables of the user object to come up with a user specific home path can be used. This uses the twig template variable style and allows picking a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` OpenAppsInTab bool `json:"openAppsInTab,omitempty" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions should generally open in a new tab. Defaults to false."` - DisablePreviews bool `json:"disablePreviews,omitempty" yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all." deprecationVersion:"3.1" removalVersion:"4.0.0" deprecationInfo:"WEB_OPTION_DISABLE_PREVIEWS is being replaced by a global variable" deprecationReplacement:"OCIS_DISABLE_PREVIEWS"` + DisablePreviews bool `json:"disablePreviews,omitempty" yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different web file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` PreviewFileMimeTypes []string `json:"previewFileMimeTypes,omitempty" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the UI. For example to only preview jpg and text files, set this option to ['image/jpeg', 'text/plain']."` AccountEditLink *AccountEditLink `json:"accountEditLink,omitempty" yaml:"accountEditLink"` DisableFeedbackLink bool `json:"disableFeedbackLink,omitempty" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled by setting the value to 'false' or with the absence of the option, allows ownCloud to get feedback from your user base through a dedicated survey website."` diff --git a/services/webdav/pkg/config/config.go b/services/webdav/pkg/config/config.go index 7317dc962..4c9aa57b0 100644 --- a/services/webdav/pkg/config/config.go +++ b/services/webdav/pkg/config/config.go @@ -20,7 +20,7 @@ type Config struct { HTTP HTTP `yaml:"http"` - DisablePreviews bool `yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` + DisablePreviews bool `yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEBDAV_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable all preview related webdav paths."` OcisPublicURL string `yaml:"ocis_public_url" env:"OCIS_URL;OCIS_PUBLIC_URL" desc:"URL, where oCIS is reachable for users."` WebdavNamespace string `yaml:"webdav_namespace" env:"WEBDAV_WEBDAV_NAMESPACE" desc:"CS3 path layout to use when forwarding /webdav requests"` RevaGateway string `yaml:"reva_gateway" env:"OCIS_REVA_GATEWAY;REVA_GATEWAY" desc:"CS3 gateway used to look up user metadata" deprecationVersion:"3.0" removalVersion:"4.0.0" deprecationInfo:"REVA_GATEWAY changing name for consistency" deprecationReplacement:"OCIS_REVA_GATEWAY"` From 5150a18dec67deb00ce9afc4043cfe4f8e970c16 Mon Sep 17 00:00:00 2001 From: Christian Richter <1058116+dragonchaser@users.noreply.github.com> Date: Fri, 23 Jun 2023 16:11:39 +0200 Subject: [PATCH 4/6] Update services/webdav/pkg/config/config.go Co-authored-by: kobergj --- services/webdav/pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/webdav/pkg/config/config.go b/services/webdav/pkg/config/config.go index 4c9aa57b0..adfa5ae07 100644 --- a/services/webdav/pkg/config/config.go +++ b/services/webdav/pkg/config/config.go @@ -20,7 +20,7 @@ type Config struct { HTTP HTTP `yaml:"http"` - DisablePreviews bool `yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEBDAV_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable all preview related webdav paths."` + DisablePreviews bool `yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEBDAV_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable all preview related webdav paths."` OcisPublicURL string `yaml:"ocis_public_url" env:"OCIS_URL;OCIS_PUBLIC_URL" desc:"URL, where oCIS is reachable for users."` WebdavNamespace string `yaml:"webdav_namespace" env:"WEBDAV_WEBDAV_NAMESPACE" desc:"CS3 path layout to use when forwarding /webdav requests"` RevaGateway string `yaml:"reva_gateway" env:"OCIS_REVA_GATEWAY;REVA_GATEWAY" desc:"CS3 gateway used to look up user metadata" deprecationVersion:"3.0" removalVersion:"4.0.0" deprecationInfo:"REVA_GATEWAY changing name for consistency" deprecationReplacement:"OCIS_REVA_GATEWAY"` From 3257b36eb46ef38a69c22d1859293982d3d68bd9 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Mon, 26 Jun 2023 09:23:33 +0200 Subject: [PATCH 5/6] fix error in changelog Signed-off-by: Christian Richter --- changelog/unreleased/disable-thumbnailer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/disable-thumbnailer.md b/changelog/unreleased/disable-thumbnailer.md index c32e1e8d1..0d420494e 100644 --- a/changelog/unreleased/disable-thumbnailer.md +++ b/changelog/unreleased/disable-thumbnailer.md @@ -2,7 +2,7 @@ Enhancement: Thumbnails can be disabled for webdav & web now We added an env var `OCIS_DISABLE_PREVIEWS` to disable the thumbnails for web & webdav via a global setting. For each service this behaviour can be disabled using the local env vars `WEB_OPTION_DISABLE_PREVIEWS` (old) -and `WEBDAV_OPTION_DISABLE_PREVIEWS` (new). +and `WEBDAV_DISABLE_PREVIEWS` (new). https://github.com/owncloud/ocis/pull/6577 https://github.com/owncloud/ocis/issues/192 \ No newline at end of file From a67c2c40a3482d68d9acc55ea682cabafe2a8a51 Mon Sep 17 00:00:00 2001 From: Christian Richter <1058116+dragonchaser@users.noreply.github.com> Date: Tue, 27 Jun 2023 13:26:59 +0200 Subject: [PATCH 6/6] Update services/web/pkg/config/options.go Co-authored-by: kobergj --- services/web/pkg/config/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/pkg/config/options.go b/services/web/pkg/config/options.go index 9e88c176a..5c7d8bef2 100644 --- a/services/web/pkg/config/options.go +++ b/services/web/pkg/config/options.go @@ -4,7 +4,7 @@ package config type Options struct { HomeFolder string `json:"homeFolder,omitempty" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"Specifies a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory, it simply serves as a default location. A static location can be provided, or variables of the user object to come up with a user specific home path can be used. This uses the twig template variable style and allows picking a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` OpenAppsInTab bool `json:"openAppsInTab,omitempty" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions should generally open in a new tab. Defaults to false."` - DisablePreviews bool `json:"disablePreviews,omitempty" yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different web file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` + DisablePreviews bool `json:"disablePreviews,omitempty" yaml:"disablePreviews" env:"OCIS_DISABLE_PREVIEWS;WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different web file listing views. This can speed up file listings in folders with many files. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` PreviewFileMimeTypes []string `json:"previewFileMimeTypes,omitempty" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the UI. For example to only preview jpg and text files, set this option to ['image/jpeg', 'text/plain']."` AccountEditLink *AccountEditLink `json:"accountEditLink,omitempty" yaml:"accountEditLink"` DisableFeedbackLink bool `json:"disableFeedbackLink,omitempty" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled by setting the value to 'false' or with the absence of the option, allows ownCloud to get feedback from your user base through a dedicated survey website."`