Skip to content

Commit

Permalink
check xattr.Remove errors on macOS (#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
fschade authored Dec 2, 2020
1 parent d8c6290 commit ee561f9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-xattr-error-darwin.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion pkg/storage/fs/ocis/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand Down
4 changes: 3 additions & 1 deletion pkg/storage/fs/ocis/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/storage/fs/owncloud/owncloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit ee561f9

Please sign in to comment.