diff --git a/changelog/unreleased/fix-xattr-error-darwin.md b/changelog/unreleased/fix-xattr-error-darwin.md new file mode 100644 index 0000000000..b5945fa09f --- /dev/null +++ b/changelog/unreleased/fix-xattr-error-darwin.md @@ -0,0 +1,5 @@ +Bugfix: Fix xattr.Remove error check for macOS + +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 68880be98e..ff167a8b41 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..22fb636eb5 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).