From 4b89ede756820004b5bae7d3a2b4a956bf2f085a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Mon, 15 Jan 2024 14:46:39 +0100 Subject: [PATCH 1/5] Do not error-log when outdated resources can't be indexed anymore That's an expected, totally valid case --- services/search/pkg/search/search.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/search/pkg/search/search.go b/services/search/pkg/search/search.go index 77eb5b741..6bce856ea 100644 --- a/services/search/pkg/search/search.go +++ b/services/search/pkg/search/search.go @@ -88,13 +88,17 @@ func statResource(ctx context.Context, ref *provider.Reference, gatewaySelector logger.Error().Err(err).Msg("failed to stat the moved resource") return nil, err } - if res.Status.Code != rpc.Code_CODE_OK { + switch res.Status.Code { + case rpc.Code_CODE_OK: + return res, nil + case rpc.Code_CODE_NOT_FOUND: + // Resource was moved or deleted in the meantime. ignore. + return nil, err + default: err := errors.New("failed to stat the moved resource") logger.Error().Interface("res", res).Msg(err.Error()) return nil, err } - - return res, nil } // NOTE: this converts CS3 to WebDAV permissions From 03f302227f59dac19f92c13c9eb42c282cb5a1d4 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Tue, 16 Jan 2024 13:00:03 +0100 Subject: [PATCH 2/5] fix update and reset the logo --- changelog/unreleased/fix-upload-reset-logo.md | 6 ++++ services/web/pkg/service/v0/branding.go | 29 ++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 changelog/unreleased/fix-upload-reset-logo.md diff --git a/changelog/unreleased/fix-upload-reset-logo.md b/changelog/unreleased/fix-upload-reset-logo.md new file mode 100644 index 000000000..7077a0068 --- /dev/null +++ b/changelog/unreleased/fix-upload-reset-logo.md @@ -0,0 +1,6 @@ +Bugfix: Updating and reset logo failed + +We fixed a bug when admin tried to update or reset the logo. + +https://github.com/owncloud/ocis/pull/8211 +https://github.com/owncloud/ocis/issues/8101 diff --git a/services/web/pkg/service/v0/branding.go b/services/web/pkg/service/v0/branding.go index 7afaf46e0..06606387b 100644 --- a/services/web/pkg/service/v0/branding.go +++ b/services/web/pkg/service/v0/branding.go @@ -145,12 +145,7 @@ func (p Web) getLogoPath(r io.Reader) (string, error) { var m map[string]interface{} _ = json.NewDecoder(r).Decode(&m) - webCfg, ok := m["clients"].(map[string]interface{})["web"].(map[string]interface{}) - if !ok { - return "", errInvalidThemeConfig - } - - logoCfg, ok := webCfg["defaults"].(map[string]interface{})["logo"].(map[string]interface{}) + logoCfg, ok := extractMap(m, "clients", "web", "defaults", "logo") if !ok { return "", errInvalidThemeConfig } @@ -175,18 +170,13 @@ func (p Web) updateLogoThemeConfig(logoPath string) error { _ = json.NewDecoder(f).Decode(&m) // change logo in common part - commonCfg, ok := m["common"].(map[string]interface{}) + commonCfg, ok := extractMap(m, "common") if !ok { return errInvalidThemeConfig } commonCfg["logo"] = logoPath - webCfg, ok := m["clients"].(map[string]interface{})["web"].(map[string]interface{}) - if !ok { - return errInvalidThemeConfig - } - - logoCfg, ok := webCfg["defaults"].(map[string]interface{})["logo"].(map[string]interface{}) + logoCfg, ok := extractMap(m, "clients", "web", "defaults", "logo") if !ok { return errInvalidThemeConfig } @@ -209,3 +199,16 @@ func allowedFiletype(filename, mediatype string) bool { mt, ok := _allowedExtensionMediatypes[ext] return ok && mt == mediatype } + +// extractMap extracts embedded map[string]interface{} by the keys chain +func extractMap(data map[string]interface{}, keys ...string) (map[string]interface{}, bool) { + last := data + var ok bool + for _, key := range keys { + last, ok = last[key].(map[string]interface{}) + if !ok { + return nil, false + } + } + return last, true +} From 5b131b75714926a11749311ebf84c9928aae3074 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Tue, 16 Jan 2024 15:52:26 +0000 Subject: [PATCH 3/5] Automated changelog update [skip ci] --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d8f324d5..a61b28a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ The following sections list the changes for unreleased. * Bugfix - Fix wrong naming in nats-js-kv registry: [#8140](https://github.com/owncloud/ocis/pull/8140) * Bugfix - IDP CS3 backend sessions now survire restart: [#8142](https://github.com/owncloud/ocis/pull/8142) * Bugfix - Fix patching of language: [#8182](https://github.com/owncloud/ocis/pull/8182) +* Bugfix - Updating and reset logo failed: [#8211](https://github.com/owncloud/ocis/pull/8211) * Enhancement - Disable the password policy: [#7985](https://github.com/owncloud/ocis/pull/7985) * Enhancement - Update antivirus service: [#8062](https://github.com/owncloud/ocis/pull/8062) * Enhancement - Update reva to latest edge version: [#8100](https://github.com/owncloud/ocis/pull/8100) @@ -94,6 +95,13 @@ The following sections list the changes for unreleased. https://github.com/owncloud/ocis/pull/8182 +* Bugfix - Updating and reset logo failed: [#8211](https://github.com/owncloud/ocis/pull/8211) + + We fixed a bug when admin tried to update or reset the logo. + + https://github.com/owncloud/ocis/issues/8101 + https://github.com/owncloud/ocis/pull/8211 + * Enhancement - Disable the password policy: [#7985](https://github.com/owncloud/ocis/pull/7985) We add the environment variable that allow to disable the password policy. From 599634148d9321112d5657efd867d61a96e1214b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Tue, 16 Jan 2024 16:44:05 +0100 Subject: [PATCH 4/5] Add changelog --- changelog/unreleased/fix-search-logging.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/unreleased/fix-search-logging.md diff --git a/changelog/unreleased/fix-search-logging.md b/changelog/unreleased/fix-search-logging.md new file mode 100644 index 000000000..a9347c74d --- /dev/null +++ b/changelog/unreleased/fix-search-logging.md @@ -0,0 +1,6 @@ +Bugfix: Fix search service to not log expected cases as errors + +We changed the search service to not log cases where resources that were about to be indexed can no longer be found. +Those are expected cases, e.g. when the file in question has already been deleted or renamed meanwhile. + +https://github.com/owncloud/ocis/pull/8200 From b758d2860e66192ef4169c3affc94c254de9104d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Tue, 16 Jan 2024 15:54:58 +0000 Subject: [PATCH 5/5] Automated changelog update [skip ci] --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a61b28a3f..26940185a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ The following sections list the changes for unreleased. * Bugfix - Fix wrong naming in nats-js-kv registry: [#8140](https://github.com/owncloud/ocis/pull/8140) * Bugfix - IDP CS3 backend sessions now survire restart: [#8142](https://github.com/owncloud/ocis/pull/8142) * Bugfix - Fix patching of language: [#8182](https://github.com/owncloud/ocis/pull/8182) +* Bugfix - Fix search service to not log expected cases as errors: [#8200](https://github.com/owncloud/ocis/pull/8200) * Bugfix - Updating and reset logo failed: [#8211](https://github.com/owncloud/ocis/pull/8211) * Enhancement - Disable the password policy: [#7985](https://github.com/owncloud/ocis/pull/7985) * Enhancement - Update antivirus service: [#8062](https://github.com/owncloud/ocis/pull/8062) @@ -95,6 +96,14 @@ The following sections list the changes for unreleased. https://github.com/owncloud/ocis/pull/8182 +* Bugfix - Fix search service to not log expected cases as errors: [#8200](https://github.com/owncloud/ocis/pull/8200) + + We changed the search service to not log cases where resources that were about + to be indexed can no longer be found. Those are expected cases, e.g. when the + file in question has already been deleted or renamed meanwhile. + + https://github.com/owncloud/ocis/pull/8200 + * Bugfix - Updating and reset logo failed: [#8211](https://github.com/owncloud/ocis/pull/8211) We fixed a bug when admin tried to update or reset the logo.