"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
local: use atomic types
Roberto Riccia56c11753a70
diff --git a/backend/local/local.go b/backend/local/local.goindex bb9f739eb..5cee05af4 100644--- a/backend/local/local.go+++ b/backend/local/local.go@@ -13,6 +13,7 @@ import ("runtime""strings""sync"+ "sync/atomic""time""unicode/utf8"@@ -243,7 +244,7 @@ type Fs struct {precision time.Duration // precision of local filesystemwarnedMu sync.Mutex // used for locking access to 'warned'.warned map[string]struct{} // whether we have warned about this string- xattrSupported int32 // whether xattrs are supported (atomic access)+ xattrSupported atomic.Int32 // whether xattrs are supported// do os.Lstat or os.Statlstat func(name string) (os.FileInfo, error)@@ -291,7 +292,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, elstat: os.Lstat,}if xattrSupported {- f.xattrSupported = 1+ f.xattrSupported.Store(1)}f.root = cleanRootPath(root, f.opt.NoUNC, f.opt.Enc)f.features = (&fs.Features{diff --git a/backend/local/xattr.go b/backend/local/xattr.goindex 81e86d8a5..fec0e4e7b 100644--- a/backend/local/xattr.go+++ b/backend/local/xattr.go@@ -6,7 +6,6 @@ package localimport ("fmt""strings"- "sync/atomic""syscall""github.com/pkg/xattr"@@ -28,7 +27,7 @@ func (f *Fs) xattrIsNotSupported(err error) bool {// Xattrs not supported can be ENOTSUP or ENOATTR or EINVAL (on Solaris)if xattrErr.Err == syscall.EINVAL || xattrErr.Err == syscall.ENOTSUP || xattrErr.Err == xattr.ENOATTR {// Show xattrs not supported- if atomic.CompareAndSwapInt32(&f.xattrSupported, 1, 0) {+ if f.xattrSupported.CompareAndSwap(1, 0) {fs.Errorf(f, "xattrs not supported - disabling: %v", err)}return true@@ -41,7 +40,7 @@ func (f *Fs) xattrIsNotSupported(err error) bool {// It doesn't return any attributes owned by this backend in// metadataKeysfunc (o *Object) getXattr() (metadata fs.Metadata, err error) {- if !xattrSupported || atomic.LoadInt32(&o.fs.xattrSupported) == 0 {+ if !xattrSupported || o.fs.xattrSupported.Load() == 0 {return nil, nil}var list []string@@ -90,7 +89,7 @@ func (o *Object) getXattr() (metadata fs.Metadata, err error) {//// It doesn't set any attributes owned by this backend in metadataKeysfunc (o *Object) setXattr(metadata fs.Metadata) (err error) {- if !xattrSupported || atomic.LoadInt32(&o.fs.xattrSupported) == 0 {+ if !xattrSupported || o.fs.xattrSupported.Load() == 0 {return nil}for k, value := range metadata {