Skip to content

Commit

Permalink
Include generic xattr syncmeta application
Browse files Browse the repository at this point in the history
  • Loading branch information
adreed-msft committed Jan 11, 2023
1 parent 406ff8b commit fba55e4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
3 changes: 1 addition & 2 deletions common/hash_data_other.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
//go:build !windows && !linux && !darwin && !freebsd && !netbsd && !solaris

package common

Expand Down
35 changes: 35 additions & 0 deletions common/hash_data_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//go:build linux || darwin || freebsd || netbsd || solaris

// additional *NIX based OSes included since it uses a generic xattr implementation.

package common

import (
"encoding/json"
"github.com/pkg/xattr"
)

var AzCopySyncMetaXAttr = "azcopy.syncmeta"

func TryGetHashData(fullpath string) (SyncHashData, error) {
// LGet because we want to target the file we actually specify, not what's on the other end.
buf, err := xattr.LGet(fullpath, AzCopySyncMetaXAttr)
if err != nil {
return SyncHashData{}, err
}

var out SyncHashData
err = json.Unmarshal(buf, &out)

return out, err
}

func PutHashData(fullpath string, data SyncHashData) error {
buf, err := json.Marshal(data)
if err != nil {
return err
}

// LSet because we want to target the file we actually specify, not what's on the other end.
return xattr.LSet(fullpath, AzCopySyncMetaXAttr, buf)
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ require (
github.com/mattn/go-ieproxy v0.0.3
github.com/minio/minio-go v6.0.14+incompatible
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.6
github.com/pkg/xattr v0.4.9
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/spf13/cobra v1.4.0
github.com/wastore/keychain v0.0.0-20180920053336-f2c902a3d807
github.com/wastore/keyctl v0.3.1
golang.org/x/crypto v0.0.0-20220314234724-5d542ad81a58
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f
google.golang.org/api v0.72.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
)
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/xattr v0.4.6 h1:0vqthLIMxQKA9VscyMcxjvAUGvyfzlk009vwLE8OZJg=
github.com/pkg/xattr v0.4.6/go.mod h1:sBD3RAqlr8Q+RC3FutZcikpT8nyDrIEEBw2J744gVWs=
github.com/pkg/xattr v0.4.9 h1:5883YPCtkSd8LFbs13nXplj9g9tlrwoJRjgpgMu1/fE=
github.com/pkg/xattr v0.4.9/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6ktU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down Expand Up @@ -460,6 +462,8 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f h1:8w7RhxzTVgUzw/AH/9mUV5q0vMgy40SQRursCcfmkCw=
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down

0 comments on commit fba55e4

Please sign in to comment.