all: Support syncing ownership (fixes #1329) (#8434)

This adds support for syncing ownership on Unixes and on Windows. The
scanner always picks up ownership information, but it is not applied
unless the new folder option "Sync Ownership" is set.

Ownership data is stored in a new FileInfo field called "platform data". This
is intended to hold further platform-specific data in the future
(specifically, extended attributes), which is why the whole design is a
bit overkill for just ownership.
This commit is contained in:
Jakob Borg
2022-07-26 08:24:58 +02:00
committed by GitHub
parent 34a5f087c8
commit adce6fa473
35 changed files with 1896 additions and 500 deletions
+4 -1
View File
@@ -14,6 +14,8 @@ import (
"path/filepath"
"strings"
"time"
"github.com/syncthing/syncthing/lib/protocol"
)
type filesystemWrapperType int32
@@ -30,7 +32,7 @@ const (
// The Filesystem interface abstracts access to the file system.
type Filesystem interface {
Chmod(name string, mode FileMode) error
Lchown(name string, uid, gid int) error
Lchown(name string, uid, gid string) error // uid/gid as strings; numeric on POSIX, SID on Windows, like in os/user package
Chtimes(name string, atime time.Time, mtime time.Time) error
Create(name string) (File, error)
CreateSymlink(target, name string) error
@@ -60,6 +62,7 @@ type Filesystem interface {
URI() string
Options() []Option
SameFile(fi1, fi2 FileInfo) bool
PlatformData(name string) (protocol.PlatformData, error)
// Used for unwrapping things
underlying() (Filesystem, bool)