Skip to content

all: Support syncing ownership (fixes #xxx) - #8415

Closed
calmh wants to merge 5 commits into
syncthing:mainfrom
calmh:owners
Closed

calmh wants to merge 5 commits into
syncthing:mainfrom
calmh:owners

Conversation

@calmh

@calmh calmh commented Jul 5, 2022 •

Copy link
Copy Markdown
Member

This adds support for syncing ownership on Unixes and on Windows. The
mechanism is disabled unless the new folder option "Sync Ownership" is set.

Ownership data is stored in a new FileInfo field called "OS data". This
is intended to hold further OS specific data in the future
(specifically, extended attributes), which is why the whole design is a
bit overkill for just ownership.

https://github.com/syncthing/docs/pull/759/files

calmh added 4 commits July 5, 2022 10:01
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 "OS data". This
is intended to hold further OS specific data in the future
(specifically, extended attributes), which is why the whole design is a
bit overkill for just ownership.
@calmh
calmh marked this pull request as draft July 5, 2022 08:31
@calmh
calmh marked this pull request as ready for review July 6, 2022 08:55
OS_WINDOWS = 2;
}

message POSIXOSData {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feels like the OS part in the name is redundant?

Also, POSIX is not really an "OS", so if we decide to keep it, not sure I like the name? Perhaps "Platform" ?

// POSIX data in the entry for OS_POSIX. The actual type of each entry
// is message ${OS}OSData. Protobuf doesn't have enum-keyed maps so this
// is an int32-keyed one instead, but the concept is the same.
map<int32, bytes> os_data = 14 [(gogoproto.castkey) = "OS", (ext.goname) = "OSData"];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess I called out this before, but I dislike maps.
I guess we only want to have one of them here, so perhaps it's ok?

Comment thread lib/scanner/walk.go

// Copy OS data from src to dst, unless it was already set on dst.
if len(dst.OSData) == 0 {
dst.OSData = src.OSData

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this really a copy? Haven't written go in a while at this point, but feels like if someone does a bunch of delete from the map, and you'd be chasing this rabbit for a while.

//
// XXX: Technically, the serialized form of protobuf messages isn't
// guaranteed to be stable. In practice it is, and this is a much easier
// comparison than deserializing each thing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the purpose of "compatability" with other non-existing re-implementations, I wouldn't do this, and do it right.

I've also been hurt by this between different versions of proto packages (not that I think it matters to us too much).

FilePermissions() uint32
FileModifiedBy() ShortID
ModTime() time.Time
LoadOSData(os OS, dst interface{ Unmarshal([]byte) error }) bool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is very yuck.

I'd rather had an explicit fields with data for each platform, i.e:

message PosixPlatformData {
...
}
message WindowsPlatformData {
...
}

message PlatformData {
  PosixPlatformData posix = 1;
  WindowsPlatformData  windows = 2;
}

then, there is no loading magic, and you can just do have platform specific .apply(PlatformData) stuff.

Comment thread lib/fs/osdata_windows.go
// The underlying filesystem must be a BasicFilesystem, because we're
// going to assume the file is an object on local disk and make system
// calls on it.
basic, ok := p.fs.(*BasicFilesystem)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lib/fs/filesystem.go:unwrapFilesystem?

Comment thread lib/fs/osdata_windows.go
l.Debugln("OS data for", rootedName, "is", pd)
return map[protocol.OS][]byte{
protocol.OsWindows: bs,
}, nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This always returns a map with one entry, feels like you could just return (type, byte[], error)

Comment thread lib/fs/basicfs.go
root: root,
options: opts,
}
fs.OSDataGetter = NewOSDataGetter(fs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is somewhat grim, could we not have platform specific implementations for this, simillar like we have for notify etc?

@calmh calmh closed this Jul 21, 2022
@calmh
calmh deleted the owners branch July 26, 2022 08:10
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jul 21, 2023
@syncthing syncthing locked and limited conversation to collaborators Jul 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants