From feeb8bc39c019e0dd811dae9ea09fe517c1558e8 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Tue, 1 Dec 2020 16:10:23 +0100 Subject: [PATCH 1/3] check xattr.Remove errors on macOS --- pkg/storage/fs/ocis/metadata.go | 4 +++- pkg/storage/fs/ocis/node.go | 4 +++- pkg/storage/fs/owncloud/owncloud.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/storage/fs/ocis/metadata.go b/pkg/storage/fs/ocis/metadata.go index 68880be98e..a2c0f56a27 100644 --- a/pkg/storage/fs/ocis/metadata.go +++ b/pkg/storage/fs/ocis/metadata.go @@ -90,7 +90,9 @@ func (fs *ocisfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Refe if err = xattr.Remove(nodePath, attrName); err != nil { // a non-existing attribute will return an error, which we can ignore // (using string compare because the error type is syscall.Errno and not wrapped/recognizable) - if e, ok := err.(*xattr.Error); !ok || e.Err.Error() != "no data available" { + if e, ok := err.(*xattr.Error); !ok || (e.Err.Error() != "no data available" || + // darwin + e.Err.Error() != "attribute not found") { appctx.GetLogger(ctx).Error().Err(err). Interface("node", n). Str("key", keys[i]). diff --git a/pkg/storage/fs/ocis/node.go b/pkg/storage/fs/ocis/node.go index fe71edef96..bcde7b28cc 100644 --- a/pkg/storage/fs/ocis/node.go +++ b/pkg/storage/fs/ocis/node.go @@ -431,7 +431,9 @@ func (n *Node) SetTMTime(t time.Time) (err error) { // UnsetTempEtag removes the temporary etag attribute func (n *Node) UnsetTempEtag() (err error) { if err = xattr.Remove(n.lu.toInternalPath(n.ID), tmpEtagAttr); err != nil { - if e, ok := err.(*xattr.Error); ok && e.Err.Error() == "no data available" { + if e, ok := err.(*xattr.Error); ok && (e.Err.Error() == "no data available" || + // darwin + e.Err.Error() == "attribute not found") { return nil } } diff --git a/pkg/storage/fs/owncloud/owncloud.go b/pkg/storage/fs/owncloud/owncloud.go index 6e08cf4047..4303bdb1ed 100644 --- a/pkg/storage/fs/owncloud/owncloud.go +++ b/pkg/storage/fs/owncloud/owncloud.go @@ -1361,7 +1361,9 @@ func (fs *ocfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Refere if err = xattr.Remove(ip, mdPrefix+k); err != nil { // a non-existing attribute will return an error, which we can ignore // (using string compare because the error type is syscall.Errno and not wrapped/recognizable) - if e, ok := err.(*xattr.Error); !ok || e.Err.Error() != "no data available" { + if e, ok := err.(*xattr.Error); !ok || (e.Err.Error() != "no data available" || + // darwin + e.Err.Error() != "attribute not found") { log.Error().Err(err). Str("ipath", ip). Str("key", k). From f2eea3141a1c2c65eb67a821d0483c4ee98112dc Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Tue, 1 Dec 2020 16:16:22 +0100 Subject: [PATCH 2/3] add changelog --- changelog/unreleased/fix-xattr-error-darwin.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/unreleased/fix-xattr-error-darwin.md diff --git a/changelog/unreleased/fix-xattr-error-darwin.md b/changelog/unreleased/fix-xattr-error-darwin.md new file mode 100644 index 0000000000..d6ce1f817c --- /dev/null +++ b/changelog/unreleased/fix-xattr-error-darwin.md @@ -0,0 +1,5 @@ +Bugfix: Fix xattrr.Remove error check for macOS + +Previously, we checked the xattrr.Remove only for linux systems. Now macOS is checked also + +https://github.com/cs3org/reva/pull/1351 \ No newline at end of file From 1daf331072eaaafdb292c4d0792f4212a80412b4 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Tue, 1 Dec 2020 16:50:49 +0100 Subject: [PATCH 3/3] fix readme fix condition --- changelog/unreleased/fix-xattr-error-darwin.md | 4 ++-- pkg/storage/fs/ocis/metadata.go | 4 ++-- pkg/storage/fs/owncloud/owncloud.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/changelog/unreleased/fix-xattr-error-darwin.md b/changelog/unreleased/fix-xattr-error-darwin.md index d6ce1f817c..b5945fa09f 100644 --- a/changelog/unreleased/fix-xattr-error-darwin.md +++ b/changelog/unreleased/fix-xattr-error-darwin.md @@ -1,5 +1,5 @@ -Bugfix: Fix xattrr.Remove error check for macOS +Bugfix: Fix xattr.Remove error check for macOS -Previously, we checked the xattrr.Remove only for linux systems. Now macOS is checked also +Previously, we checked the xattr.Remove error only for linux systems. Now macOS is checked also https://github.com/cs3org/reva/pull/1351 \ No newline at end of file diff --git a/pkg/storage/fs/ocis/metadata.go b/pkg/storage/fs/ocis/metadata.go index a2c0f56a27..ff167a8b41 100644 --- a/pkg/storage/fs/ocis/metadata.go +++ b/pkg/storage/fs/ocis/metadata.go @@ -90,9 +90,9 @@ func (fs *ocisfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Refe if err = xattr.Remove(nodePath, attrName); err != nil { // a non-existing attribute will return an error, which we can ignore // (using string compare because the error type is syscall.Errno and not wrapped/recognizable) - if e, ok := err.(*xattr.Error); !ok || (e.Err.Error() != "no data available" || + if e, ok := err.(*xattr.Error); !ok || !(e.Err.Error() == "no data available" || // darwin - e.Err.Error() != "attribute not found") { + e.Err.Error() == "attribute not found") { appctx.GetLogger(ctx).Error().Err(err). Interface("node", n). Str("key", keys[i]). diff --git a/pkg/storage/fs/owncloud/owncloud.go b/pkg/storage/fs/owncloud/owncloud.go index 4303bdb1ed..22fb636eb5 100644 --- a/pkg/storage/fs/owncloud/owncloud.go +++ b/pkg/storage/fs/owncloud/owncloud.go @@ -1361,9 +1361,9 @@ func (fs *ocfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Refere if err = xattr.Remove(ip, mdPrefix+k); err != nil { // a non-existing attribute will return an error, which we can ignore // (using string compare because the error type is syscall.Errno and not wrapped/recognizable) - if e, ok := err.(*xattr.Error); !ok || (e.Err.Error() != "no data available" || + if e, ok := err.(*xattr.Error); !ok || !(e.Err.Error() == "no data available" || // darwin - e.Err.Error() != "attribute not found") { + e.Err.Error() == "attribute not found") { log.Error().Err(err). Str("ipath", ip). Str("key", k).