Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check xattr.Remove errors on macOS #1351

Merged
merged 3 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 xattrr.Remove error check for macOS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in xattrr 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, done 👍


Previously, we checked the xattrr.Remove 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