-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include generic xattr syncmeta application
- Loading branch information
1 parent
406ff8b
commit fba55e4
Showing
4 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters